| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef REND_OPENGL_H |
| 20 | #define REND_OPENGL_H |
| 21 | |
| 22 | #include "renderer.h" |
| 23 | #include "3d.h" |
| 24 | |
| 25 | class oeApplication; |
| 26 | |
| 27 | // Starts up opengl |
| 28 | int opengl_Init(oeApplication *app, renderer_preferred_state *pref_state); |
| 29 | |
| 30 | // Closes down opengl |
| 31 | void opengl_Close(const bool just_resizing=false); |
| 32 | void opengl_Shutdown(); |
| 33 | |
| 34 | // The main drawing function...draws a flat/textured/gouraud polygon |
| 35 | void opengl_DrawPolygon(int, g3Point **, int, int); |
| 36 | |
| 37 | void opengl_SetFlatColor(ddgr_color color); |
| 38 | |
| 39 | // Ends a frame |
| 40 | void opengl_EndFrame(); |
| 41 | |
| 42 | // Flips the screen |
| 43 | void opengl_Flip(); |
| 44 | |
| 45 | // Does setup for a new frame |
| 46 | void opengl_BeginFrame(int, int, int, int, int); |
| 47 | |
| 48 | // Tells opengl what kind of texturing (linear/perspective) we want |
| 49 | void opengl_SetTextureType(texture_type); |
| 50 | |
| 51 | // Sets the lighting state of opengl |
| 52 | void opengl_SetLightingState(light_state state); |
| 53 | |
| 54 | // Sets the opengl color model (either rgb or mono) |
| 55 | void opengl_SetColorModel(color_model state); |
| 56 | |
| 57 | // Sets the state of bilinear filtering for our textures |
| 58 | void opengl_SetFiltering(int8_t state); |
| 59 | |
| 60 | // Sets the state of zbuffering to on or off |
| 61 | void opengl_SetZBufferState(int8_t state); |
| 62 | |
| 63 | // Sets the near/far z values for zbuffering |
| 64 | void opengl_SetZValues(float nearz, float farz); |
| 65 | |
| 66 | // Sets a bitmap as a lightmap to rendered on top of the next texture map |
| 67 | // a -1 value indicates no lighting map |
| 68 | void opengl_SetLightingMap(int handle); |
| 69 | |
| 70 | // Clears the display to a specified color |
| 71 | void opengl_ClearScreen(ddgr_color color); |
| 72 | |
| 73 | // Fills a rectangle on the display |
| 74 | void opengl_FillRect(ddgr_color color, int x1, int y1, int x2, int y2); |
| 75 | |
| 76 | // Sets a pixel on the display |
| 77 | void opengl_SetPixel(ddgr_color color, int x, int y); |
| 78 | |
| 79 | // Sets the near and far plane of fog |
| 80 | void opengl_SetFogBorders(float nearz, float farz); |
| 81 | |
| 82 | // Sets the fog state to on or off |
| 83 | void opengl_SetFogState(int8_t state); |
| 84 | |
| 85 | // Fills in projection variables |
| 86 | void opengl_GetProjectionParameters(int *width, int *height); |
| 87 | void opengl_GetProjectionScreenParameters(int &screenLX, int &screenTY, int &screenW, int &screenH); |
| 88 | |
| 89 | // Returns the aspect ratio of the physical screen |
| 90 | float opengl_GetAspectRatio(); |
| 91 | |
| 92 | // Sets texture wrapping type |
| 93 | void opengl_SetWrapType(wrap_type val); |
| 94 | |
| 95 | // Sets the constant alpha value |
| 96 | void opengl_SetAlphaValue(uint8_t val); |
| 97 | |
| 98 | // Sets the overall alpha scale factor (all alpha values are scaled by this value) |
| 99 | // usefull for motion blur effect |
| 100 | void opengl_SetAlphaFactor(float val); |
| 101 | |
| 102 | // Returns the current Alpha factor |
| 103 | float opengl_GetAlphaFactor(void); |
| 104 | |
| 105 | // Sets the type of alpha blending you want |
| 106 | void opengl_SetAlphaType(int8_t atype); |
| 107 | |
| 108 | // Sets whether or not to write into the zbuffer |
| 109 | void opengl_SetZBufferWriteMask(int state); |
| 110 | |
| 111 | // Gets the current state of the renderer |
| 112 | void opengl_GetRenderState(rendering_state *rstate); |
| 113 | |
| 114 | // draws a line |
| 115 | void opengl_DrawLine(int x1, int y1, int x2, int y2); |
| 116 | |
| 117 | // draws a line |
| 118 | void opengl_DrawSpecialLine(g3Point *p0, g3Point *p1); |
| 119 | |
| 120 | // Sets the color that opengl uses for fog |
| 121 | void opengl_SetFogColor(ddgr_color color); |
| 122 | |
| 123 | // Sets the coplanar z bias for rendered polygons |
| 124 | void opengl_SetCoplanarPolygonOffset(float factor); |
| 125 | |
| 126 | // Sets up a some global preferences for openGL |
| 127 | int opengl_SetPreferredState(renderer_preferred_state *pref_state); |
| 128 | |
| 129 | // Sets the gamma correction value |
| 130 | void opengl_SetGammaValue(float val); |
| 131 | |
| 132 | // Takes a screenshot of the frontbuffer and puts it into the passed bitmap handle |
| 133 | void opengl_Screenshot(int bm_handle); |
| 134 | |
| 135 | // Returns the pixel color at x,y |
| 136 | ddgr_color opengl_GetPixel(int, int); |
| 137 | |
| 138 | // Clears the zbuffer |
| 139 | void opengl_ClearZBuffer(); |
| 140 | |
| 141 | // Clears the texture cache |
| 142 | void opengl_ResetCache(); |
| 143 | |
| 144 | // Takes a bitmap and blits it to the screen using linear frame buffer stuff |
| 145 | // X and Y are the destination X,Y |
| 146 | void opengl_CopyBitmapToFramebuffer(int bm_handle, int x, int y); |
| 147 | |
| 148 | // Gets a renderer ready for a framebuffer copy, or stops a framebuffer copy |
| 149 | void opengl_SetFrameBufferCopyState(bool state); |
| 150 | |
| 151 | #if defined(WIN32) |
| 152 | // returns directdraw object |
| 153 | void *opengl_DirectDrawObj(); |
| 154 | #endif |
| 155 | |
| 156 | // returns rendering statistics for the frame |
| 157 | void opengl_GetStatistics(tRendererStats *stats); |
| 158 | |
| 159 | |
| 160 | #endif |