Debian Codegraph @

renderer/HardwareOpenGL.cpp

raw symbols SCIP
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 #include <algorithm>
20 #include <cstdlib>
21 #include <cstdio>
22 #include <cstring>
23 #include <SDL.h>
24
25 #if defined(WIN32)
26 #include <windows.h>
27 #endif
28
29 #include "byteswap.h"cxx . . $ `<file>/lib/byteswap.h`/
30 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
31 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
32 #include "3d.h"cxx . . $ `<file>/lib/3d.h`/
33 #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/
34 #include "application.h"cxx . . $ `<file>/lib/application.h`/
35 #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/
36 #include "lightmap.h"cxx . . $ `<file>/lib/lightmap.h`/
37 #include "rend_opengl.h"cxx . . $ `<file>/lib/rend_opengl.h`/
38 #include "grdefs.h"cxx . . $ `<file>/lib/grdefs.h`/
39 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
40 #include "config.h"cxx . . $ `<file>/Descent3/config.h`/
41 #include "rtperformance.h"cxx . . $ `<file>/rtperformance/rtperformance.h`/
42 #include "HardwareInternal.h"cxx . . $ `<file>/renderer/HardwareInternal.h`/
43 #include "../Descent3/args.h"cxx . . $ `<file>/Descent3/args.h`/
44 #include "NewBitmap.h"cxx . . $ `<file>/bitmap/NewBitmap.h`/
45
46 #define DECLARE_OPENGLcxx . . $ `renderer/HardwareOpenGL.cpp:46:9`!
47 #include "dyna_gl.h"cxx . . $ `<file>/renderer/dyna_gl.h`/
48
49 #if defined(WIN32)
50 #include "win/arb_extensions.h"
51 #endif
52
53 int FindArgcxx . . $ FindArg(5c4306d8553b3696).(const char *);
54 void rend_SetLightingStatecxx . . $ rend_SetLightingState(e55526c9d3dd1656).(light_statecxx . . $ light_state# state);
55
56 // General renderer states
57 extern int gpu_Overlay_mapcxx . . $ gpu_Overlay_map.;
58 int Bump_mapcxx . . $ Bump_map. = 0;
59 int Bumpmap_readycxx . . $ Bumpmap_ready. = 0;
60 extern uint8_tcxx . . $ uint8_t# gpu_Overlay_typecxx . . $ gpu_Overlay_type.;
61 float Z_biascxx . . $ Z_bias. = 0.0f;
62 uint8_tcxx . . $ uint8_t# Renderer_close_flagcxx . . $ Renderer_close_flag. = 0;
63 extern uint8_tcxx . . $ uint8_t# Renderer_inittedcxx . . $ Renderer_initted.;
64 renderer_typecxx . . $ renderer_type# Renderer_typecxx . . $ Renderer_type. = RENDERER_OPENGLcxx . . $ RENDERER_OPENGL.;
65 int WindowGLcxx . . $ WindowGL. = 0;
66
67 #ifndef GL_UNSIGNED_SHORT_5_5_5_1cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1512:9`!
68 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
69 #endif
70
71 #ifndef GL_UNSIGNED_SHORT_4_4_4_4cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1510:9`!
72 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
73 #endif
74
75 #define CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(x)
76
77 SDL_Window *GSDLWindowcxx . . $ GSDLWindow. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
78 SDL_GLContext GSDLGLContextcxx . . $ GSDLGLContext. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
79 char loadedLibrarycxx . . $ loadedLibrary.[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
80
81 #define GET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:81:9`!(x) (x >> 4)
82 #define GET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:82:9`!(x) (x & 0x0f)
83
84 #define SET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:84:9`!(x, s) \
85 { \
86 x &= 0x0F; \
87 x |= (s << 4); \
88 }
89 #define SET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:89:9`!(x, s) \
90 { \
91 x &= 0xF0; \
92 x |= (s); \
93 }
94
95 // OpenGL Stuff
96 static int OpenGL_window_inittedcxx . . $ OpenGL_window_initted. = 0;
97 static int OpenGL_polys_drawncxx . . $ OpenGL_polys_drawn. = 0;
98 static int OpenGL_verts_processedcxx . . $ OpenGL_verts_processed. = 0;
99 static int OpenGL_uploadscxx . . $ OpenGL_uploads. = 0;
100 static int OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[10];
101 static int OpenGL_packed_pixelscxx . . $ OpenGL_packed_pixels. = 0;
102 static int Cur_texture_object_numcxx . . $ Cur_texture_object_num. = 1;
103 static int OpenGL_cache_inittedcxx . . $ OpenGL_cache_initted. = 0;
104 static int OpenGL_last_boundcxx . . $ OpenGL_last_bound.[2];
105 static int Last_texel_unit_setcxx . . $ Last_texel_unit_set. = -1;
106
107 extern int gpu_last_frame_polys_drawncxx . . $ gpu_last_frame_polys_drawn.;
108 extern int gpu_last_frame_verts_processedcxx . . $ gpu_last_frame_verts_processed.;
109 extern int gpu_last_uploadedcxx . . $ gpu_last_uploaded.;
110
111 extern float gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.;
112 extern float gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier.;
113
114 #if defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!)
115 PFNGLACTIVETEXTUREARBPROC oglActiveTextureARBcxx . . $ oglActiveTextureARB. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
116 PFNGLCLIENTACTIVETEXTUREARBPROC oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
117 PFNGLMULTITEXCOORD4FARBPROC oglMultiTexCoord4fcxx . . $ oglMultiTexCoord4f. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
118 #endif
119
120 uint16_tcxx . . $ uint16_t# *OpenGL_bitmap_remapcxx . . $ OpenGL_bitmap_remap. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
121 uint16_tcxx . . $ uint16_t# *OpenGL_lightmap_remapcxx . . $ OpenGL_lightmap_remap. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
122 uint8_tcxx . . $ uint8_t# *OpenGL_bitmap_statescxx . . $ OpenGL_bitmap_states. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
123 uint8_tcxx . . $ uint8_t# *OpenGL_lightmap_statescxx . . $ OpenGL_lightmap_states. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
124
125 uint32_tcxx . . $ uint32_t# *opengl_Upload_datacxx . . $ opengl_Upload_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
126 uint32_tcxx . . $ uint32_t# *opengl_Translate_tablecxx . . $ opengl_Translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
127 uint32_tcxx . . $ uint32_t# *opengl_4444_translate_tablecxx . . $ opengl_4444_translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
128
129 uint16_tcxx . . $ uint16_t# *opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
130 uint16_tcxx . . $ uint16_t# *opengl_packed_Translate_tablecxx . . $ opengl_packed_Translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
131 uint16_tcxx . . $ uint16_t# *opengl_packed_4444_translate_tablecxx . . $ opengl_packed_4444_translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
132
133 extern rendering_statecxx . . $ rendering_state# gpu_statecxx . . $ gpu_state.;
134 extern renderer_preferred_statecxx . . $ renderer_preferred_state# gpu_preferred_statecxx . . $ gpu_preferred_state.;
135
136 bool OpenGL_multitexture_statecxx . . $ OpenGL_multitexture_state. = false;
137 modulecxx . . $ module# *OpenGLDLLHandlecxx . . $ OpenGLDLLHandle. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
138 int Already_loadedcxx . . $ Already_loaded. = 0;
139 bool opengl_Blending_oncxx . . $ opengl_Blending_on. = 0;
140
141 static oeApplicationcxx . . $ oeApplication# *ParentApplicationcxx . . $ ParentApplication. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
142
143 /* framebuffer object for backbuffer, scale to window size without changing resolution. --ryan, 2019. */
144 #define GL_DEPTH_COMPONENT16_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:144:9`! 0x81A5
145 #define GL_READ_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:145:9`! 0x8CA8
146 #define GL_DRAW_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:146:9`! 0x8CA9
147 #define GL_FRAMEBUFFER_COMPLETE_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:147:9`! 0x8CD5
148 #define GL_COLOR_ATTACHMENT0_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:148:9`! 0x8CE0
149 #define GL_DEPTH_ATTACHMENT_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:149:9`! 0x8D00
150 #define GL_STENCIL_ATTACHMENT_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:150:9`! 0x8D20
151 #define GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`! 0x8D40
152 #define GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`! 0x8D41
153 static GLuint GOpenGLFBOcxx . . $ GOpenGLFBO. = 0;
154 static GLuint GOpenGLRBOColorcxx . . $ GOpenGLRBOColor. = 0;
155 static GLuint GOpenGLRBODepthcxx . . $ GOpenGLRBODepth. = 0;
156 static GLuint GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth. = 0;
157 static GLuint GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight. = 0;
158
159
160 #if 0
161 int checkForGLErrors( const char *file, int line )
162 {
163 /*
164 int errors = 0 ;
165 int counter = 0 ;
166 static int errcnt = 0;
167 if(!dglGetError)
168 return 0;
169 while ( counter < 1000 )
170 {
171 GLenum x = dglGetError() ;
172
173 if ( x == GL_NO_ERROR )
174 return errors ;
175
176 printf( "%s:%d OpenGL error: %s [%08x]\n", file,line, gluErrorString ( x ), errcnt++ ) ;
177 errors++ ;
178 counter++ ;
179 }
180 */
181 const char *sdlp = SDL_GetError();
182 if(sdlp && *sdlp)
183 mprintf(0,"SDL: %s",sdlp);
184 return 1;
185 }
186 #endif
187
188 // Sets up multi-texturing using ARB extensions
189 void opengl_GetDLLFunctionscxx . . $ opengl_GetDLLFunctions(49f6e7a06ebc5aa8).(void) {
190 #if defined(WIN32)
191 oglActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)dwglGetProcAddress("glActiveTextureARB");
192 if (!oglActiveTextureARB)
193 goto dll_error;
194
195 oglClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)dwglGetProcAddress("glClientActiveTextureARB");
196 if (!oglClientActiveTextureARB)
197 goto dll_error;
198
199 oglMultiTexCoord4f = (PFNGLMULTITEXCOORD4FARBPROC)dwglGetProcAddress("glMultiTexCoord4f");
200 if (!oglMultiTexCoord4f)
201 goto dll_error;
202 #else
203 #define mod_GetSymbolcxx . . $ `renderer/HardwareOpenGL.cpp:203:9`!(x, funcStr, y) __SDL_mod_GetSymbol(funcStr)
204
205 oglActiveTextureARBcxx . . $ oglActiveTextureARB. = (PFNGLACTIVETEXTUREARBPROC)mod_GetSymbolcxx . . $ `renderer/HardwareOpenGL.cpp:203:9`!(OpenGLDLLHandle, "glActiveTextureARB", 255);
206 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB. =
207 (PFNGLCLIENTACTIVETEXTUREARBPROC)mod_GetSymbolcxx . . $ `renderer/HardwareOpenGL.cpp:203:9`!(OpenGLDLLHandle, "glClientActiveTextureARB", 255);
208 oglMultiTexCoord4fcxx . . $ oglMultiTexCoord4f. = (PFNGLMULTITEXCOORD4FARBPROC)mod_GetSymbolcxx . . $ `renderer/HardwareOpenGL.cpp:203:9`!(OpenGLDLLHandle, "glMultiTexCoord4f", 255);
209 if (!oglMultiTexCoord4fcxx . . $ oglMultiTexCoord4f.) {
210 oglMultiTexCoord4fcxx . . $ oglMultiTexCoord4f. = (PFNGLMULTITEXCOORD4FARBPROC)mod_GetSymbolcxx . . $ `renderer/HardwareOpenGL.cpp:203:9`!(OpenGLDLLHandle, "glMultiTexCoord4fARB", 255);
211 }
212 if (oglActiveTextureARBcxx . . $ oglActiveTextureARB. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || oglMultiTexCoord4fcxx . . $ oglMultiTexCoord4f. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
213 goto dll_error;
214 }
215
216 #undef mod_GetSymbolcxx . . $ `renderer/HardwareOpenGL.cpp:203:9`!
217 #endif
218
219 UseMultitexturecxx . . $ UseMultitexture. = true;
220 return;
221
222 dll_error:
223 oglActiveTextureARBcxx . . $ oglActiveTextureARB. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
224 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
225 oglMultiTexCoord4fcxx . . $ oglMultiTexCoord4f. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
226 UseMultitexturecxx . . $ UseMultitexture. = false;
227 }
228
229 // returns true if the passed in extension name is supported
230 bool opengl_CheckExtensioncxx . . $ opengl_CheckExtension(c5f7da30cbc0f4e9).(const char *extName) {
231 const char *p = (const char *)dglGetStringcxx . . $ dglGetString.(GL_EXTENSIONScxx . . $ `<external>/12235287750774029552/SDL_opengl.h:710:9`!);
232 int extNameLen = strlen(extName);
233 const char *end = p + strlen(p);
234
235 while (p < end) {
236 int n = strcspn(p, " ");
237 if ((extNameLen == n) && (strncmp(extName, p, n) == 0))
238 return true;
239
240 p += (n + 1);
241 }
242
243 return false;
244 }
245
246 // Gets some specific information about this particular flavor of opengl
247 void opengl_GetInformationcxx . . $ opengl_GetInformation(49f6e7a06ebc5aa8).() {
248 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL Vendor: %s\n", dglGetString(GL_VENDOR));
249 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL Renderer: %s\n", dglGetString(GL_RENDERER));
250 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL Version: %s\n", dglGetString(GL_VERSION));
251 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL Extensions: %s\n", dglGetString(GL_EXTENSIONS));
252 }
253
254 int opengl_MakeTextureObjectcxx . . $ opengl_MakeTextureObject(7864480464b09eea).(int tn) {
255 int num = Cur_texture_object_numcxx . . $ Cur_texture_object_num.;
256
257 Cur_texture_object_numcxx . . $ Cur_texture_object_num.++;
258
259 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != tn) {
260 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
261 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + tn);
262 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = tn;
263 #endif
264 }
265
266 dglBindTexturecxx . . $ dglBindTexture.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, num);
267 dglPixelStoreicxx . . $ dglPixelStorei.(GL_UNPACK_ALIGNMENTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:652:9`!, 2);
268
269 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Scxx . . $ `<external>/12235287750774029552/SDL_opengl.h:666:9`!, GL_REPEATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:699:9`!);
270 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Tcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:667:9`!, GL_REPEATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:699:9`!);
271
272 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MAG_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:668:9`!, GL_NEARESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:698:9`!);
273 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MIN_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:669:9`!, GL_NEARESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:698:9`!);
274
275 // glTexEnvf (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
276
277 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(2)
278
279 return num;
280 }
281
282 int opengl_InitCachecxx . . $ opengl_InitCache(b126dc7c1de90089).(void) {
283
284 OpenGL_bitmap_remapcxx . . $ OpenGL_bitmap_remap. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(MAX_BITMAPScxx . . $ `lib/bitmap.h:30:9`! * 2);
285 ASSERTcxx . . $ `misc/pserror.h:246:9`!(OpenGL_bitmap_remap);
286 OpenGL_lightmap_remapcxx . . $ OpenGL_lightmap_remap. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(MAX_LIGHTMAPScxx . . $ `lib/lightmap.h:24:9`! * 2);
287 ASSERTcxx . . $ `misc/pserror.h:246:9`!(OpenGL_lightmap_remap);
288
289 OpenGL_bitmap_statescxx . . $ OpenGL_bitmap_states. = (uint8_tcxx . . $ uint8_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(MAX_BITMAPScxx . . $ `lib/bitmap.h:30:9`!);
290 ASSERTcxx . . $ `misc/pserror.h:246:9`!(OpenGL_bitmap_states);
291 OpenGL_lightmap_statescxx . . $ OpenGL_lightmap_states. = (uint8_tcxx . . $ uint8_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(MAX_LIGHTMAPScxx . . $ `lib/lightmap.h:24:9`!);
292 ASSERTcxx . . $ `misc/pserror.h:246:9`!(OpenGL_lightmap_states);
293
294 Cur_texture_object_numcxx . . $ Cur_texture_object_num. = 1;
295
296 // Setup textures and cacheing
297 int i;
298 for (i = 0; i < MAX_BITMAPScxx . . $ `lib/bitmap.h:30:9`!; i++) {
299 OpenGL_bitmap_remapcxx . . $ OpenGL_bitmap_remap.[i] = 65535;
300 OpenGL_bitmap_statescxx . . $ OpenGL_bitmap_states.[i] = 255;
301 GameBitmapscxx . . $ GameBitmaps.[i].flagscxx . . $ bms_bitmap#flags. |= BF_CHANGEDcxx . . $ `lib/bitmap.h:46:9`! | BF_BRAND_NEWcxx . . $ `lib/bitmap.h:51:9`!;
302 }
303
304 for (i = 0; i < MAX_LIGHTMAPScxx . . $ `lib/lightmap.h:24:9`!; i++) {
305 OpenGL_lightmap_remapcxx . . $ OpenGL_lightmap_remap.[i] = 65535;
306 OpenGL_lightmap_statescxx . . $ OpenGL_lightmap_states.[i] = 255;
307 GameLightmapscxx . . $ GameLightmaps.[i].flagscxx . . $ bms_lightmap#flags. |= LF_CHANGEDcxx . . $ `lib/lightmap.h:28:9`! | LF_BRAND_NEWcxx . . $ `lib/lightmap.h:31:9`!;
308 }
309
310 dglTexEnvfcxx . . $ dglTexEnvf.(GL_TEXTURE_ENVcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:662:9`!, GL_TEXTURE_ENV_MODEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:663:9`!, GL_MODULATEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:697:9`!);
311
312 if (UseMultitexturecxx . . $ UseMultitexture.) {
313 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
314 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 1);
315 dglTexEnvfcxx . . $ dglTexEnvf.(GL_TEXTURE_ENVcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:662:9`!, GL_TEXTURE_ENV_MODEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:663:9`!, GL_MODULATEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:697:9`!);
316 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
317 #endif
318 }
319
320 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(3)
321
322 OpenGL_cache_inittedcxx . . $ OpenGL_cache_initted. = 1;
323 return 1;
324 }
325
326 // Sets default states for our renderer
327 void opengl_SetDefaultscxx . . $ opengl_SetDefaults(49f6e7a06ebc5aa8).() {
328 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Setting states\n");
329
330 gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color. = 0x00FFFFFF;
331 gpu_statecxx . . $ gpu_state..cur_bilinear_statecxx . . $ rendering_state#cur_bilinear_state. = -1;
332 gpu_statecxx . . $ gpu_state..cur_zbuffer_statecxx . . $ rendering_state#cur_zbuffer_state. = -1;
333 gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. = -1;
334 gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. = LS_GOURAUDcxx . . $ LS_GOURAUD.;
335 gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. = CM_MONOcxx . . $ CM_MONO.;
336 gpu_statecxx . . $ gpu_state..cur_bilinear_statecxx . . $ rendering_state#cur_bilinear_state. = -1;
337 gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type. = AT_TEXTUREcxx . . $ `lib/renderer.h:401:9`!;
338
339 // Enable some states
340 dglAlphaFunccxx . . $ dglAlphaFunc.(GL_GREATERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:317:9`!, 0);
341 dglEnablecxx . . $ dglEnable.(GL_ALPHA_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:386:9`!);
342 dglEnablecxx . . $ dglEnable.(GL_BLENDcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:391:9`!);
343 dglEnablecxx . . $ dglEnable.(GL_DITHERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:521:9`!);
344 opengl_Blending_oncxx . . $ opengl_Blending_on. = true;
345
346 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!);
347 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
348 rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(1);
349 rend_SetLightingStatecxx . . $ rend_SetLightingState(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
350 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.);
351 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.);
352 rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1);
353 rend_SetZValuescxx . . $ rend_SetZValues(5102ef758adc0ae7).(0, 3000);
354 rend_SetGammaValuecxx . . $ rend_SetGammaValue(9364e6e7bff7660).(gpu_preferred_statecxx . . $ gpu_preferred_state..gammacxx . . $ renderer_preferred_state#gamma.);
355 OpenGL_last_boundcxx . . $ OpenGL_last_bound.[0] = 9999999;
356 OpenGL_last_boundcxx . . $ OpenGL_last_bound.[1] = 9999999;
357 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = -1;
358 OpenGL_multitexture_statecxx . . $ OpenGL_multitexture_state. = false;
359
360 dglEnableClientStatecxx . . $ dglEnableClientState.(GL_VERTEX_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:222:9`!);
361 dglEnableClientStatecxx . . $ dglEnableClientState.(GL_COLOR_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:224:9`!);
362 dglEnableClientStatecxx . . $ dglEnableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
363
364 dglHintcxx . . $ dglHint.(GL_PERSPECTIVE_CORRECTION_HINTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:598:9`!, GL_NICESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:605:9`!);
365 dglHintcxx . . $ dglHint.(GL_FOG_HINTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:602:9`!, GL_NICESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:605:9`!);
366 dglEnablecxx . . $ dglEnable.(GL_SCISSOR_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:609:9`!);
367 dglScissorcxx . . $ dglScissor.(0, 0, gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width., gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height.);
368 dglDisablecxx . . $ dglDisable.(GL_SCISSOR_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:609:9`!);
369 dglDepthRangecxx . . $ dglDepthRange.(0.0f, 1.0f);
370
371 if (UseMultitexturecxx . . $ UseMultitexture.) {
372 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
373 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 1);
374 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 1);
375 dglEnableClientStatecxx . . $ dglEnableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
376 dglHintcxx . . $ dglHint.(GL_PERSPECTIVE_CORRECTION_HINTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:598:9`!, GL_NICESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:605:9`!);
377 dglHintcxx . . $ dglHint.(GL_FOG_HINTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:602:9`!, GL_NICESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:605:9`!);
378
379 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
380
381 dglDisablecxx . . $ dglDisable.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!);
382 dglAlphaFunccxx . . $ dglAlphaFunc.(GL_GREATERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:317:9`!, 0);
383 dglEnablecxx . . $ dglEnable.(GL_ALPHA_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:386:9`!);
384 dglEnablecxx . . $ dglEnable.(GL_BLENDcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:391:9`!);
385 dglEnablecxx . . $ dglEnable.(GL_DITHERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:521:9`!);
386 dglBlendFunccxx . . $ dglBlendFunc.(GL_DST_COLORcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:402:9`!, GL_ZEROcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:394:9`!);
387 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
388 #endif
389 }
390 }
391
392 extern bool linux_permit_gammacxx . . $ linux_permit_gamma.;
393 extern renderer_preferred_statecxx . . $ renderer_preferred_state# Render_preferred_statecxx . . $ Render_preferred_state.;
394 extern bool ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed.;
395 int SDLCALLcxx . . $ `/usr/include/SDL2/begin_code.h:87:9`! d3SDLEventFiltercxx . . $ d3SDLEventFilter(c0128bf54fa871fa).(void *userdata, SDL_Event *event);
396
397 int opengl_Setupcxx . . $ opengl_Setup(a194bd61aa2f3456).(oeApplicationcxx . . $ oeApplication# *app, int *width, int *height) {
398 int winw = Video_res_listcxx . . $ Video_res_list.[Game_video_resolutioncxx . . $ Game_video_resolution.].widthcxx . . $ tVideoResolution#width.;
399 int winh = Video_res_listcxx . . $ Video_res_list.[Game_video_resolutioncxx . . $ Game_video_resolution.].heightcxx . . $ tVideoResolution#height.;
400
401 // rcg09182000 don't need to quitsubsystem anymore...
402 // SDL_QuitSubSystem(SDL_INIT_VIDEO); // here goes nothing...
403 // Already_loaded = false;
404 SDL_ClearError();
405 if (!SDL_WasInit(SDL_INIT_VIDEOcxx . . $ `<external>/13597568925221565411/SDL.h:85:9`!)) {
406 const int rc = SDL_Init(SDL_INIT_VIDEOcxx . . $ `<external>/13597568925221565411/SDL.h:85:9`!);
407 if (rc != 0) {
408 char buffer[512];
409 snprintf(buffer, sizeof(buffer), "SDL_GetError() reports \"%s\".\n", SDL_GetError());
410 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SDL: SDL_Init() failed! rc == (%d).\n", rc);
411 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s", buffer);
412 rend_SetErrorMessagecxx . . $ rend_SetErrorMessage(85c52e162fed56f9).(buffer);
413 return (0);
414 }
415 }
416
417 SDL_SetEventFilter(d3SDLEventFiltercxx . . $ d3SDLEventFilter(c0128bf54fa871fa)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
418
419 bool fullscreen = true;
420
421 if (FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-fullscreen", 'f')) {
422 fullscreen = true;
423 } else if (FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-windowed", 'w')) {
424 fullscreen = false;
425 }
426
427 if (!Already_loadedcxx . . $ Already_loaded.) {
428 #define MAX_ARGScxx . . $ `renderer/HardwareOpenGL.cpp:428:9`! 30
429 #define MAX_CHARS_PER_ARGcxx . . $ `renderer/HardwareOpenGL.cpp:429:9`! 100
430 extern char GameArgscxx . . $ GameArgs.[MAX_ARGScxx . . $ `renderer/HardwareOpenGL.cpp:428:9`!][MAX_CHARS_PER_ARGcxx . . $ `renderer/HardwareOpenGL.cpp:429:9`!];
431
432 char gl_library[256];
433 int arg;
434 arg = FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-gllibrary", 'g');
435 if (arg != 0) {
436 strcpy(gl_library, GameArgscxx . . $ GameArgs.[arg + 1]);
437 } else {
438 gl_library[0] = 0;
439 }
440
441 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: Attempting to use \"%s\" for OpenGL\n", gl_library[0] ? gl_library : "[system default library]");
442
443 // ryan's adds. 04/18/2000...SDL stuff on 04/25/2000
444 bool success = true;
445
446 OpenGLDLLHandlecxx . . $ OpenGLDLLHandle. = LoadOpenGLDLLcxx . . $ LoadOpenGLDLL(86c04df0e374c4ee).(gl_library);
447 if (!(OpenGLDLLHandlecxx . . $ OpenGLDLLHandle.)) {
448 // rcg07072000 last ditch effort...
449 #if defined(POSIXcxx . . $ `<built-in>:478:9`!)
450 strcpy(gl_library, "libGL.so.1");
451 #else
452 strcpy(gl_library, "opengl32.dll");
453 #endif
454 OpenGLDLLHandlecxx . . $ OpenGLDLLHandle. = LoadOpenGLDLLcxx . . $ LoadOpenGLDLL(86c04df0e374c4ee).(gl_library);
455 if (!(OpenGLDLLHandlecxx . . $ OpenGLDLLHandle.)) {
456 success = false;
457 }
458 } // if
459
460 if (!success) {
461 char buffer[512];
462 snprintf(buffer, sizeof(buffer), "Failed to load library [%s].\n", gl_library);
463 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s", buffer);
464 rend_SetErrorMessagecxx . . $ rend_SetErrorMessage(85c52e162fed56f9).(buffer);
465 return 0;
466 } // if
467 }
468
469 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8 );
470 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
471 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
472 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
473 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
474 Uint32cxx . . $ Uint32# flags = SDL_WINDOW_OPENGL;
475
476 if (fullscreen) {
477 flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
478 }
479
480 if (!GSDLWindowcxx . . $ GSDLWindow.) {
481 GSDLWindowcxx . . $ GSDLWindow. = SDL_CreateWindow("Descent 3", SDL_WINDOWPOS_UNDEFINEDcxx . . $ `<external>/14887343297790812595/SDL_video.h:138:9`!, SDL_WINDOWPOS_UNDEFINEDcxx . . $ `<external>/14887343297790812595/SDL_video.h:138:9`!, winw, winh, flags);
482 if (!GSDLWindowcxx . . $ GSDLWindow.) {
483 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: SDL window creation failed: %s", SDL_GetError());
484 return 0;
485 }
486 } else {
487 SDL_SetWindowSize(GSDLWindowcxx . . $ GSDLWindow., winw, winh);
488 SDL_SetWindowFullscreen(GSDLWindowcxx . . $ GSDLWindow., flags);
489 }
490
491 if (!GSDLGLContextcxx . . $ GSDLGLContext.) {
492 GSDLGLContextcxx . . $ GSDLGLContext. = SDL_GL_CreateContext(GSDLWindowcxx . . $ GSDLWindow.);
493 if (!GSDLGLContextcxx . . $ GSDLGLContext.) {
494 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: OpenGL context creation failed: %s", SDL_GetError());
495 SDL_DestroyWindow(GSDLWindowcxx . . $ GSDLWindow.);
496 GSDLWindowcxx . . $ GSDLWindow. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
497 return 0;
498 }
499 }
500
501 // clear the window framebuffer to start.
502 dglClearColorcxx . . $ dglClearColor.(0.0f, 0.0f, 0.0f, 1.0f);
503 dglClearcxx . . $ dglClear.(GL_COLOR_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:736:9`!|GL_DEPTH_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:730:9`!);
504 SDL_GL_SwapWindow(GSDLWindowcxx . . $ GSDLWindow.);
505
506 bool fbo_available = true;
507 if (!SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object")) {
508 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: GL_EXT_framebuffer_object extension is not available");
509 fbo_available = false;
510 }
511
512 if (!SDL_GL_ExtensionSupported("GL_EXT_framebuffer_blit")) {
513 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: GL_EXT_framebuffer_blit extension is not available");
514 fbo_available = false;
515 }
516
517 if (fbo_available) {
518 #define LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(x) \
519 dgl##x = (gl##x##_fp) SDL_GL_GetProcAddress("gl" #x); \
520 if (dgl##x == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { \
521 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: gl%s function not found!", #x); \
522 fbo_available = false; \
523 }
524 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(GenFramebuffersEXT);
525 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(GenRenderbuffersEXT);
526 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(BindFramebufferEXT);
527 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(BindRenderbufferEXT);
528 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(RenderbufferStorageEXT);
529 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(FramebufferRenderbufferEXT);
530 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(CheckFramebufferStatusEXT);
531 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(DeleteFramebuffersEXT);
532 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(DeleteRenderbuffersEXT);
533 LOOKUP_GL_SYMcxx . . $ `renderer/HardwareOpenGL.cpp:518:13`!(BlitFramebufferEXT);
534 }
535
536 if (!fbo_available) {
537 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: We need missing Framebuffer Object support, giving up");
538 SDL_GL_DeleteContext(GSDLGLContextcxx . . $ GSDLGLContext.);
539 SDL_DestroyWindow(GSDLWindowcxx . . $ GSDLWindow.);
540 GSDLGLContextcxx . . $ GSDLGLContext. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
541 GSDLWindowcxx . . $ GSDLWindow. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
542 return 0;
543 }
544
545 /* Tear down the backbuffer and rebuild at new dimensions... */
546 if (GOpenGLFBOcxx . . $ GOpenGLFBO.) {
547 dglBindFramebufferEXTcxx . . $ dglBindFramebufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GOpenGLFBOcxx . . $ GOpenGLFBO.);
548 dglFramebufferRenderbufferEXTcxx . . $ dglFramebufferRenderbufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GL_COLOR_ATTACHMENT0_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:148:9`!, GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, 0);
549 dglFramebufferRenderbufferEXTcxx . . $ dglFramebufferRenderbufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GL_DEPTH_ATTACHMENT_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:149:9`!, GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, 0);
550 dglBindRenderbufferEXTcxx . . $ dglBindRenderbufferEXT.(GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, 0);
551 dglBindFramebufferEXTcxx . . $ dglBindFramebufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, 0);
552 dglDeleteFramebuffersEXTcxx . . $ dglDeleteFramebuffersEXT.(1, &GOpenGLFBOcxx . . $ GOpenGLFBO.);
553 dglDeleteRenderbuffersEXTcxx . . $ dglDeleteRenderbuffersEXT.(1, &GOpenGLRBOColorcxx . . $ GOpenGLRBOColor.);
554 dglDeleteRenderbuffersEXTcxx . . $ dglDeleteRenderbuffersEXT.(1, &GOpenGLRBODepthcxx . . $ GOpenGLRBODepth.);
555 GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth. = GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight. = GOpenGLFBOcxx . . $ GOpenGLFBO. = GOpenGLRBOColorcxx . . $ GOpenGLRBOColor. = GOpenGLRBODepthcxx . . $ GOpenGLRBODepth. = 0;
556 }
557
558 const GLsizei w = (GLsizei) *width;
559 const GLsizei h = (GLsizei) *height;
560
561 GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth. = w;
562 GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight. = h;
563
564 dglGenFramebuffersEXTcxx . . $ dglGenFramebuffersEXT.(1, &GOpenGLFBOcxx . . $ GOpenGLFBO.);
565 dglBindFramebufferEXTcxx . . $ dglBindFramebufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GOpenGLFBOcxx . . $ GOpenGLFBO.);
566
567 dglGenRenderbuffersEXTcxx . . $ dglGenRenderbuffersEXT.(1, &GOpenGLRBOColorcxx . . $ GOpenGLRBOColor.);
568 dglBindRenderbufferEXTcxx . . $ dglBindRenderbufferEXT.(GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, GOpenGLRBOColorcxx . . $ GOpenGLRBOColor.);
569 dglRenderbufferStorageEXTcxx . . $ dglRenderbufferStorageEXT.(GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, GL_RGBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:522:9`!, w, h);
570 dglFramebufferRenderbufferEXTcxx . . $ dglFramebufferRenderbufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GL_COLOR_ATTACHMENT0_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:148:9`!, GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, GOpenGLRBOColorcxx . . $ GOpenGLRBOColor.);
571
572 dglGenRenderbuffersEXTcxx . . $ dglGenRenderbuffersEXT.(1, &GOpenGLRBODepthcxx . . $ GOpenGLRBODepth.);
573 dglBindRenderbufferEXTcxx . . $ dglBindRenderbufferEXT.(GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, GOpenGLRBODepthcxx . . $ GOpenGLRBODepth.);
574 dglRenderbufferStorageEXTcxx . . $ dglRenderbufferStorageEXT.(GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, GL_DEPTH_COMPONENT16_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:144:9`!, w, h);
575 dglFramebufferRenderbufferEXTcxx . . $ dglFramebufferRenderbufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GL_DEPTH_ATTACHMENT_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:149:9`!, GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, GOpenGLRBODepthcxx . . $ GOpenGLRBODepth.);
576
577 if (dglCheckFramebufferStatusEXTcxx . . $ dglCheckFramebufferStatusEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!) != GL_FRAMEBUFFER_COMPLETE_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:147:9`!) {
578 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL: our framebuffer object is incomplete, giving up");
579 dglFramebufferRenderbufferEXTcxx . . $ dglFramebufferRenderbufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GL_COLOR_ATTACHMENT0_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:148:9`!, GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, 0);
580 dglFramebufferRenderbufferEXTcxx . . $ dglFramebufferRenderbufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GL_DEPTH_ATTACHMENT_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:149:9`!, GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, 0);
581 dglBindRenderbufferEXTcxx . . $ dglBindRenderbufferEXT.(GL_RENDERBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:152:9`!, 0);
582 dglBindFramebufferEXTcxx . . $ dglBindFramebufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, 0);
583 dglDeleteFramebuffersEXTcxx . . $ dglDeleteFramebuffersEXT.(1, &GOpenGLFBOcxx . . $ GOpenGLFBO.);
584 dglDeleteRenderbuffersEXTcxx . . $ dglDeleteRenderbuffersEXT.(1, &GOpenGLRBOColorcxx . . $ GOpenGLRBOColor.);
585 dglDeleteRenderbuffersEXTcxx . . $ dglDeleteRenderbuffersEXT.(1, &GOpenGLRBODepthcxx . . $ GOpenGLRBODepth.);
586 GOpenGLFBOcxx . . $ GOpenGLFBO. = GOpenGLRBOColorcxx . . $ GOpenGLRBOColor. = GOpenGLRBODepthcxx . . $ GOpenGLRBODepth. = 0;
587 SDL_GL_DeleteContext(GSDLGLContextcxx . . $ GSDLGLContext.);
588 SDL_DestroyWindow(GSDLWindowcxx . . $ GSDLWindow.);
589 GSDLGLContextcxx . . $ GSDLGLContext. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
590 GSDLWindowcxx . . $ GSDLWindow. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
591 return 0;
592 }
593
594 if (!FindArgcxx . . $ FindArg(5c4306d8553b3696).("-nomousegrab")) {
595 ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed. = true;
596 }
597
598 SDL_SetRelativeMouseMode(ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed. ? SDL_TRUEcxx . . $ SDL_TRUE. : SDL_FALSEcxx . . $ SDL_FALSE.);
599
600 // rcg09182000 gamma fun.
601 // rcg01112000 --nogamma fun.
602 if (FindArgCharcxx . . $ FindArgChar(7c0a79fa02e3e627).("-nogamma", 'M')) {
603 linux_permit_gammacxx . . $ linux_permit_gamma. = false;
604 } else {
605 Uint16cxx . . $ Uint16# ramp[256];
606 SDL_CalculateGammaRamp(Render_preferred_statecxx . . $ Render_preferred_state..gammacxx . . $ renderer_preferred_state#gamma., ramp);
607 linux_permit_gammacxx . . $ linux_permit_gamma. = (SDL_SetWindowGammaRamp(GSDLWindowcxx . . $ GSDLWindow., ramp, ramp, ramp) == 0);
608 } // else
609
610 if (ParentApplicationcxx . . $ ParentApplication.) {
611 reinterpret_cast<oeLnxApplicationcxx . . $ oeLnxApplication# *>(ParentApplicationcxx . . $ ParentApplication.)->set_sizeposcxx . . $ oeLnxApplication#set_sizepos(748afa4755bc9595).(0, 0, *width, *height);
612 }
613
614 Already_loadedcxx . . $ Already_loaded. = 1;
615 return 1;
616 }
617
618 // Sets up our OpenGL rendering context
619 // Returns 1 if ok, 0 if something bad
620 int opengl_Initcxx . . $ opengl_Init(5803d2fe7a27ef5).(oeApplicationcxx . . $ oeApplication# *app, renderer_preferred_statecxx . . $ renderer_preferred_state# *pref_state) {
621 int width, height;
622 int retval = 1;
623 int i;
624
625 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Setting up opengl mode!\n");
626
627 if (pref_state) {
628 gpu_preferred_statecxx . . $ gpu_preferred_state. =cxx . . $ renderer_preferred_state#`operator=`(50e6b83d03d7b456). *pref_state;
629 }
630
631 if (app != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
632 ParentApplicationcxx . . $ ParentApplication. = app;
633 }
634
635 int windowX = 0, windowY = 0;
636
637 /***********************************************************
638 * LINUX OPENGL
639 ***********************************************************
640 */
641 // Setup gpu_state.screen_width & gpu_state.screen_height & width & height
642 width = gpu_preferred_statecxx . . $ gpu_preferred_state..widthcxx . . $ renderer_preferred_state#width.;
643 height = gpu_preferred_statecxx . . $ gpu_preferred_state..heightcxx . . $ renderer_preferred_state#height.;
644
645 if (!opengl_Setupcxx . . $ opengl_Setup(a194bd61aa2f3456).(app, &width, &height)) {
646 opengl_Closecxx . . $ opengl_Close(b45ddcbc8423892c).();
647 return 0;
648 }
649
650 memset(&gpu_statecxx . . $ gpu_state., 0, sizeof(rendering_statecxx . . $ rendering_state#));
651 gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width. = width;
652 gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height. = height;
653
654 // Get some info
655 opengl_GetInformationcxx . . $ opengl_GetInformation(49f6e7a06ebc5aa8).();
656
657 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Setting up multitexture...\n");
658
659 // Determine if Multitexture is supported
660 bool supportsMultiTexture = opengl_CheckExtensioncxx . . $ opengl_CheckExtension(c5f7da30cbc0f4e9).("GL_ARB_multitexture");
661 if (!supportsMultiTexture) {
662 supportsMultiTexture = opengl_CheckExtensioncxx . . $ opengl_CheckExtension(c5f7da30cbc0f4e9).("GL_SGIS_multitexture");
663 }
664
665 if (FindArgcxx . . $ FindArg(5c4306d8553b3696).("-NoMultitexture")) {
666 supportsMultiTexture = false;
667 }
668
669 if (supportsMultiTexture) {
670 // attempt to grab Multitexture functions
671 opengl_GetDLLFunctionscxx . . $ opengl_GetDLLFunctions(49f6e7a06ebc5aa8).();
672 } else {
673 // No multitexture at all
674 UseMultitexturecxx . . $ UseMultitexture. = false;
675 }
676
677 // Do we have packed pixel formats?
678 OpenGL_packed_pixelscxx . . $ OpenGL_packed_pixels. = opengl_CheckExtensioncxx . . $ opengl_CheckExtension(c5f7da30cbc0f4e9).("GL_EXT_packed_pixels");
679
680 opengl_InitCachecxx . . $ opengl_InitCache(b126dc7c1de90089).();
681
682 if (UseMultitexturecxx . . $ UseMultitexture.) {
683 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Using multitexture.");
684 } else {
685 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Not using multitexture.");
686 }
687
688 if (OpenGL_packed_pixelscxx . . $ OpenGL_packed_pixels.) {
689 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(2048 * 2048 * 2);
690 opengl_packed_Translate_tablecxx . . $ opengl_packed_Translate_table. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(65536 * 2);
691 opengl_packed_4444_translate_tablecxx . . $ opengl_packed_4444_translate_table. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(65536 * 2);
692
693 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_packed_Upload_data);
694 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_packed_Translate_table);
695 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_packed_4444_translate_table);
696
697 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Building packed OpenGL translate table...\n");
698
699 for (i = 0; i < 65536; i++) {
700 int r = (i >> 10) & 0x1f;
701 int g = (i >> 5) & 0x1f;
702 int b = i & 0x1f;
703
704 #ifdef BRIGHTNESS_HACK
705 r *= BRIGHTNESS_HACK;
706 g *= BRIGHTNESS_HACK;
707 b *= BRIGHTNESS_HACK;
708 if (r > 0x1F)
709 r = 0x1F;
710 if (g > 0x1F)
711 g = 0x1F;
712 if (b > 0x1F)
713 b = 0x1F;
714 #endif
715
716 uint16_tcxx . . $ uint16_t# pix;
717
718 if (!(i & OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`!)) {
719 pix = 0;
720 } else {
721 pix = (r << 11) | (g << 6) | (b << 1) | 1;
722 }
723
724 opengl_packed_Translate_tablecxx . . $ opengl_packed_Translate_table.[i] = INTEL_INTcxx . . $ `lib/byteswap.h:107:9`!(pix);
725
726 // 4444 table
727 int a = (i >> 12) & 0xf;
728 r = (i >> 8) & 0xf;
729 g = (i >> 4) & 0xf;
730 b = i & 0xf;
731
732 pix = (r << 12) | (g << 8) | (b << 4) | a;
733 opengl_packed_4444_translate_tablecxx . . $ opengl_packed_4444_translate_table.[i] = INTEL_INTcxx . . $ `lib/byteswap.h:107:9`!(pix);
734 }
735 } else {
736 opengl_Upload_datacxx . . $ opengl_Upload_data. = (uint32_tcxx . . $ uint32_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(2048 * 2048 * 4);
737 opengl_Translate_tablecxx . . $ opengl_Translate_table. = (uint32_tcxx . . $ uint32_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(65536 * 4);
738 opengl_4444_translate_tablecxx . . $ opengl_4444_translate_table. = (uint32_tcxx . . $ uint32_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(65536 * 4);
739
740 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_Upload_data);
741 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_Translate_table);
742 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_4444_translate_table);
743
744 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Building OpenGL translate table...\n");
745
746 for (i = 0; i < 65536; i++) {
747 uint32_tcxx . . $ uint32_t# pix;
748 int r = (i >> 10) & 0x1f;
749 int g = (i >> 5) & 0x1f;
750 int b = i & 0x1f;
751
752 #ifdef BRIGHTNESS_HACK
753 r *= BRIGHTNESS_HACK;
754 g *= BRIGHTNESS_HACK;
755 b *= BRIGHTNESS_HACK;
756 if (r > 0x1F)
757 r = 0x1F;
758 if (g > 0x1F)
759 g = 0x1F;
760 if (b > 0x1F)
761 b = 0x1F;
762 #endif
763
764 float fr = (float)r / 31.0f;
765 float fg = (float)g / 31.0f;
766 float fb = (float)b / 31.0f;
767
768 r = 255 * fr;
769 g = 255 * fg;
770 b = 255 * fb;
771
772 if (!(i & OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`!)) {
773 pix = 0;
774 } else {
775 pix = (255 << 24) | (b << 16) | (g << 8) | (r);
776 }
777
778 opengl_Translate_tablecxx . . $ opengl_Translate_table.[i] = INTEL_INTcxx . . $ `lib/byteswap.h:107:9`!(pix);
779
780 // Do 4444
781 int a = (i >> 12) & 0xf;
782 r = (i >> 8) & 0xf;
783 g = (i >> 4) & 0xf;
784 b = i & 0xf;
785
786 float fa = (float)a / 15.0f;
787 fr = (float)r / 15.0f;
788 fg = (float)g / 15.0f;
789 fb = (float)b / 15.0f;
790
791 a = 255 * fa;
792 r = 255 * fr;
793 g = 255 * fg;
794 b = 255 * fb;
795
796 pix = (a << 24) | (b << 16) | (g << 8) | (r);
797
798 opengl_4444_translate_tablecxx . . $ opengl_4444_translate_table.[i] = INTEL_INTcxx . . $ `lib/byteswap.h:107:9`!(pix);
799 }
800 }
801
802 opengl_SetDefaultscxx . . $ opengl_SetDefaults(49f6e7a06ebc5aa8).();
803
804 g3_ForceTransformRefreshcxx . . $ g3_ForceTransformRefresh(49f6e7a06ebc5aa8).();
805
806 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(4)
807
808 gpu_statecxx . . $ gpu_state..inittedcxx . . $ rendering_state#initted. = 1;
809
810 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OpenGL initialization at %d x %d was successful.\n", width, height);
811
812 return retval;
813 }
814
815 // Releases the rendering context
816 void opengl_Closecxx . . $ opengl_Close(b45ddcbc8423892c).(const bool just_resizing) {
817 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(5)
818
819 uint32_tcxx . . $ uint32_t# *delete_list = (uint32_tcxx . . $ uint32_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(Cur_texture_object_num * sizeof(int));
820 ASSERTcxx . . $ `misc/pserror.h:246:9`!(delete_list);
821 for (int i = 1; i < Cur_texture_object_numcxx . . $ Cur_texture_object_num.; i++)
822 delete_list[i] = i;
823
824 if (Cur_texture_object_numcxx . . $ Cur_texture_object_num. > 1)
825 dglDeleteTexturescxx . . $ dglDeleteTextures.(Cur_texture_object_numcxx . . $ Cur_texture_object_num., (const uint32_tcxx . . $ uint32_t# *)delete_list);
826
827 mem_freecxx . . $ `mem/mem.h:80:9`!(delete_list);
828
829 if (GSDLGLContextcxx . . $ GSDLGLContext.) {
830 SDL_GL_MakeCurrent(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
831 SDL_GL_DeleteContext(GSDLGLContextcxx . . $ GSDLGLContext.);
832 GSDLGLContextcxx . . $ GSDLGLContext. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
833 GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth. = GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight. = GOpenGLFBOcxx . . $ GOpenGLFBO. = GOpenGLRBOColorcxx . . $ GOpenGLRBOColor. = GOpenGLRBODepthcxx . . $ GOpenGLRBODepth. = 0;
834 }
835
836 if (!just_resizing && GSDLWindowcxx . . $ GSDLWindow.) {
837 SDL_DestroyWindow(GSDLWindowcxx . . $ GSDLWindow.);
838 GSDLWindowcxx . . $ GSDLWindow. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
839 }
840
841
842 if (OpenGL_packed_pixelscxx . . $ OpenGL_packed_pixels.) {
843 if (opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.) {
844 mem_freecxx . . $ `mem/mem.h:80:9`!(opengl_packed_Upload_data);
845 }
846 if (opengl_packed_Translate_tablecxx . . $ opengl_packed_Translate_table.) {
847 mem_freecxx . . $ `mem/mem.h:80:9`!(opengl_packed_Translate_table);
848 }
849 if (opengl_packed_4444_translate_tablecxx . . $ opengl_packed_4444_translate_table.) {
850 mem_freecxx . . $ `mem/mem.h:80:9`!(opengl_packed_4444_translate_table);
851 }
852 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
853 opengl_packed_Translate_tablecxx . . $ opengl_packed_Translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
854 opengl_packed_4444_translate_tablecxx . . $ opengl_packed_4444_translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
855 } else {
856 if (opengl_Upload_datacxx . . $ opengl_Upload_data.)
857 mem_freecxx . . $ `mem/mem.h:80:9`!(opengl_Upload_data);
858 if (opengl_Translate_tablecxx . . $ opengl_Translate_table.)
859 mem_freecxx . . $ `mem/mem.h:80:9`!(opengl_Translate_table);
860 if (opengl_4444_translate_tablecxx . . $ opengl_4444_translate_table.)
861 mem_freecxx . . $ `mem/mem.h:80:9`!(opengl_4444_translate_table);
862 opengl_Upload_datacxx . . $ opengl_Upload_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
863 opengl_Translate_tablecxx . . $ opengl_Translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
864 opengl_4444_translate_tablecxx . . $ opengl_4444_translate_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
865 }
866
867 if (OpenGL_cache_inittedcxx . . $ OpenGL_cache_initted.) {
868 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_lightmap_remap);
869 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_bitmap_remap);
870 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_lightmap_states);
871 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_bitmap_states);
872 OpenGL_cache_inittedcxx . . $ OpenGL_cache_initted. = 0;
873 }
874
875 // mod_FreeModule (OpenGLDLLHandle);
876 gpu_statecxx . . $ gpu_state..inittedcxx . . $ rendering_state#initted. = 0;
877 }
878
879 // Takes our 16bit format and converts it into the memory scheme that OpenGL wants
880 void opengl_TranslateBitmapToOpenGLcxx . . $ opengl_TranslateBitmapToOpenGL(1559a299834bcdd5).(int texnum, int bm_handle, int map_type, int replace, int tn) {
881 uint16_tcxx . . $ uint16_t# *bm_ptr;
882
883 int w, h;
884 int size;
885
886 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != tn) {
887 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
888 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + tn);
889 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = tn;
890 #endif
891 }
892
893 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
894 if (GameLightmapscxx . . $ GameLightmaps.[bm_handle].flagscxx . . $ bms_lightmap#flags. & LF_BRAND_NEWcxx . . $ `lib/lightmap.h:31:9`!)
895 replace = 0;
896
897 bm_ptr = lm_datacxx . . $ lm_data(2fbd6a760478ca0f).(bm_handle);
898 GameLightmapscxx . . $ GameLightmaps.[bm_handle].flagscxx . . $ bms_lightmap#flags. &= ~(LF_CHANGEDcxx . . $ `lib/lightmap.h:28:9`! | LF_BRAND_NEWcxx . . $ `lib/lightmap.h:31:9`!);
899
900 w = lm_wcxx . . $ lm_w(7864480464b09eea).(bm_handle);
901 h = lm_hcxx . . $ lm_h(7864480464b09eea).(bm_handle);
902 size = GameLightmapscxx . . $ GameLightmaps.[bm_handle].square_rescxx . . $ bms_lightmap#square_res.;
903 } else {
904 if (GameBitmapscxx . . $ GameBitmaps.[bm_handle].flagscxx . . $ bms_bitmap#flags. & BF_BRAND_NEWcxx . . $ `lib/bitmap.h:51:9`!)
905 replace = 0;
906
907 bm_ptr = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(bm_handle, 0);
908 GameBitmapscxx . . $ GameBitmaps.[bm_handle].flagscxx . . $ bms_bitmap#flags. &= ~(BF_CHANGEDcxx . . $ `lib/bitmap.h:46:9`! | BF_BRAND_NEWcxx . . $ `lib/bitmap.h:51:9`!);
909 w = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0);
910 h = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0);
911 size = w;
912 }
913
914 if (OpenGL_last_boundcxx . . $ OpenGL_last_bound.[tn] != texnum) {
915 dglBindTexturecxx . . $ dglBindTexture.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, texnum);
916 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[0]++;
917 OpenGL_last_boundcxx . . $ OpenGL_last_bound.[tn] = texnum;
918 }
919
920 int i;
921
922 if (OpenGL_packed_pixelscxx . . $ OpenGL_packed_pixels.) {
923 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
924 uint16_tcxx . . $ uint16_t# *left_data = (uint16_tcxx . . $ uint16_t# *)opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.;
925 int bm_left = 0;
926
927 for (int i = 0; i < h; i++, left_data += size, bm_left += w) {
928 uint16_tcxx . . $ uint16_t# *dest_data = left_data;
929 for (int t = 0; t < w; t++) {
930 *dest_data++ = opengl_packed_Translate_tablecxx . . $ opengl_packed_Translate_table.[bm_ptr[bm_left + t]];
931 }
932 }
933
934 if (replace) {
935 dglTexSubImage2Dcxx . . $ dglTexSubImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, 0, 0, 0, size, size, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_SHORT_5_5_5_1cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1512:9`!,
936 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.);
937 } else {
938 dglTexImage2Dcxx . . $ dglTexImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, 0, GL_RGB5_A1cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:781:9`!, size, size, 0, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_SHORT_5_5_5_1cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1512:9`!,
939 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.);
940 }
941 } else {
942 int limit = 0;
943
944 if (bm_mippedcxx . . $ bm_mipped(7864480464b09eea).(bm_handle)) {
945 limit = NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`! + 3;
946 } else {
947 limit = 1;
948 }
949
950 for (int m = 0; m < limit; m++) {
951 if (m < NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`!) {
952 bm_ptr = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(bm_handle, m);
953 w = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, m);
954 h = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, m);
955 } else {
956 bm_ptr = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(bm_handle, NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`! - 1);
957 w = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`! - 1);
958 h = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`! - 1);
959
960 w >>= m - (NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`! - 1);
961 h >>= m - (NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`! - 1);
962
963 if ((w < 1) || (h < 1))
964 continue;
965 }
966
967 if (bm_formatcxx . . $ bm_format(7864480464b09eea).(bm_handle) == BITMAP_FORMAT_4444cxx . . $ `lib/bitmap.h:57:9`!) {
968 // Do 4444
969 if (bm_mippedcxx . . $ bm_mipped(7864480464b09eea).(bm_handle)) {
970 for (i = 0; i < w * h; i++)
971 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.[i] = 0xf | (opengl_packed_4444_translate_tablecxx . . $ opengl_packed_4444_translate_table.[bm_ptr[i]]);
972 } else {
973 for (i = 0; i < w * h; i++)
974 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.[i] = opengl_packed_4444_translate_tablecxx . . $ opengl_packed_4444_translate_table.[bm_ptr[i]];
975 }
976
977 if (replace) {
978 dglTexSubImage2Dcxx . . $ dglTexSubImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, m, 0, 0, w, h, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_SHORT_4_4_4_4cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1510:9`!,
979 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.);
980 } else {
981 dglTexImage2Dcxx . . $ dglTexImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, m, GL_RGBA4cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:780:9`!, w, h, 0, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_SHORT_4_4_4_4cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1510:9`!,
982 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.);
983 }
984 } else {
985 // Do 1555
986 for (i = 0; i < w * h; i++) {
987 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.[i] = opengl_packed_Translate_tablecxx . . $ opengl_packed_Translate_table.[bm_ptr[i]];
988 }
989
990 if (replace) {
991 dglTexSubImage2Dcxx . . $ dglTexSubImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, m, 0, 0, w, h, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_SHORT_5_5_5_1cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1512:9`!,
992 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.);
993 } else {
994 dglTexImage2Dcxx . . $ dglTexImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, m, GL_RGB5_A1cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:781:9`!, w, h, 0, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_SHORT_5_5_5_1cxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1512:9`!,
995 opengl_packed_Upload_datacxx . . $ opengl_packed_Upload_data.);
996 }
997 }
998 }
999 }
1000 } else {
1001 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
1002 uint32_tcxx . . $ uint32_t# *left_data = (uint32_tcxx . . $ uint32_t# *)opengl_Upload_datacxx . . $ opengl_Upload_data.;
1003 int bm_left = 0;
1004
1005 for (int i = 0; i < h; i++, left_data += size, bm_left += w) {
1006 uint32_tcxx . . $ uint32_t# *dest_data = left_data;
1007 for (int t = 0; t < w; t++) {
1008 *dest_data++ = opengl_Translate_tablecxx . . $ opengl_Translate_table.[bm_ptr[bm_left + t]];
1009 }
1010 }
1011 if (size > 0) {
1012 if (replace) {
1013 dglTexSubImage2Dcxx . . $ dglTexSubImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, 0, 0, 0, size, size, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_BYTEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:198:9`!, opengl_Upload_datacxx . . $ opengl_Upload_data.);
1014 } else {
1015 dglTexImage2Dcxx . . $ dglTexImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, 0, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, size, size, 0, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_BYTEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:198:9`!, opengl_Upload_datacxx . . $ opengl_Upload_data.);
1016 }
1017 }
1018 } else {
1019 int limit = 0;
1020
1021 if (bm_mippedcxx . . $ bm_mipped(7864480464b09eea).(bm_handle)) {
1022 limit = NUM_MIP_LEVELScxx . . $ `lib/bitmap.h:31:9`! + 3; // ryan added +3.
1023 } else {
1024 limit = 1;
1025 }
1026
1027 for (int m = 0; m < limit; m++) {
1028 bm_ptr = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(bm_handle, m);
1029 w = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, m);
1030 h = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, m);
1031
1032 if (bm_formatcxx . . $ bm_format(7864480464b09eea).(bm_handle) == BITMAP_FORMAT_4444cxx . . $ `lib/bitmap.h:57:9`!) {
1033 // Do 4444
1034
1035 if (bm_mippedcxx . . $ bm_mipped(7864480464b09eea).(bm_handle)) {
1036 for (i = 0; i < w * h; i++)
1037 opengl_Upload_datacxx . . $ opengl_Upload_data.[i] = INTEL_INTcxx . . $ `lib/byteswap.h:107:9`!((255 << 24)) | opengl_4444_translate_tablecxx . . $ opengl_4444_translate_table.[bm_ptr[i]];
1038 } else {
1039 for (i = 0; i < w * h; i++)
1040 opengl_Upload_datacxx . . $ opengl_Upload_data.[i] = opengl_4444_translate_tablecxx . . $ opengl_4444_translate_table.[bm_ptr[i]];
1041 }
1042 } else {
1043 // Do 1555
1044
1045 for (i = 0; i < w * h; i++)
1046 opengl_Upload_datacxx . . $ opengl_Upload_data.[i] = opengl_Translate_tablecxx . . $ opengl_Translate_table.[bm_ptr[i]];
1047 }
1048
1049 // rcg06262000 my if wrapper.
1050 if ((w > 0) && (h > 0)) {
1051 if (replace) {
1052 dglTexSubImage2Dcxx . . $ dglTexSubImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, m, 0, 0, w, h, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_BYTEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:198:9`!, opengl_Upload_datacxx . . $ opengl_Upload_data.);
1053 } else {
1054 dglTexImage2Dcxx . . $ dglTexImage2D.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, m, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, w, h, 0, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_BYTEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:198:9`!, opengl_Upload_datacxx . . $ opengl_Upload_data.);
1055 }
1056 }
1057 }
1058 }
1059 }
1060
1061 // mprintf(1,"Doing slow upload to opengl!\n");
1062
1063 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
1064 GameLightmapscxx . . $ GameLightmaps.[bm_handle].flagscxx . . $ bms_lightmap#flags. &= ~LF_LIMITScxx . . $ `lib/lightmap.h:29:9`!;
1065 }
1066
1067 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(6)
1068 OpenGL_uploadscxx . . $ OpenGL_uploads.++;
1069 }
1070
1071 extern bool Force_one_texturecxx . . $ Force_one_texture.;
1072
1073 // Utilizes a LRU cacheing scheme to select/upload textures the opengl driver
1074 int opengl_MakeBitmapCurrentcxx . . $ opengl_MakeBitmapCurrent(2326284602b0bb2d).(int handle, int map_type, int tn) {
1075 int w, h;
1076 int texnum;
1077
1078 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
1079 w = GameLightmapscxx . . $ GameLightmaps.[handle].square_rescxx . . $ bms_lightmap#square_res.;
1080 h = GameLightmapscxx . . $ GameLightmaps.[handle].square_rescxx . . $ bms_lightmap#square_res.;
1081 } else {
1082 if (Force_one_texturecxx . . $ Force_one_texture.) {
1083 handle = 0;
1084 }
1085
1086 w = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(handle, 0);
1087 h = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(handle, 0);
1088 }
1089
1090 if (w != h) {
1091 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Can't use non-square textures with OpenGL!\n");
1092 return 0;
1093 }
1094
1095 // See if the bitmaps is already in the cache
1096 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
1097 if (OpenGL_lightmap_remapcxx . . $ OpenGL_lightmap_remap.[handle] == 65535) {
1098 texnum = opengl_MakeTextureObjectcxx . . $ opengl_MakeTextureObject(7864480464b09eea).(tn);
1099 SET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:84:9`!(OpenGL_lightmap_states[handle], 1);
1100 SET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:89:9`!(OpenGL_lightmap_states[handle], 0);
1101 OpenGL_lightmap_remapcxx . . $ OpenGL_lightmap_remap.[handle] = texnum;
1102 opengl_TranslateBitmapToOpenGLcxx . . $ opengl_TranslateBitmapToOpenGL(1559a299834bcdd5).(texnum, handle, map_type, 0, tn);
1103 } else {
1104 texnum = OpenGL_lightmap_remapcxx . . $ OpenGL_lightmap_remap.[handle];
1105 if (GameLightmapscxx . . $ GameLightmaps.[handle].flagscxx . . $ bms_lightmap#flags. & LF_CHANGEDcxx . . $ `lib/lightmap.h:28:9`!)
1106 opengl_TranslateBitmapToOpenGLcxx . . $ opengl_TranslateBitmapToOpenGL(1559a299834bcdd5).(texnum, handle, map_type, 1, tn);
1107 }
1108 } else {
1109 if (OpenGL_bitmap_remapcxx . . $ OpenGL_bitmap_remap.[handle] == 65535) {
1110 texnum = opengl_MakeTextureObjectcxx . . $ opengl_MakeTextureObject(7864480464b09eea).(tn);
1111 SET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:84:9`!(OpenGL_bitmap_states[handle], 1);
1112 SET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:89:9`!(OpenGL_bitmap_states[handle], 0);
1113 OpenGL_bitmap_remapcxx . . $ OpenGL_bitmap_remap.[handle] = texnum;
1114 opengl_TranslateBitmapToOpenGLcxx . . $ opengl_TranslateBitmapToOpenGL(1559a299834bcdd5).(texnum, handle, map_type, 0, tn);
1115 } else {
1116 texnum = OpenGL_bitmap_remapcxx . . $ OpenGL_bitmap_remap.[handle];
1117 if (GameBitmapscxx . . $ GameBitmaps.[handle].flagscxx . . $ bms_bitmap#flags. & BF_CHANGEDcxx . . $ `lib/bitmap.h:46:9`!) {
1118 opengl_TranslateBitmapToOpenGLcxx . . $ opengl_TranslateBitmapToOpenGL(1559a299834bcdd5).(texnum, handle, map_type, 1, tn);
1119 }
1120 }
1121 }
1122
1123 if (OpenGL_last_boundcxx . . $ OpenGL_last_bound.[tn] != texnum) {
1124 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != tn) {
1125 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1126 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + tn);
1127 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = tn;
1128 #endif
1129 }
1130
1131 dglBindTexturecxx . . $ dglBindTexture.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, texnum);
1132 OpenGL_last_boundcxx . . $ OpenGL_last_bound.[tn] = texnum;
1133 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[0]++;
1134 }
1135
1136 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(7)
1137 return 1;
1138 }
1139
1140 // Sets up an appropriate wrap type for the current bound texture
1141 void opengl_MakeWrapTypeCurrentcxx . . $ opengl_MakeWrapTypeCurrent(b1146eedae1e1d0b).(int handle, int map_type, int tn) {
1142 int uwrap;
1143 wrap_typecxx . . $ wrap_type# dest_wrap;
1144
1145 if (tn == 1)
1146 dest_wrap = WT_CLAMPcxx . . $ WT_CLAMP.;
1147 else
1148 dest_wrap = gpu_statecxx . . $ gpu_state..cur_wrap_typecxx . . $ rendering_state#cur_wrap_type.;
1149
1150 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!)
1151 uwrap = GET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:81:9`!(OpenGL_lightmap_states[handle]);
1152 else
1153 uwrap = GET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:81:9`!(OpenGL_bitmap_states[handle]);
1154
1155 if (uwrap == dest_wrap)
1156 return;
1157
1158 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != tn) {
1159 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1160 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + tn);
1161 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = tn;
1162 #endif
1163 }
1164
1165 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[1]++;
1166
1167 if (gpu_statecxx . . $ gpu_state..cur_wrap_typecxx . . $ rendering_state#cur_wrap_type. == WT_CLAMPcxx . . $ WT_CLAMP.) {
1168 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Scxx . . $ `<external>/12235287750774029552/SDL_opengl.h:666:9`!, GL_CLAMPcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:700:9`!);
1169 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Tcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:667:9`!, GL_CLAMPcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:700:9`!);
1170
1171 } else if (gpu_statecxx . . $ gpu_state..cur_wrap_typecxx . . $ rendering_state#cur_wrap_type. == WT_WRAP_Vcxx . . $ WT_WRAP_V.) {
1172 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Scxx . . $ `<external>/12235287750774029552/SDL_opengl.h:666:9`!, GL_CLAMPcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:700:9`!);
1173 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Tcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:667:9`!, GL_REPEATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:699:9`!);
1174 } else {
1175 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Scxx . . $ `<external>/12235287750774029552/SDL_opengl.h:666:9`!, GL_REPEATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:699:9`!);
1176 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_WRAP_Tcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:667:9`!, GL_REPEATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:699:9`!);
1177 }
1178
1179 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
1180 SET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:84:9`!(OpenGL_lightmap_states[handle], dest_wrap);
1181 } else {
1182 SET_WRAP_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:84:9`!(OpenGL_bitmap_states[handle], dest_wrap);
1183 }
1184
1185 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(8)
1186 }
1187
1188 // Chooses the correct filter type for the currently bound texture
1189 void opengl_MakeFilterTypeCurrentcxx . . $ opengl_MakeFilterTypeCurrent(b1146eedae1e1d0b).(int handle, int map_type, int tn) {
1190 int magf;
1191 int8_t dest_state;
1192
1193 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
1194 magf = GET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:82:9`!(OpenGL_lightmap_states[handle]);
1195 dest_state = 1;
1196 } else {
1197 magf = GET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:82:9`!(OpenGL_bitmap_states[handle]);
1198 dest_state = gpu_preferred_statecxx . . $ gpu_preferred_state..filteringcxx . . $ renderer_preferred_state#filtering.;
1199 if (!gpu_statecxx . . $ gpu_state..cur_bilinear_statecxx . . $ rendering_state#cur_bilinear_state.)
1200 dest_state = 0;
1201 }
1202
1203 if (magf == dest_state)
1204 return;
1205 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1206 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != tn) {
1207 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + tn);
1208 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = tn;
1209 }
1210 #endif
1211
1212 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[2]++;
1213
1214 if (dest_state) {
1215 if (map_type == MAP_TYPE_BITMAPcxx . . $ `lib/renderer.h:362:9`! && bm_mippedcxx . . $ bm_mipped(7864480464b09eea).(handle)) {
1216 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MAG_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:668:9`!, GL_LINEARcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:441:9`!);
1217 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MIN_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:669:9`!, GL_LINEAR_MIPMAP_NEARESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:689:9`!);
1218 } else {
1219 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MAG_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:668:9`!, GL_LINEARcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:441:9`!);
1220 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MIN_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:669:9`!, GL_LINEARcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:441:9`!);
1221 }
1222 } else {
1223 if (map_type == MAP_TYPE_BITMAPcxx . . $ `lib/renderer.h:362:9`! && bm_mippedcxx . . $ bm_mipped(7864480464b09eea).(handle)) {
1224 // dglTexParameteri (GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST_MIPMAP_NEAREST);
1225 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MAG_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:668:9`!, GL_NEARESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:698:9`!);
1226 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MIN_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:669:9`!, GL_NEAREST_MIPMAP_NEARESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:687:9`!);
1227 } else {
1228 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MAG_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:668:9`!, GL_NEARESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:698:9`!);
1229 dglTexParametericxx . . $ dglTexParameteri.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!, GL_TEXTURE_MIN_FILTERcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:669:9`!, GL_NEARESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:698:9`!);
1230 }
1231 }
1232
1233 if (map_type == MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!) {
1234 SET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:89:9`!(OpenGL_lightmap_states[handle], dest_state);
1235 } else {
1236 SET_FILTER_STATEcxx . . $ `renderer/HardwareOpenGL.cpp:89:9`!(OpenGL_bitmap_states[handle], dest_state);
1237 }
1238
1239 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(9)
1240 }
1241
1242 // Turns on/off multitexture blending
1243 void gpu_SetMultitextureBlendModecxx . . $ gpu_SetMultitextureBlendMode(b45ddcbc8423892c).(bool state) {
1244 if (OpenGL_multitexture_statecxx . . $ OpenGL_multitexture_state. == state)
1245 return;
1246 OpenGL_multitexture_statecxx . . $ OpenGL_multitexture_state. = state;
1247
1248 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1249 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE1_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1985:9`!);
1250 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE1_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1985:9`!);
1251 if (state) {
1252 dglEnableClientStatecxx . . $ dglEnableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
1253 dglEnablecxx . . $ dglEnable.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!);
1254 } else {
1255 dglDisableClientStatecxx . . $ dglDisableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
1256 dglDisablecxx . . $ dglDisable.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!);
1257 }
1258 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`!);
1259 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`!);
1260 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = 0;
1261 #endif
1262 }
1263
1264 void gpu_DrawFlatPolygon3Dcxx . . $ gpu_DrawFlatPolygon3D(3ae387dc3696f211).(g3Pointcxx . . $ g3Point# **p, int nv) {
1265 float fr, fg, fb;
1266 int i;
1267
1268 if (UseMultitexturecxx . . $ UseMultitexture.) {
1269 gpu_SetMultitextureBlendModecxx . . $ gpu_SetMultitextureBlendMode(b45ddcbc8423892c).(false);
1270 }
1271
1272 float alpha = gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.;
1273
1274 fr = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.);
1275 fg = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.);
1276 fb = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.);
1277 fr /= 255.0;
1278 fg /= 255.0;
1279 fb /= 255.0;
1280
1281 // And draw!
1282 dglBegincxx . . $ dglBegin.(GL_POLYGONcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:219:9`!);
1283 for (i = 0; i < nv; i++) {
1284 g3Pointcxx . . $ g3Point# *pnt = p[i];
1285 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pnt->p3_flags & PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!);
1286
1287 if (gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type. & ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!)
1288 alpha = pnt->p3_acxx . . $ `lib/3d.h:256:9`! * gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.;
1289
1290 // If we have a lighting model, apply the correct lighting!
1291 if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. != LS_NONEcxx . . $ LS_NONE.) {
1292 // Do lighting based on intesity (MONO) or colored (RGB)
1293 if (gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. == CM_MONOcxx . . $ CM_MONO.)
1294 dglColor4fcxx . . $ dglColor4f.(pnt->p3_lcxx . . $ `lib/3d.h:252:9`!, pnt->p3_lcxx . . $ `lib/3d.h:252:9`!, pnt->p3_lcxx . . $ `lib/3d.h:252:9`!, alpha);
1295 else {
1296 dglColor4fcxx . . $ dglColor4f.(pnt->p3_rcxx . . $ `lib/3d.h:253:9`!, pnt->p3_gcxx . . $ `lib/3d.h:254:9`!, pnt->p3_bcxx . . $ `lib/3d.h:255:9`!, alpha);
1297 }
1298
1299 } else {
1300 dglColor4fcxx . . $ dglColor4f.(fr, fg, fb, alpha);
1301 }
1302
1303 /*
1304 // Finally, specify a vertex
1305 float z = std::max(0,std::min(1.0,1.0-(1.0/(pnt->p3_z+Z_bias))));
1306 dglVertex3f (pnt->p3_sx+x_add,pnt->p3_sy+y_add,-z);
1307 */
1308 dglVertex3fcxx . . $ dglVertex3f.(pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot..xcxx . . $ vector#x., pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot..ycxx . . $ vector#y., pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot..zcxx . . $ vector#z.);
1309 }
1310
1311 dglEndcxx . . $ dglEnd.();
1312 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(11)
1313 OpenGL_polys_drawncxx . . $ OpenGL_polys_drawn.++;
1314 OpenGL_verts_processedcxx . . $ OpenGL_verts_processed. += nv;
1315 }
1316
1317 // Sets the gamma correction value
1318 void rend_SetGammaValuecxx . . $ rend_SetGammaValue(9364e6e7bff7660).(float val) {
1319 // if( WindowGL )
1320 // return;
1321
1322 gpu_preferred_statecxx . . $ gpu_preferred_state..gammacxx . . $ renderer_preferred_state#gamma. = val;
1323 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Setting gamma to %f\n", val);
1324 }
1325
1326 // Resets the texture cache
1327 void opengl_ResetCachecxx . . $ opengl_ResetCache(49f6e7a06ebc5aa8).(void) {
1328 if (OpenGL_cache_inittedcxx . . $ OpenGL_cache_initted.) {
1329 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_lightmap_remap);
1330 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_bitmap_remap);
1331 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_lightmap_states);
1332 mem_freecxx . . $ `mem/mem.h:80:9`!(OpenGL_bitmap_states);
1333 OpenGL_cache_inittedcxx . . $ OpenGL_cache_initted. = 0;
1334 }
1335
1336 opengl_InitCachecxx . . $ opengl_InitCache(b126dc7c1de90089).();
1337 }
1338
1339 uint8_tcxx . . $ uint8_t# opengl_Framebuffer_readycxx . . $ opengl_Framebuffer_ready. = 0;
1340 chunked_bitmapcxx . . $ chunked_bitmap# opengl_Chunked_bitmapcxx . . $ opengl_Chunked_bitmap.;
1341
1342 void opengl_ChangeChunkedBitmapcxx . . $ opengl_ChangeChunkedBitmap(367ea157a22f9336).(int bm_handle, chunked_bitmapcxx . . $ chunked_bitmap# *chunk) {
1343 int bw = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0);
1344 int bh = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0);
1345
1346 // determine optimal size of the square bitmaps
1347 float fopt = 128.0f;
1348 int iopt;
1349
1350 // find the smallest dimension and base off that
1351 int smallest = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(bw, bh);
1352
1353 if (smallest <= 32)
1354 fopt = 32;
1355 else if (smallest <= 64)
1356 fopt = 64;
1357 else
1358 fopt = 128;
1359
1360 iopt = (int)fopt;
1361
1362 // Get how many pieces we need across and down
1363 float temp = bw / fopt;
1364 int how_many_across = temp;
1365 if ((temp - how_many_across) > 0)
1366 how_many_across++;
1367
1368 temp = bh / fopt;
1369 int how_many_down = temp;
1370 if ((temp - how_many_down) > 0)
1371 how_many_down++;
1372
1373 ASSERTcxx . . $ `misc/pserror.h:246:9`!(how_many_across > 0);
1374 ASSERTcxx . . $ `misc/pserror.h:246:9`!(how_many_down > 0);
1375
1376 // Now go through our big bitmap and partition it into pieces
1377 uint16_tcxx . . $ uint16_t# *src_data = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(bm_handle, 0);
1378 uint16_tcxx . . $ uint16_t# *sdata;
1379 uint16_tcxx . . $ uint16_t# *ddata;
1380
1381 int shift;
1382 switch (iopt) {
1383 case 32:
1384 shift = 5;
1385 break;
1386 case 64:
1387 shift = 6;
1388 break;
1389 case 128:
1390 shift = 7;
1391 break;
1392 default:
1393 Int3cxx . . $ `misc/pserror.h:247:9`!(); // Get Jeff
1394 break;
1395 }
1396 int maxx, maxy;
1397 int windex, hindex;
1398 int s_y, s_x, d_y, d_x;
1399
1400 for (hindex = 0; hindex < how_many_down; hindex++) {
1401 for (windex = 0; windex < how_many_across; windex++) {
1402 // loop through the chunks
1403 // find end x and y
1404 if (windex < how_many_across - 1)
1405 maxx = iopt;
1406 else
1407 maxx = bw - (windex << shift);
1408 if (hindex < how_many_down - 1)
1409 maxy = iopt;
1410 else
1411 maxy = bh - (hindex << shift);
1412
1413 // find the starting source x and y
1414 s_x = (windex << shift);
1415 s_y = (hindex << shift);
1416
1417 // get the pointers pointing to the right spot
1418 ddata = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(chunk->bm_arraycxx . . $ chunked_bitmap#bm_array.[hindex * how_many_across + windex], 0);
1419 GameBitmapscxx . . $ GameBitmaps.[chunk->bm_arraycxx . . $ chunked_bitmap#bm_array.[hindex * how_many_across + windex]].flagscxx . . $ bms_bitmap#flags. |= BF_CHANGEDcxx . . $ `lib/bitmap.h:46:9`!;
1420 sdata = &src_data[s_y * bw + s_x];
1421
1422 // copy the data
1423 for (d_y = 0; d_y < maxy; d_y++) {
1424 for (d_x = 0; d_x < maxx; d_x++) {
1425 ddata[d_x] = sdata[d_x];
1426 } // end for d_x
1427 sdata += bw;
1428 ddata += iopt;
1429 } // end for d_y
1430
1431 } // end for windex
1432 } // end for hindex
1433 }
1434
1435 // Tells the software renderer whether or not to use mipping
1436 void rend_SetMipStatecxx . . $ rend_SetMipState(4af4fd0e2b26c4ac).(int8_t mipstate) {}
1437
1438 // Init our renderer
1439 int rend_Initcxx . . $ rend_Init(ae0da8e3769500f1).(renderer_typecxx . . $ renderer_type# state, oeApplicationcxx . . $ oeApplication# *app, renderer_preferred_statecxx . . $ renderer_preferred_state# *pref_state) {
1440 #ifndef DEDICATED_ONLY
1441 int retval = 0;
1442 rend_SetRendererTypecxx . . $ rend_SetRendererType(dddea4430b800401).(state);
1443 if (!Renderer_inittedcxx . . $ Renderer_initted.) {
1444 if (!Renderer_close_flagcxx . . $ Renderer_close_flag.) {
1445 atexit(rend_Closecxx . . $ rend_Close(49f6e7a06ebc5aa8).);
1446 Renderer_close_flagcxx . . $ Renderer_close_flag. = 1;
1447 }
1448
1449 Renderer_inittedcxx . . $ Renderer_initted. = 1;
1450 }
1451
1452 if (OpenGL_window_inittedcxx . . $ OpenGL_window_initted.) {
1453 rend_CloseOpenGLWindowcxx . . $ rend_CloseOpenGLWindow(49f6e7a06ebc5aa8).();
1454 OpenGL_window_inittedcxx . . $ OpenGL_window_initted. = 0;
1455 }
1456
1457 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Renderer init is set to %d\n", Renderer_initted);
1458
1459 #ifndef OEM_V3
1460 int flags = app->flagscxx . . $ oeApplication#flags(455f465bc33b4cdf).();
1461 if (flags & OEAPP_WINDOWEDcxx . . $ OEAPP_WINDOWED.) {
1462 // initialize for windowed
1463 retval = rend_InitOpenGLWindowcxx . . $ rend_InitOpenGLWindow(5803d2fe7a27ef5).(app, pref_state);
1464 } else {
1465 // initialize for full screen
1466 retval = opengl_Initcxx . . $ opengl_Init(5803d2fe7a27ef5).(app, pref_state);
1467 }
1468 #endif
1469
1470 return retval;
1471 #else
1472 return 0;
1473 #endif // #ifdef DEDICATED_ONLY
1474 }
1475
1476 void rend_Closecxx . . $ rend_Close(49f6e7a06ebc5aa8).(void) {
1477 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "CLOSE:Renderer init is set to %d\n", Renderer_initted);
1478 if (!Renderer_inittedcxx . . $ Renderer_initted.)
1479 return;
1480
1481 if (OpenGL_window_inittedcxx . . $ OpenGL_window_initted.) {
1482 if (Renderer_typecxx . . $ Renderer_type. == RENDERER_OPENGLcxx . . $ RENDERER_OPENGL.) {
1483 rend_CloseOpenGLWindowcxx . . $ rend_CloseOpenGLWindow(49f6e7a06ebc5aa8).();
1484 }
1485 OpenGL_window_inittedcxx . . $ OpenGL_window_initted. = 0;
1486 }
1487
1488 opengl_Closecxx . . $ opengl_Close(b45ddcbc8423892c).();
1489
1490 Renderer_inittedcxx . . $ Renderer_initted. = 0;
1491 }
1492
1493 void gpu_BindTexturecxx . . $ gpu_BindTexture(b1146eedae1e1d0b).(int handle, int map_type, int slot) {
1494 opengl_MakeBitmapCurrentcxx . . $ opengl_MakeBitmapCurrent(2326284602b0bb2d).(handle, map_type, slot);
1495 opengl_MakeWrapTypeCurrentcxx . . $ opengl_MakeWrapTypeCurrent(b1146eedae1e1d0b).(handle, map_type, slot);
1496 opengl_MakeFilterTypeCurrentcxx . . $ opengl_MakeFilterTypeCurrent(b1146eedae1e1d0b).(handle, map_type, slot);
1497 }
1498
1499 void gpu_RenderPolygoncxx . . $ gpu_RenderPolygon(1c3023f92cf1bc74).(PosColorUVVertexcxx . . $ PosColorUVVertex# *vData, uint32_tcxx . . $ uint32_t# nv) {
1500 dglVertexPointercxx . . $ dglVertexPointer.(3, GL_FLOATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:203:9`!, sizeof(*vData), &vData->poscxx . . $ PosColorUVVertex#pos.);
1501 dglColorPointercxx . . $ dglColorPointer.(4, GL_FLOATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:203:9`!, sizeof(*vData), &vData->colorcxx . . $ PosColorUVVertex#color.);
1502 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
1503 dglTexCoordPointercxx . . $ dglTexCoordPointer.(4, GL_FLOATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:203:9`!, sizeof(*vData), &vData->uvcxx . . $ PosColorUVVertex#uv.);
1504
1505 if (gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. == 0) {
1506 // force disable textures
1507 dglDisableClientStatecxx . . $ dglDisableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
1508 }
1509
1510 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 1);
1511 dglDisableClientStatecxx . . $ dglDisableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
1512
1513 // draw the data in the arrays
1514 dglDrawArrayscxx . . $ dglDrawArrays.(GL_POLYGONcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:219:9`!, 0, nv);
1515
1516 if (gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. == 0) {
1517 // re-enable textures
1518 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
1519 dglEnableClientStatecxx . . $ dglEnableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
1520 }
1521
1522 OpenGL_polys_drawncxx . . $ OpenGL_polys_drawn.++;
1523 OpenGL_verts_processedcxx . . $ OpenGL_verts_processed. += nv;
1524 }
1525
1526 void gpu_RenderPolygonUV2cxx . . $ gpu_RenderPolygonUV2(e7931de23695a417).(PosColorUV2Vertexcxx . . $ PosColorUV2Vertex# *vData, uint32_tcxx . . $ uint32_t# nv) {
1527 dglVertexPointercxx . . $ dglVertexPointer.(3, GL_FLOATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:203:9`!, sizeof(*vData), &vData->poscxx . . $ PosColorUV2Vertex#pos.);
1528 dglColorPointercxx . . $ dglColorPointer.(4, GL_FLOATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:203:9`!, sizeof(*vData), &vData->colorcxx . . $ PosColorUV2Vertex#color.);
1529 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
1530 dglTexCoordPointercxx . . $ dglTexCoordPointer.(4, GL_FLOATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:203:9`!, sizeof(*vData), &vData->uv0cxx . . $ PosColorUV2Vertex#uv0.);
1531 oglClientActiveTextureARBcxx . . $ oglClientActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 1);
1532 dglEnableClientStatecxx . . $ dglEnableClientState.(GL_TEXTURE_COORD_ARRAYcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:226:9`!);
1533 dglTexCoordPointercxx . . $ dglTexCoordPointer.(4, GL_FLOATcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:203:9`!, sizeof(*vData), &vData->uv1cxx . . $ PosColorUV2Vertex#uv1.);
1534
1535 dglDrawArrayscxx . . $ dglDrawArrays.(GL_POLYGONcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:219:9`!, 0, nv);
1536 OpenGL_polys_drawncxx . . $ OpenGL_polys_drawn.++;
1537 OpenGL_verts_processedcxx . . $ OpenGL_verts_processed. += nv;
1538
1539 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(10)
1540 }
1541
1542 void rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# color) { gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color. = color; }
1543
1544 // Sets the fog state to TRUE or FALSE
1545 void rend_SetFogStatecxx . . $ rend_SetFogState(4af4fd0e2b26c4ac).(int8_t state) {
1546 if (state == gpu_statecxx . . $ gpu_state..cur_fog_statecxx . . $ rendering_state#cur_fog_state.)
1547 return;
1548
1549 gpu_statecxx . . $ gpu_state..cur_fog_statecxx . . $ rendering_state#cur_fog_state. = state;
1550 if (state == 1) {
1551 dglEnablecxx . . $ dglEnable.(GL_FOGcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:434:9`!);
1552 } else {
1553 dglDisablecxx . . $ dglDisable.(GL_FOGcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:434:9`!);
1554 }
1555 }
1556
1557 // Sets the near and far plane of fog
1558 void rend_SetFogBorderscxx . . $ rend_SetFogBorders(5102ef758adc0ae7).(float nearz, float farz) {
1559 // Sets the near and far plane of fog
1560 float fogStart = nearz;
1561 float fogEnd = farz;
1562
1563 gpu_statecxx . . $ gpu_state..cur_fog_startcxx . . $ rendering_state#cur_fog_start. = fogStart;
1564 gpu_statecxx . . $ gpu_state..cur_fog_endcxx . . $ rendering_state#cur_fog_end. = fogEnd;
1565
1566 dglFogicxx . . $ dglFogi.(GL_FOG_MODEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:435:9`!, GL_LINEARcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:441:9`!);
1567 dglFogfcxx . . $ dglFogf.(GL_FOG_STARTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:439:9`!, fogStart);
1568 dglFogfcxx . . $ dglFogf.(GL_FOG_ENDcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:440:9`!, fogEnd);
1569 }
1570
1571 void rend_SetRendererTypecxx . . $ rend_SetRendererType(dddea4430b800401).(renderer_typecxx . . $ renderer_type# state) {
1572 Renderer_typecxx . . $ Renderer_type. = state;
1573 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "RendererType is set to %d.\n", state);
1574 }
1575
1576 void rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(light_statecxx . . $ light_state# state) {
1577 if (state == gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state.)
1578 return; // No redundant state setting
1579 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1580 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != 0) {
1581 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
1582 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = 0;
1583 }
1584 #endif
1585
1586 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[4]++;
1587
1588 switch (state) {
1589 case LS_NONEcxx . . $ LS_NONE.:
1590 dglShadeModelcxx . . $ dglShadeModel.(GL_SMOOTHcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:359:9`!);
1591 gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. = LS_NONEcxx . . $ LS_NONE.;
1592 break;
1593 case LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD.:
1594 dglShadeModelcxx . . $ dglShadeModel.(GL_SMOOTHcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:359:9`!);
1595 gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. = LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD.;
1596 break;
1597 case LS_GOURAUDcxx . . $ LS_GOURAUD.:
1598 case LS_PHONGcxx . . $ LS_PHONG.:
1599 dglShadeModelcxx . . $ dglShadeModel.(GL_SMOOTHcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:359:9`!);
1600 gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. = LS_GOURAUDcxx . . $ LS_GOURAUD.;
1601 break;
1602 default:
1603 Int3cxx . . $ `misc/pserror.h:247:9`!();
1604 break;
1605 }
1606
1607 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(13)
1608 }
1609
1610 void rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(color_modelcxx . . $ color_model# state) {
1611 switch (state) {
1612 case CM_MONOcxx . . $ CM_MONO.:
1613 gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. = CM_MONOcxx . . $ CM_MONO.;
1614 break;
1615 case CM_RGBcxx . . $ CM_RGB.:
1616 gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. = CM_RGBcxx . . $ CM_RGB.;
1617 break;
1618 default:
1619 Int3cxx . . $ `misc/pserror.h:247:9`!();
1620 break;
1621 }
1622 }
1623
1624 void rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(texture_typecxx . . $ texture_type# state) {
1625 if (state == gpu_statecxx . . $ gpu_state..cur_texture_typecxx . . $ rendering_state#cur_texture_type.)
1626 return; // No redundant state setting
1627 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1628 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != 0) {
1629 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
1630 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = 0;
1631 }
1632 #endif
1633 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[3]++;
1634
1635 switch (state) {
1636 case TT_FLATcxx . . $ TT_FLAT.:
1637 dglDisablecxx . . $ dglDisable.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!);
1638 gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. = 0;
1639 break;
1640 case TT_LINEARcxx . . $ TT_LINEAR.:
1641 case TT_LINEAR_SPECIALcxx . . $ TT_LINEAR_SPECIAL.:
1642 case TT_PERSPECTIVEcxx . . $ TT_PERSPECTIVE.:
1643 case TT_PERSPECTIVE_SPECIALcxx . . $ TT_PERSPECTIVE_SPECIAL.:
1644 dglEnablecxx . . $ dglEnable.(GL_TEXTURE_2Dcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:665:9`!);
1645 gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. = 2;
1646 break;
1647 default:
1648 Int3cxx . . $ `misc/pserror.h:247:9`!(); // huh? Get Jason
1649 break;
1650 }
1651
1652 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(12)
1653 gpu_statecxx . . $ gpu_state..cur_texture_typecxx . . $ rendering_state#cur_texture_type. = state;
1654 }
1655
1656 void rend_StartFramecxx . . $ rend_StartFrame(1559a299834bcdd5).(int x1, int y1, int x2, int y2, int clear_flags) {
1657 if (clear_flags & RF_CLEAR_ZBUFFERcxx . . $ `lib/renderer.h:329:9`!) {
1658 dglClearcxx . . $ dglClear.(GL_DEPTH_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:730:9`!);
1659 }
1660 gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1. = x1;
1661 gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1. = y1;
1662 gpu_statecxx . . $ gpu_state..clip_x2cxx . . $ rendering_state#clip_x2. = x2;
1663 gpu_statecxx . . $ gpu_state..clip_y2cxx . . $ rendering_state#clip_y2. = y2;
1664 }
1665
1666
1667 // Flips the screen
1668 void rend_Flipcxx . . $ rend_Flip(49f6e7a06ebc5aa8).(void) {
1669 #ifndef RELEASE
1670 int i;
1671
1672 RTP_INCRVALUEcxx . . $ `rtperformance/rtperformance.h:116:9`!(texture_uploads, OpenGL_uploads);
1673 RTP_INCRVALUEcxx . . $ `rtperformance/rtperformance.h:116:9`!(polys_drawn, OpenGL_polys_drawn);
1674
1675 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(1, 1, 0, "Uploads=%d Polys=%d Verts=%d ", OpenGL_uploads, OpenGL_polys_drawn, OpenGL_verts_processed);
1676 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(1, 2, 0, "Sets= 0:%d 1:%d 2:%d 3:%d ", OpenGL_sets_this_frame[0], OpenGL_sets_this_frame[1],
1677 OpenGL_sets_this_frame[2], OpenGL_sets_this_frame[3]);
1678 mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(1, 3, 0, "Sets= 4:%d 5:%d ", OpenGL_sets_this_frame[4], OpenGL_sets_this_frame[5]);
1679 for (i = 0; i < 10; i++) {
1680 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[i] = 0;
1681 }
1682 #endif
1683
1684 gpu_last_frame_polys_drawncxx . . $ gpu_last_frame_polys_drawn. = OpenGL_polys_drawncxx . . $ OpenGL_polys_drawn.;
1685 gpu_last_frame_verts_processedcxx . . $ gpu_last_frame_verts_processed. = OpenGL_verts_processedcxx . . $ OpenGL_verts_processed.;
1686 gpu_last_uploadedcxx . . $ gpu_last_uploaded. = OpenGL_uploadscxx . . $ OpenGL_uploads.;
1687
1688 OpenGL_uploadscxx . . $ OpenGL_uploads. = 0;
1689 OpenGL_polys_drawncxx . . $ OpenGL_polys_drawn. = 0;
1690 OpenGL_verts_processedcxx . . $ OpenGL_verts_processed. = 0;
1691
1692 // if we're rendering to an FBO, scale to the window framebuffer!
1693 if (GOpenGLFBOcxx . . $ GOpenGLFBO. != 0) {
1694 int w, h;
1695 SDL_GL_GetDrawableSize(GSDLWindowcxx . . $ GSDLWindow., &w, &h);
1696
1697 int scaledHeight, scaledWidth;
1698 if (w < h) {
1699 scaledWidth = w;
1700 scaledHeight = (int) (((((double)GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight.) / ((double)GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth.))) * ((double)w));
1701 } else {
1702 scaledHeight = h;
1703 scaledWidth = (int) (((((double)GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth.) / ((double)GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight.))) * ((double)h));
1704 }
1705
1706 const int centeredX = (w - scaledWidth) / 2;
1707 const int centeredY = (h - scaledHeight) / 2;
1708
1709 dglBindFramebufferEXTcxx . . $ dglBindFramebufferEXT.(GL_DRAW_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:146:9`!, 0);
1710 dglClearColorcxx . . $ dglClearColor. (0.0f, 0.0f, 0.0f, 1.0f);
1711 dglClearcxx . . $ dglClear.(GL_COLOR_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:736:9`!); // in case the Steam Overlay wrote to places we don't blit over.
1712 dglBlitFramebufferEXTcxx . . $ dglBlitFramebufferEXT.(0, 0, GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth., GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight.,
1713 centeredX, centeredY, centeredX + scaledWidth, centeredY + scaledHeight,
1714 GL_COLOR_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:736:9`!, GL_LINEARcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:441:9`!);
1715 dglBindFramebufferEXTcxx . . $ dglBindFramebufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, 0);
1716 }
1717
1718 SDL_GL_SwapWindow(GSDLWindowcxx . . $ GSDLWindow.);
1719
1720 // go back to drawing on the FBO until we want to blit to the window framebuffer again.
1721 if (GOpenGLFBOcxx . . $ GOpenGLFBO. != 0) {
1722 dglBindFramebufferEXTcxx . . $ dglBindFramebufferEXT.(GL_FRAMEBUFFER_EXTcxx . . $ `renderer/HardwareOpenGL.cpp:151:9`!, GOpenGLFBOcxx . . $ GOpenGLFBO.);
1723 dglViewportcxx . . $ dglViewport.(0, 0, GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth., GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight.);
1724 dglScissorcxx . . $ dglScissor.(0, 0, GOpenGLFBOWidthcxx . . $ GOpenGLFBOWidth., GOpenGLFBOHeightcxx . . $ GOpenGLFBOHeight.);
1725 }
1726 }
1727
1728 void rend_EndFramecxx . . $ rend_EndFrame(49f6e7a06ebc5aa8).(void) {}
1729
1730 // Sets the state of z-buffering to on or off
1731 void rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(int8_t state) {
1732 if (state == gpu_statecxx . . $ gpu_state..cur_zbuffer_statecxx . . $ rendering_state#cur_zbuffer_state.)
1733 return; // No redundant state setting
1734
1735 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[5]++;
1736 gpu_statecxx . . $ gpu_state..cur_zbuffer_statecxx . . $ rendering_state#cur_zbuffer_state. = state;
1737
1738 // mprintf(0,"OPENGL: Setting zbuffer state to %d.\n",state);
1739
1740 if (state) {
1741 dglEnablecxx . . $ dglEnable.(GL_DEPTH_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:321:9`!);
1742 dglDepthFunccxx . . $ dglDepthFunc.(GL_LEQUALcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:316:9`!);
1743 } else {
1744 dglDisablecxx . . $ dglDisable.(GL_DEPTH_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:321:9`!);
1745 }
1746
1747 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(14)
1748 }
1749
1750 // Clears the display to a specified color
1751 void rend_ClearScreencxx . . $ rend_ClearScreen(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# color) {
1752 int r = (color >> 16 & 0xFF);
1753 int g = (color >> 8 & 0xFF);
1754 int b = (color & 0xFF);
1755
1756 dglClearColorcxx . . $ dglClearColor.((float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 0);
1757
1758 dglClearcxx . . $ dglClear.(GL_COLOR_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:736:9`! | GL_DEPTH_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:730:9`!);
1759 }
1760
1761 // Clears the zbuffer for the screen
1762 void rend_ClearZBuffercxx . . $ rend_ClearZBuffer(49f6e7a06ebc5aa8).(void) { dglClearcxx . . $ dglClear.(GL_DEPTH_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:730:9`!); }
1763
1764 // Clears the zbuffer for the screen
1765 void rend_ResetCachecxx . . $ rend_ResetCache(49f6e7a06ebc5aa8).(void) {
1766 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Resetting texture cache!\n");
1767 opengl_ResetCachecxx . . $ opengl_ResetCache(49f6e7a06ebc5aa8).();
1768 }
1769
1770 // Fills a rectangle on the display
1771 void rend_FillRectcxx . . $ rend_FillRect(fe09a4b73d8d396f).(ddgr_colorcxx . . $ ddgr_color# color, int x1, int y1, int x2, int y2) {
1772 int r = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color);
1773 int g = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color);
1774 int b = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color);
1775
1776 int width = x2 - x1;
1777 int height = y2 - y1;
1778
1779 x1 += gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1.;
1780 y1 += gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.;
1781
1782 dglEnablecxx . . $ dglEnable.(GL_SCISSOR_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:609:9`!);
1783 dglScissorcxx . . $ dglScissor.(x1, gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height. - (height + y1), width, height);
1784 dglClearColorcxx . . $ dglClearColor.((float)r / 255.0, (float)g / 255.0, (float)b / 255.0, 0);
1785 dglClearcxx . . $ dglClear.(GL_COLOR_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:736:9`! | GL_DEPTH_BUFFER_BITcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:730:9`!);
1786
1787 width = gpu_statecxx . . $ gpu_state..clip_x2cxx . . $ rendering_state#clip_x2. - gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1.;
1788 height = gpu_statecxx . . $ gpu_state..clip_y2cxx . . $ rendering_state#clip_y2. - gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.;
1789
1790 dglScissorcxx . . $ dglScissor.(gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1., gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height. - (gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1. + height), width, height);
1791 dglDisablecxx . . $ dglDisable.(GL_SCISSOR_TESTcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:609:9`!);
1792 }
1793
1794 // Sets a pixel on the display
1795 void rend_SetPixelcxx . . $ rend_SetPixel(8c880916ccadf15d).(ddgr_colorcxx . . $ ddgr_color# color, int x, int y) {
1796 int r = (color >> 16 & 0xFF);
1797 int g = (color >> 8 & 0xFF);
1798 int b = (color & 0xFF);
1799
1800 g3_RefreshTransformscxx . . $ g3_RefreshTransforms(b45ddcbc8423892c).(true);
1801
1802 dglColor3ubcxx . . $ dglColor3ub.(r, g, b);
1803
1804 dglBegincxx . . $ dglBegin.(GL_POINTScxx . . $ `<external>/12235287750774029552/SDL_opengl.h:210:9`!);
1805 dglVertex2icxx . . $ dglVertex2i.(x, y);
1806 dglEndcxx . . $ dglEnd.();
1807 }
1808
1809 // Sets a pixel on the display
1810 ddgr_colorcxx . . $ ddgr_color# rend_GetPixelcxx . . $ rend_GetPixel(58c590d1186ea715).(int x, int y) {
1811 ddgr_colorcxx . . $ ddgr_color# color[4];
1812 dglReadPixelscxx . . $ dglReadPixels.(x, (gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height. - 1) - y, 1, 1, GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_BYTEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:198:9`!, (GLvoid *)color);
1813 return color[0];
1814 }
1815
1816 // Draws a line
1817 void rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(int x1, int y1, int x2, int y2) {
1818 int8_t atype;
1819 light_statecxx . . $ light_state# ltype;
1820 texture_typecxx . . $ texture_type# ttype;
1821 int color = gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.;
1822
1823 g3_RefreshTransformscxx . . $ g3_RefreshTransforms(b45ddcbc8423892c).(true);
1824
1825 int r = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color);
1826 int g = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color);
1827 int b = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color);
1828
1829 atype = gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type.;
1830 ltype = gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state.;
1831 ttype = gpu_statecxx . . $ gpu_state..cur_texture_typecxx . . $ rendering_state#cur_texture_type.;
1832
1833 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!);
1834 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
1835 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.);
1836
1837 // TODO: Generalize
1838 dglBegincxx . . $ dglBegin.(GL_LINEScxx . . $ `<external>/12235287750774029552/SDL_opengl.h:211:9`!);
1839 dglColor4ubcxx . . $ dglColor4ub.(r, g, b, 255);
1840 dglVertex2icxx . . $ dglVertex2i.(x1 + gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1., y1 + gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.);
1841 dglColor4ubcxx . . $ dglColor4ub.(r, g, b, 255);
1842 dglVertex2icxx . . $ dglVertex2i.(x2 + gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1., y2 + gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.);
1843 dglEndcxx . . $ dglEnd.();
1844
1845 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(atype);
1846 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(ltype);
1847 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(ttype);
1848 }
1849
1850 // Sets the color of fog
1851 void rend_SetFogColorcxx . . $ rend_SetFogColor(cb2f890c2fdad230).(ddgr_colorcxx . . $ ddgr_color# color) {
1852 if (color == gpu_statecxx . . $ gpu_state..cur_fog_colorcxx . . $ rendering_state#cur_fog_color.)
1853 return;
1854
1855 float fc[4];
1856 fc[0] = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color);
1857 fc[1] = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color);
1858 fc[2] = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color);
1859 fc[3] = 1;
1860
1861 fc[0] /= 255.0f;
1862 fc[1] /= 255.0f;
1863 fc[2] /= 255.0f;
1864
1865 dglFogfvcxx . . $ dglFogfv.(GL_FOG_COLORcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:437:9`!, fc);
1866 }
1867
1868 // Sets the lighting state of opengl
1869 void rend_SetLightingStatecxx . . $ rend_SetLightingState(e55526c9d3dd1656).(light_statecxx . . $ light_state# state) {
1870 if (state == gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state.)
1871 return; // No redundant state setting
1872
1873 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != 0) {
1874 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1875 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
1876 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = 0;
1877 #endif
1878 }
1879
1880 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[4]++;
1881
1882 switch (state) {
1883 case LS_NONEcxx . . $ LS_NONE.:
1884 dglShadeModelcxx . . $ dglShadeModel.(GL_SMOOTHcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:359:9`!);
1885 gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. = LS_NONEcxx . . $ LS_NONE.;
1886 break;
1887 case LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD.:
1888 dglShadeModelcxx . . $ dglShadeModel.(GL_SMOOTHcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:359:9`!);
1889 gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. = LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD.;
1890 break;
1891 case LS_GOURAUDcxx . . $ LS_GOURAUD.:
1892 case LS_PHONGcxx . . $ LS_PHONG.:
1893 dglShadeModelcxx . . $ dglShadeModel.(GL_SMOOTHcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:359:9`!);
1894 gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. = LS_GOURAUDcxx . . $ LS_GOURAUD.;
1895 break;
1896 default:
1897 Int3cxx . . $ `misc/pserror.h:247:9`!();
1898 break;
1899 }
1900
1901 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(13)
1902 }
1903
1904 void rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(int8_t atype) {
1905 if (atype == gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type.)
1906 return; // don't set it redundantly
1907 #if (defined(_USE_OGL_ACTIVE_TEXTUREScxx . . $ `<built-in>:481:9`!))
1908 if (UseMultitexturecxx . . $ UseMultitexture. && Last_texel_unit_setcxx . . $ Last_texel_unit_set. != 0) {
1909 oglActiveTextureARBcxx . . $ oglActiveTextureARB.(GL_TEXTURE0_ARBcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:1984:9`! + 0);
1910 Last_texel_unit_setcxx . . $ Last_texel_unit_set. = 0;
1911 }
1912 #endif
1913 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[6]++;
1914
1915 if (atype == AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!) {
1916 if (opengl_Blending_oncxx . . $ opengl_Blending_on.) {
1917 dglDisablecxx . . $ dglDisable.(GL_BLENDcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:391:9`!);
1918 opengl_Blending_oncxx . . $ opengl_Blending_on. = false;
1919 }
1920 } else {
1921 if (!opengl_Blending_oncxx . . $ opengl_Blending_on.) {
1922 dglEnablecxx . . $ dglEnable.(GL_BLENDcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:391:9`!);
1923 opengl_Blending_oncxx . . $ opengl_Blending_on. = true;
1924 }
1925 }
1926
1927 switch (atype) {
1928 case AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!:
1929 case AT_TEXTUREcxx . . $ `lib/renderer.h:401:9`!:
1930 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
1931 dglBlendFunccxx . . $ dglBlendFunc.(GL_ONEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:395:9`!, GL_ZEROcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:394:9`!);
1932 break;
1933 case AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!:
1934 case AT_CONSTANT_TEXTUREcxx . . $ `lib/renderer.h:402:9`!:
1935 case AT_VERTEXcxx . . $ `lib/renderer.h:403:9`!:
1936 case AT_CONSTANT_TEXTURE_VERTEXcxx . . $ `lib/renderer.h:406:9`!:
1937 case AT_CONSTANT_VERTEXcxx . . $ `lib/renderer.h:404:9`!:
1938 case AT_TEXTURE_VERTEXcxx . . $ `lib/renderer.h:405:9`!:
1939 dglBlendFunccxx . . $ dglBlendFunc.(GL_SRC_ALPHAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:398:9`!, GL_ONE_MINUS_SRC_ALPHAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:399:9`!);
1940 break;
1941 case AT_LIGHTMAP_BLENDcxx . . $ `lib/renderer.h:407:9`!:
1942 dglBlendFunccxx . . $ dglBlendFunc.(GL_DST_COLORcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:402:9`!, GL_ZEROcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:394:9`!);
1943 break;
1944 case AT_SATURATE_TEXTUREcxx . . $ `lib/renderer.h:408:9`!:
1945 case AT_LIGHTMAP_BLEND_SATURATEcxx . . $ `lib/renderer.h:417:9`!:
1946 case AT_SATURATE_VERTEXcxx . . $ `lib/renderer.h:411:9`!:
1947 case AT_SATURATE_CONSTANT_VERTEXcxx . . $ `lib/renderer.h:412:9`!:
1948 case AT_SATURATE_TEXTURE_VERTEXcxx . . $ `lib/renderer.h:413:9`!:
1949 dglBlendFunccxx . . $ dglBlendFunc.(GL_SRC_ALPHAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:398:9`!, GL_ONEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:395:9`!);
1950 break;
1951 case AT_SPECULARcxx . . $ `lib/renderer.h:416:9`!:
1952 break;
1953 default:
1954 Int3cxx . . $ `misc/pserror.h:247:9`!(); // no type defined,get jason
1955 break;
1956 }
1957 gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type. = atype;
1958 gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. = rend_GetAlphaMultipliercxx . . $ rend_GetAlphaMultiplier(9b8c9e39889c762c).();
1959 CHECK_ERRORcxx . . $ `renderer/HardwareOpenGL.cpp:75:9`!(15)
1960 }
1961
1962 // Draws a line using the states of the renderer
1963 void rend_DrawSpecialLinecxx . . $ rend_DrawSpecialLine(1b637e6b3e24914d).(g3Pointcxx . . $ g3Point# *p0, g3Pointcxx . . $ g3Point# *p1) {
1964 g3_RefreshTransformscxx . . $ g3_RefreshTransforms(b45ddcbc8423892c).(true);
1965
1966 int x_add = gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1.;
1967 int y_add = gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.;
1968 float fr, fg, fb, alpha;
1969 int i;
1970
1971 fr = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.);
1972 fg = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.);
1973 fb = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.);
1974
1975 fr /= 255.0f;
1976 fg /= 255.0f;
1977 fb /= 255.0f;
1978
1979 alpha = gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.;
1980
1981 // And draw!
1982 dglBegincxx . . $ dglBegin.(GL_LINEScxx . . $ `<external>/12235287750774029552/SDL_opengl.h:211:9`!);
1983 for (i = 0; i < 2; i++) {
1984 g3Pointcxx . . $ g3Point# *pnt = p0;
1985
1986 if (i == 1)
1987 pnt = p1;
1988
1989 if (gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type. & ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!)
1990 alpha = pnt->p3_acxx . . $ `lib/3d.h:256:9`! * gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.;
1991
1992 // If we have a lighting model, apply the correct lighting!
1993 if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. != LS_NONEcxx . . $ LS_NONE.) {
1994 if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. == LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD.) {
1995 dglColor4fcxx . . $ dglColor4f.(fr, fg, fb, alpha);
1996 } else {
1997 // Do lighting based on intesity (MONO) or colored (RGB)
1998 if (gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. == CM_MONOcxx . . $ CM_MONO.)
1999 dglColor4fcxx . . $ dglColor4f.(pnt->p3_lcxx . . $ `lib/3d.h:252:9`!, pnt->p3_lcxx . . $ `lib/3d.h:252:9`!, pnt->p3_lcxx . . $ `lib/3d.h:252:9`!, alpha);
2000 else {
2001 dglColor4fcxx . . $ dglColor4f.(pnt->p3_rcxx . . $ `lib/3d.h:253:9`!, pnt->p3_gcxx . . $ `lib/3d.h:254:9`!, pnt->p3_bcxx . . $ `lib/3d.h:255:9`!, alpha);
2002 }
2003 }
2004 } else {
2005 dglColor4fcxx . . $ dglColor4f.(fr, fg, fb, alpha);
2006 }
2007
2008 // Finally, specify a vertex
2009 float z = stdcxx . . $ std/::clampcxx . . $ std/clamp(3dbe0c69cb86ae06).(1.0 - (1.0 / (pnt->p3_zcxx . . $ `lib/3d.h:247:9`! + Z_biascxx . . $ Z_bias.)), 0.0, 1.0);
2010 dglVertex3fcxx . . $ dglVertex3f.(pnt->p3_sxcxx . . $ g3Point#p3_sx. + x_add, pnt->p3_sycxx . . $ g3Point#p3_sy. + y_add, -z);
2011 }
2012
2013 dglEndcxx . . $ dglEnd.();
2014 }
2015
2016 // Takes a screenshot of the current frame and puts it into the handle passed
2017 stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<NewBitmapcxx . . $ NewBitmap#> rend_Screenshotcxx . . $ rend_Screenshot(9a644bd298f70b13).() {
2018 uint16_tcxx . . $ uint16_t# *dest_data;
2019 uint32_tcxx . . $ uint32_t# *temp_data;
2020
2021 int total = gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width. * gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height.;
2022 auto result = stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<NewBitmapcxx . . $ NewBitmap#>(gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width., gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height., PixelDataFormatcxx . . $ PixelDataFormat#::RGBA32cxx . . $ PixelDataFormat#RGBA32., true);
2023
2024 if (!result || result->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).getDatacxx . . $ NewBitmap#getData(707a43c27767d44a).() == nullptr) {
2025 return nullptrcxx . . $ std/unique_ptr#unique_ptr(6d988fd07f070dfc).;
2026 }
2027
2028 dglReadPixelscxx . . $ dglReadPixels.(0, 0, gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width., gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height., GL_RGBAcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:523:9`!, GL_UNSIGNED_BYTEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:198:9`!,
2029 (GLvoid *)result->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).getDatacxx . . $ NewBitmap#getData(707a43c27767d44a).());
2030
2031 return resultcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).;
2032 }
2033
2034 // Takes a screenshot of the current frame and puts it into the handle passed
2035 void rend_Screenshotcxx . . $ rend_Screenshot(d4f767463ce0a6b3).(int bm_handle) {
2036 auto screenshot = rend_Screenshotcxx . . $ rend_Screenshot(9a644bd298f70b13).();
2037 auto *temp_data = reinterpret_cast<uint32_tcxx . . $ uint32_t#*>(screenshot->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).getDatacxx . . $ NewBitmap#getData(707a43c27767d44a).());
2038
2039 uint32_tcxx . . $ uint32_t# w, h;
2040 screenshot->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).getSizecxx . . $ NewBitmap#getSize(aa87d7b5cf3e960a).(w, h);
2041
2042 ASSERTcxx . . $ `misc/pserror.h:246:9`!((bm_w(bm_handle, 0)) == gpu_state.screen_width);
2043 ASSERTcxx . . $ `misc/pserror.h:246:9`!((bm_h(bm_handle, 0)) == gpu_state.screen_height);
2044
2045 uint16_tcxx . . $ uint16_t#* dest_data = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(bm_handle, 0);
2046
2047 for (int i = 0; i < h; i++) {
2048 for (int t = 0; t < w; t++) {
2049 uint32_tcxx . . $ uint32_t# spix = temp_data[i * w + t];
2050
2051 int r = spix & 0xff;
2052 int g = (spix >> 8) & 0xff;
2053 int b = (spix >> 16) & 0xff;
2054
2055 dest_data[(((h - 1) - i) * w) + t] = GR_RGB16cxx . . $ GR_RGB16(6461fafb79bad5b9).(r, g, b);
2056 }
2057 }
2058 }
2059
2060 // Enables/disables writes the depth buffer
2061 void rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(int state) {
2062 OpenGL_sets_this_framecxx . . $ OpenGL_sets_this_frame.[5]++;
2063 if (state) {
2064 dglDepthMaskcxx . . $ dglDepthMask.(GL_TRUEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:194:9`!);
2065 } else {
2066 dglDepthMaskcxx . . $ dglDepthMask.(GL_FALSEcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:193:9`!);
2067 }
2068 }
2069
2070 int rend_ReInitcxx . . $ rend_ReInit(b126dc7c1de90089).() {
2071 opengl_Closecxx . . $ opengl_Close(b45ddcbc8423892c).(true);
2072 return opengl_Initcxx . . $ opengl_Init(5803d2fe7a27ef5).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &gpu_preferred_statecxx . . $ gpu_preferred_state.);
2073 }
2074
2075 // Takes a bitmap and blits it to the screen using linear frame buffer stuff
2076 // X and Y are the destination X,Y
2077 void rend_CopyBitmapToFramebuffercxx . . $ rend_CopyBitmapToFramebuffer(b1146eedae1e1d0b).(int bm_handle, int x, int y) {
2078 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_Framebuffer_ready);
2079
2080 if (opengl_Framebuffer_readycxx . . $ opengl_Framebuffer_ready. == 1) {
2081 bm_CreateChunkedBitmapcxx . . $ bm_CreateChunkedBitmap(b9fa1b176cbdfaf1).(bm_handle, &opengl_Chunked_bitmapcxx . . $ opengl_Chunked_bitmap.);
2082 opengl_Framebuffer_readycxx . . $ opengl_Framebuffer_ready. = 2;
2083 } else {
2084 opengl_ChangeChunkedBitmapcxx . . $ opengl_ChangeChunkedBitmap(367ea157a22f9336).(bm_handle, &opengl_Chunked_bitmapcxx . . $ opengl_Chunked_bitmap.);
2085 }
2086
2087 rend_DrawChunkedBitmapcxx . . $ rend_DrawChunkedBitmap(529c7906ea1e7bf7).(&opengl_Chunked_bitmapcxx . . $ opengl_Chunked_bitmap., 0, 0, 255);
2088 }
2089
2090 // Gets a renderer ready for a framebuffer copy, or stops a framebuffer copy
2091 void rend_SetFrameBufferCopyStatecxx . . $ rend_SetFrameBufferCopyState(b45ddcbc8423892c).(bool state) {
2092 if (state) {
2093 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_Framebuffer_ready == 0);
2094 opengl_Framebuffer_readycxx . . $ opengl_Framebuffer_ready. = 1;
2095 } else {
2096 ASSERTcxx . . $ `misc/pserror.h:246:9`!(opengl_Framebuffer_ready != 0);
2097 opengl_Framebuffer_readycxx . . $ opengl_Framebuffer_ready. = 0;
2098
2099 if (opengl_Framebuffer_readycxx . . $ opengl_Framebuffer_ready. == 2) {
2100 bm_DestroyChunkedBitmapcxx . . $ bm_DestroyChunkedBitmap(1635f60f4d3c1317).(&opengl_Chunked_bitmapcxx . . $ opengl_Chunked_bitmap.);
2101 opengl_ResetCachecxx . . $ opengl_ResetCache(49f6e7a06ebc5aa8).();
2102 }
2103 }
2104 }
2105
2106 // Gets OpenGL ready to work in a window
2107 int rend_InitOpenGLWindowcxx . . $ rend_InitOpenGLWindow(5803d2fe7a27ef5).(oeApplicationcxx . . $ oeApplication# *app, renderer_preferred_statecxx . . $ renderer_preferred_state# *pref_state) {
2108 WindowGLcxx . . $ WindowGL. = 1;
2109 return opengl_Initcxx . . $ opengl_Init(5803d2fe7a27ef5).(app, pref_state);
2110 }
2111
2112 // Shuts down OpenGL in a window
2113 void rend_CloseOpenGLWindowcxx . . $ rend_CloseOpenGLWindow(49f6e7a06ebc5aa8).(void) {
2114 opengl_Closecxx . . $ opengl_Close(b45ddcbc8423892c).();
2115 WindowGLcxx . . $ WindowGL. = 0;
2116 OpenGL_window_inittedcxx . . $ OpenGL_window_initted. = 0;
2117 mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "SHUTTING DOWN WINDOWED OPENGL!");
2118 }
2119
2120 // Sets the hardware bias level for coplanar polygons
2121 // This helps reduce z buffer artifacts
2122 void rend_SetCoplanarPolygonOffsetcxx . . $ rend_SetCoplanarPolygonOffset(9364e6e7bff7660).(float factor) {
2123 if (factor == 0.0f) {
2124 dglDisablecxx . . $ dglDisable.(GL_POLYGON_OFFSET_FILLcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:303:9`!);
2125 } else {
2126 dglEnablecxx . . $ dglEnable.(GL_POLYGON_OFFSET_FILLcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:303:9`!);
2127 dglPolygonOffsetcxx . . $ dglPolygonOffset.(-1.0f, -1.0f);
2128 }
2129 }
2130
2131 // returns the direct draw object
2132 void *rend_RetrieveDirectDrawObjcxx . . $ rend_RetrieveDirectDrawObj(e4f7c2273530be42).(void **frontsurf, void **backsurf) {
2133 *frontsurf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2134 *backsurf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2135 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2136 }
2137
2138 void rend_TransformSetToPassthrucxx . . $ rend_TransformSetToPassthru(49f6e7a06ebc5aa8).(void) {
2139 int width = gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width.;
2140 int height = gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height.;
2141
2142 // TODO: Generalize
2143 // Projection
2144 dglMatrixModecxx . . $ dglMatrixMode.(GL_PROJECTIONcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:266:9`!);
2145 dglLoadIdentitycxx . . $ dglLoadIdentity.();
2146 dglOrthocxx . . $ dglOrtho.((GLfloat)0.0f, (GLfloat)(width), (GLfloat)(height), (GLfloat)0.0f, 0.0f, 1.0f);
2147
2148 // Viewport
2149 dglViewportcxx . . $ dglViewport.(0, 0, width, height);
2150 dglScissorcxx . . $ dglScissor.(0, 0, width, height);
2151
2152 // ModelView
2153 dglMatrixModecxx . . $ dglMatrixMode.(GL_MODELVIEWcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:265:9`!);
2154 dglLoadIdentitycxx . . $ dglLoadIdentity.();
2155 }
2156
2157 void rend_TransformSetViewportcxx . . $ rend_TransformSetViewport(748afa4755bc9595).(int lx, int ty, int width, int height) {
2158 dglViewportcxx . . $ dglViewport.(lx, gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height. - (ty + height - 1), width, height);
2159 }
2160
2161 void rend_TransformSetProjectioncxx . . $ rend_TransformSetProjection(9fb3ef344050b01e).(float trans[4][4]) {
2162 dglMatrixModecxx . . $ dglMatrixMode.(GL_PROJECTIONcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:266:9`!);
2163 dglLoadMatrixfcxx . . $ dglLoadMatrixf.(&trans[0][0]);
2164 }
2165
2166 void rend_TransformSetModelViewcxx . . $ rend_TransformSetModelView(9fb3ef344050b01e).(float trans[4][4]) {
2167 dglMatrixModecxx . . $ dglMatrixMode.(GL_MODELVIEWcxx . . $ `<external>/12235287750774029552/SDL_opengl.h:265:9`!);
2168 dglLoadMatrixfcxx . . $ dglLoadMatrixf.(&trans[0][0]);
2169 }