DXGL r456 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r455‎ | r456 | r457 >
Date:23:29, 4 July 2014
Author:admin
Status:new
Tags:
Comment:
Convert glRenderer to a struct and make the functions C linkage.
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/ddraw.h (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -40,8 +40,12 @@
4141 void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7)
4242 {
4343 TRACE_ENTER(6,11,width,11,height,11,bpp,21,fullscreen,13,hWnd,14,glDD7);
44 - if(!glDD7->renderer) glDD7->renderer = new glRenderer(width,height,bpp,fullscreen,frequency,hWnd,glDD7);
45 - else glDD7->renderer->SetWnd(width,height,bpp,fullscreen,frequency,hWnd);
 44+ if (!glDD7->renderer)
 45+ {
 46+ glDD7->renderer = (glRenderer*)malloc(sizeof(glRenderer));
 47+ glRenderer_Init(glDD7->renderer,width,height,bpp,fullscreen,frequency,hWnd,glDD7);
 48+ }
 49+ else glRenderer_SetWnd(glDD7->renderer,width,height,bpp,fullscreen,frequency,hWnd);
4650 TRACE_EXIT(0,0);
4751 }
4852
Index: ddraw/ddraw.h
@@ -59,7 +59,7 @@
6060 extern DXGLCFG dxglcfg;
6161 extern DWORD gllock;
6262 extern const GUID device_template;
63 -class glRenderer;
 63+struct glRenderer;
6464 class glDirectDraw7;
6565 void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
6666
Index: ddraw/glDirect3DDevice.cpp
@@ -366,7 +366,7 @@
367367 d3ddesc3.dwMaxTextureRepeat = d3ddesc3.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
368368 scalex = scaley = 0;
369369 mhWorld = mhView = mhProjection = 0;
370 - renderer->InitD3D(zbuffer);
 370+ glRenderer_InitD3D(renderer,zbuffer);
371371 error = D3D_OK;
372372 TRACE_EXIT(-1,0);
373373 }
@@ -574,7 +574,7 @@
575575 TRACE_ENTER(7,14,this,8,dwCount,14,lpRects,9,dwFlags,9,dwColor,19,&dvZ,9,dwStencil);
576576 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
577577 if(dwCount && !lpRects) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
578 - TRACE_RET(HRESULT,23,renderer->Clear(glDDS7,dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil));
 578+ TRACE_RET(HRESULT,23,glRenderer_Clear(renderer,glDDS7,dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil));
579579 }
580580 HRESULT WINAPI glDirect3DDevice7::ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres,
581581 DWORD dwFlags, LPDWORD lpdwReturnValues)
@@ -802,7 +802,7 @@
803803 if(lpwIndices) AddStats(d3dptPrimitiveType,dwIndexCount,&stats);
804804 else AddStats(d3dptPrimitiveType,dwVertexCount,&stats);
805805 if(err != D3D_OK) TRACE_RET(HRESULT,23,err);
806 - TRACE_RET(HRESULT,23,renderer->DrawPrimitives(this,setdrawmode(d3dptPrimitiveType),vertdata,texformats,
 806+ TRACE_RET(HRESULT,23,glRenderer_DrawPrimitives(renderer,this,setdrawmode(d3dptPrimitiveType),vertdata,texformats,
807807 dwVertexCount,lpwIndices,dwIndexCount,dwFlags));
808808 }
809809 HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
@@ -854,7 +854,7 @@
855855 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
856856 if(!inscene) TRACE_RET(HRESULT,23,D3DERR_SCENE_NOT_IN_SCENE);
857857 inscene = false;
858 - renderer->Flush();
 858+ glRenderer_Flush(renderer);
859859 TRACE_EXIT(23,D3D_OK);
860860 return D3D_OK;
861861 }
Index: ddraw/glDirectDraw.cpp
@@ -629,7 +629,11 @@
630630 }
631631 free(surfaces);
632632 }
633 - if(renderer) delete renderer;
 633+ if(renderer)
 634+ {
 635+ glRenderer_Delete(renderer);
 636+ free(renderer);
 637+ }
634638 renderer = NULL;
635639 }
636640 TRACE_EXIT(-1,0);
@@ -1112,7 +1116,7 @@
11131117 if(!renderer) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
11141118 if(!primary) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
11151119 if(!initialized) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
1116 - *lpdwScanLine = renderer->GetScanLine();
 1120+ *lpdwScanLine = glRenderer_GetScanLine(renderer);
11171121 if(*lpdwScanLine >= primary->fakey) TRACE_RET(HRESULT,23,DDERR_VERTICALBLANKINPROGRESS);
11181122 TRACE_EXIT(23,DD_OK);
11191123 return DD_OK;
@@ -1125,7 +1129,7 @@
11261130 if(!renderer) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
11271131 if(!primary) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
11281132 if(!initialized) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
1129 - if(renderer->GetScanLine() >= primary->fakey) *lpbIsInVB = TRUE;
 1133+ if(glRenderer_GetScanLine(renderer) >= primary->fakey) *lpbIsInVB = TRUE;
11301134 else *lpbIsInVB = FALSE;
11311135 TRACE_EXIT(23,DD_OK);
11321136 return DD_OK;
Index: ddraw/glDirectDraw.h
@@ -24,7 +24,7 @@
2525 class glDirectDrawSurface7;
2626 struct glDirectDrawClipper;
2727 class glDirect3D7;
28 -class glRenderer;
 28+struct glRenderer;
2929
3030 class glDirectDraw1;
3131 class glDirectDraw2;
Index: ddraw/glDirectDrawSurface.cpp
@@ -140,7 +140,7 @@
141141 paltex->pixelformat.dwGBitMask = 0xFF00;
142142 paltex->pixelformat.dwRBitMask = 0xFF;
143143 paltex->pixelformat.dwRGBBitCount = 32;
144 - ddInterface->renderer->MakeTexture(paltex,256,1);
 144+ glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
145145 }
146146 else paltex = NULL;
147147 }
@@ -310,7 +310,7 @@
311311 else texture->minfilter = texture->magfilter = GL_NEAREST;
312312 }
313313 texture->wraps = texture->wrapt = GL_CLAMP_TO_EDGE;
314 - ddInterface->renderer->MakeTexture(texture,fakex,fakey);
 314+ glRenderer_MakeTexture(ddInterface->renderer,texture,fakex,fakey);
315315 }
316316
317317 if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
@@ -356,21 +356,21 @@
357357 if(dds4) dds4->Release();
358358 if(paltex)
359359 {
360 - ddInterface->renderer->DeleteTexture(paltex);
 360+ glRenderer_DeleteTexture(ddInterface->renderer, paltex);
361361 delete paltex;
362362 }
363363 if(texture)
364364 {
365 - ddInterface->renderer->DeleteTexture(texture);
 365+ glRenderer_DeleteTexture(ddInterface->renderer, texture);
366366 delete texture;
367367 }
368368 if(stencil)
369369 {
370 - ddInterface->renderer->DeleteTexture(stencil);
 370+ glRenderer_DeleteTexture(ddInterface->renderer, stencil);
371371 delete stencil;
372372 }
373 - if(fbo.fbo) ddInterface->renderer->DeleteFBO(&fbo);
374 - if(stencilfbo.fbo) ddInterface->renderer->DeleteFBO(&stencilfbo);
 373+ if(fbo.fbo) glRenderer_DeleteFBO(ddInterface->renderer, &fbo);
 374+ if(stencilfbo.fbo) glRenderer_DeleteFBO(ddInterface->renderer, &stencilfbo);
375375 if(bitmapinfo) free(bitmapinfo);
376376 if(palette) glDirectDrawPalette_Release(palette);
377377 if(backbuffer) backbuffer->Release();
@@ -615,7 +615,7 @@
616616 glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
617617 if(dirty & 1)
618618 {
619 - ddInterface->renderer->UploadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
 619+ glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
620620 fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
621621 ddsd.ddpfPixelFormat.dwRGBBitCount);
622622 dirty &= ~1;
@@ -622,7 +622,7 @@
623623 }
624624 if(src && (src->dirty & 1))
625625 {
626 - ddInterface->renderer->UploadTexture(src->buffer,src->bigbuffer,src->texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
 626+ glRenderer_UploadTexture(ddInterface->renderer,src->buffer,src->bigbuffer,src->texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
627627 src->fakex,src->fakey,src->ddsd.lPitch,
628628 (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
629629 src->ddsd.ddpfPixelFormat.dwRGBBitCount);
@@ -639,7 +639,7 @@
640640 if (error) TRACE_RET(HRESULT, 23, error);
641641 TRACE_RET(HRESULT,23,this->Blt(lpDestRect, ddInterface->tmpsurface, &tmprect, dwFlags, lpDDBltFx));
642642 }
643 - else TRACE_RET(HRESULT,23,ddInterface->renderer->Blt(lpDestRect,src,this,lpSrcRect,dwFlags,lpDDBltFx));
 643+ else TRACE_RET(HRESULT,23,glRenderer_Blt(ddInterface->renderer,lpDestRect,src,this,lpSrcRect,dwFlags,lpDDBltFx));
644644 }
645645 HRESULT WINAPI glDirectDrawSurface7::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
646646 {
@@ -769,7 +769,7 @@
770770 tmp = this;
771771 if(dirty & 1)
772772 {
773 - ddInterface->renderer->UploadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
 773+ glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
774774 fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
775775 ddsd.ddpfPixelFormat.dwRGBBitCount);
776776 dirty &= ~1;
@@ -780,7 +780,7 @@
781781 tmp = tmp->GetBackbuffer();
782782 if(tmp->dirty & 1)
783783 {
784 - ddInterface->renderer->UploadTexture(tmp->buffer,tmp->bigbuffer,tmp->texture,tmp->ddsd.dwWidth,tmp->ddsd.dwHeight,
 784+ glRenderer_UploadTexture(ddInterface->renderer,tmp->buffer,tmp->bigbuffer,tmp->texture,tmp->ddsd.dwWidth,tmp->ddsd.dwHeight,
785785 tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*tmp->fakex)),
786786 tmp->ddsd.ddpfPixelFormat.dwRGBBitCount);
787787 tmp->dirty &= ~1;
@@ -1034,7 +1034,7 @@
10351035 break;
10361036 case 0:
10371037 if(dirty & 2)
1038 - ddInterface->renderer->DownloadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
 1038+ glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
10391039 (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount);
10401040 ddsd.lpSurface = buffer;
10411041 dirty &= ~2;
@@ -1049,7 +1049,7 @@
10501050 if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
10511051 bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOfWord(fakex) * fakey)/8);
10521052 else bigbuffer = NULL;
1053 - ddInterface->renderer->DownloadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
 1053+ glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
10541054 (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount);
10551055 dirty &= ~2;
10561056 surfacetype = 0;
@@ -1113,8 +1113,8 @@
11141114 }
11151115 if(backbuffer) backbuffer->Restore2();
11161116 if(zbuffer) zbuffer->Restore2();
1117 - if(paltex) ddInterface->renderer->MakeTexture(paltex,256,1);
1118 - ddInterface->renderer->MakeTexture(texture,fakex,fakey);
 1117+ if(paltex) glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
 1118+ glRenderer_MakeTexture(ddInterface->renderer,texture,fakex,fakey);
11191119 }
11201120 TRACE_EXIT(0,0);
11211121 }
@@ -1159,8 +1159,8 @@
11601160 if(backbuffer) backbuffer->Restore();
11611161 if(zbuffer) zbuffer->Restore();
11621162 }
1163 - if(paltex) ddInterface->renderer->MakeTexture(paltex,256,1);
1164 - ddInterface->renderer->MakeTexture(texture,fakex,fakey);
 1163+ if(paltex) glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
 1164+ glRenderer_MakeTexture(ddInterface->renderer,texture,fakex,fakey);
11651165 TRACE_EXIT(23,DD_OK);
11661166 return DD_OK;
11671167 }
@@ -1293,7 +1293,7 @@
12941294 void glDirectDrawSurface7::RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface, int vsync)
12951295 {
12961296 TRACE_ENTER(3,14,this,14,texture,14,surface);
1297 - ddInterface->renderer->DrawScreen(texture,paltex,this,surface,vsync);
 1297+ glRenderer_DrawScreen(ddInterface->renderer,texture, paltex, this, surface, vsync);
12981298 TRACE_EXIT(0,0);
12991299 }
13001300 // ddraw 2+ api
Index: ddraw/glRenderer.cpp
@@ -31,6 +31,8 @@
3232 #include "ShaderGen3D.h"
3333 #include "matrix.h"
3434
 35+extern "C" {
 36+
3537 const GLushort bltindices[4] = {0,1,2,3};
3638
3739 /**
@@ -59,21 +61,25 @@
6062
6163 /**
6264 * Sets the Windows OpenGL swap interval
 65+ * @param This
 66+ * Pointer to glRenderer object
6367 * @param swap
6468 * Number of vertical retraces to wait per frame, 0 disable vsync
6569 */
66 -inline void glRenderer::_SetSwap(int swap)
 70+inline void glRenderer__SetSwap(glRenderer *This, int swap)
6771 {
68 - if(swap != oldswap)
 72+ if(swap != This->oldswap)
6973 {
70 - ext->wglSwapIntervalEXT(swap);
71 - oldswap = ext->wglGetSwapIntervalEXT();
72 - oldswap = swap;
 74+ This->ext->wglSwapIntervalEXT(swap);
 75+ This->oldswap = This->ext->wglGetSwapIntervalEXT();
 76+ This->oldswap = swap;
7377 }
7478 }
7579
7680 /**
7781 * Internal function for uploading surface content to an OpenGL texture
 82+ * @param This
 83+ * Pointer to glRenderer object
7884 * @param buffer
7985 * Contains the contents of the surface
8086 * @param bigbuffer
@@ -92,13 +98,13 @@
9399 * @param bpp
94100 * Number of bits per surface pixel
95101 */
96 -void glRenderer::_UploadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
 102+void glRenderer__UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
97103 int bigx, int bigy, int pitch, int bigpitch, int bpp)
98104 {
99105 if(bpp == 15) bpp = 16;
100106 if((x == bigx && y == bigy) || !bigbuffer)
101107 {
102 - TextureManager__UploadTexture(texman, texture, 0, buffer, x, y);
 108+ TextureManager__UploadTexture(This->texman, texture, 0, buffer, x, y);
103109 }
104110 else
105111 {
@@ -118,12 +124,14 @@
119125 break;
120126 break;
121127 }
122 - TextureManager__UploadTexture(texman,texture,0,bigbuffer,bigx,bigy);
 128+ TextureManager__UploadTexture(This->texman,texture,0,bigbuffer,bigx,bigy);
123129 }
124130 }
125131
126132 /**
127133 * Internal function for downloading surface content from an OpenGL texture
 134+ * @param This
 135+ * Pointer to glRenderer object
128136 * @param buffer
129137 * Buffer to receive the surface contents
130138 * @param bigbuffer
@@ -142,16 +150,16 @@
143151 * @param bpp
144152 * Number of bits per surface pixel
145153 */
146 -void glRenderer::_DownloadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
 154+void glRenderer__DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
147155 int bigx, int bigy, int pitch, int bigpitch, int bpp)
148156 {
149157 if((bigx == x && bigy == y) || !bigbuffer)
150158 {
151 - TextureManager__DownloadTexture(texman,texture,0,buffer);
 159+ TextureManager__DownloadTexture(This->texman,texture,0,buffer);
152160 }
153161 else
154162 {
155 - TextureManager__DownloadTexture(texman,texture,0,bigbuffer);
 163+ TextureManager__DownloadTexture(This->texman,texture,0,bigbuffer);
156164 switch(bpp)
157165 {
158166 case 8:
@@ -173,7 +181,9 @@
174182 }
175183
176184 /**
177 - * Constructor for the glRenderer object
 185+ * Initializes a glRenderer object
 186+ * @param This
 187+ * Pointer to glRenderer object to initialize
178188 * @param width,height,bpp
179189 * Width, height, and BPP of the rendering window
180190 * @param fullscreen
@@ -184,60 +194,62 @@
185195 * @param glDD7
186196 * Pointer to the glDirectDraw7 object that is managing the glRenderer object
187197 */
188 -glRenderer::glRenderer(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7)
 198+void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7)
189199 {
190 - oldswap = 0;
191 - fogcolor = 0;
192 - fogstart = 0.0f;
193 - fogend = 1.0f;
194 - fogdensity = 1.0f;
195 - backbuffer = NULL;
196 - hDC = NULL;
197 - hRC = NULL;
198 - PBO = 0;
199 - dib.enabled = false;
200 - hWnd = hwnd;
201 - InitializeCriticalSection(&cs);
202 - busy = CreateEvent(NULL,FALSE,FALSE,NULL);
203 - start = CreateEvent(NULL,FALSE,FALSE,NULL);
 200+ This->oldswap = 0;
 201+ This->fogcolor = 0;
 202+ This->fogstart = 0.0f;
 203+ This->fogend = 1.0f;
 204+ This->fogdensity = 1.0f;
 205+ This->backbuffer = NULL;
 206+ This->hDC = NULL;
 207+ This->hRC = NULL;
 208+ This->PBO = 0;
 209+ This->dib.enabled = false;
 210+ This->hWnd = hwnd;
 211+ InitializeCriticalSection(&This->cs);
 212+ This->busy = CreateEvent(NULL,FALSE,FALSE,NULL);
 213+ This->start = CreateEvent(NULL,FALSE,FALSE,NULL);
204214 if(fullscreen)
205215 {
206 - SetWindowLongPtrA(hWnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
207 - SetWindowLongPtrA(hWnd,GWL_STYLE,WS_OVERLAPPED);
208 - ShowWindow(hWnd,SW_MAXIMIZE);
 216+ SetWindowLongPtrA(This->hWnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
 217+ SetWindowLongPtrA(This->hWnd,GWL_STYLE,WS_OVERLAPPED);
 218+ ShowWindow(This->hWnd,SW_MAXIMIZE);
209219 }
210220 if(width)
211221 {
212222 // TODO: Adjust window rect
213223 }
214 - SetWindowPos(hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
215 - RenderWnd = new glRenderWindow(width,height,fullscreen,hWnd,glDD7);
216 - inputs[0] = (void*)width;
217 - inputs[1] = (void*)height;
218 - inputs[2] = (void*)bpp;
219 - inputs[3] = (void*)fullscreen;
220 - inputs[4] = (void*)frequency;
221 - inputs[5] = (void*)hWnd;
222 - inputs[6] = glDD7;
223 - inputs[7] = this;
224 - hThread = CreateThread(NULL,0,ThreadEntry,inputs,0,NULL);
225 - WaitForSingleObject(busy,INFINITE);
 224+ SetWindowPos(This->hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
 225+ This->RenderWnd = new glRenderWindow(width,height,fullscreen,This->hWnd,glDD7);
 226+ This->inputs[0] = (void*)width;
 227+ This->inputs[1] = (void*)height;
 228+ This->inputs[2] = (void*)bpp;
 229+ This->inputs[3] = (void*)fullscreen;
 230+ This->inputs[4] = (void*)frequency;
 231+ This->inputs[5] = (void*)This->hWnd;
 232+ This->inputs[6] = glDD7;
 233+ This->inputs[7] = This;
 234+ This->hThread = CreateThread(NULL, 0, glRenderer_ThreadEntry, This->inputs, 0, NULL);
 235+ WaitForSingleObject(This->busy,INFINITE);
226236 }
227237
228238 /**
229 - * Destructor for the glRenderer object
 239+ * Deletes a glRenderer object
 240+ * @param This
 241+ * Pointer to glRenderer object
230242 */
231 -glRenderer::~glRenderer()
 243+void glRenderer_Delete(glRenderer *This)
232244 {
233 - EnterCriticalSection(&cs);
234 - opcode = OP_DELETE;
235 - SetEvent(start);
236 - WaitForObjectAndMessages(busy);
237 - CloseHandle(start);
238 - CloseHandle(busy);
239 - LeaveCriticalSection(&cs);
240 - DeleteCriticalSection(&cs);
241 - CloseHandle(hThread);
 245+ EnterCriticalSection(&This->cs);
 246+ This->opcode = OP_DELETE;
 247+ SetEvent(This->start);
 248+ WaitForObjectAndMessages(This->busy);
 249+ CloseHandle(This->start);
 250+ CloseHandle(This->busy);
 251+ LeaveCriticalSection(&This->cs);
 252+ DeleteCriticalSection(&This->cs);
 253+ CloseHandle(This->hThread);
242254 }
243255
244256 /**
@@ -245,15 +257,17 @@
246258 * @param entry
247259 * Pointer to the inputs passed by the CreateThread function
248260 */
249 -DWORD WINAPI glRenderer::ThreadEntry(void *entry)
 261+DWORD WINAPI glRenderer_ThreadEntry(void *entry)
250262 {
251263 void **inputsin = (void**)entry;
252264 glRenderer *This = (glRenderer*)inputsin[7];
253 - return This->_Entry();
 265+ return glRenderer__Entry(This);
254266 }
255267
256268 /**
257269 * Creates an OpenGL texture.
 270+ * @param This
 271+ * Pointer to glRenderer object
258272 * @param min,mag
259273 * Minification and magnification filters for the OpenGL texture
260274 * @param wraps,wrapt
@@ -269,20 +283,22 @@
270284 * @return
271285 * Number representing the texture created by OpenGL.
272286 */
273 -void glRenderer::MakeTexture(TEXTURE *texture, DWORD width, DWORD height)
 287+void glRenderer_MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height)
274288 {
275 - EnterCriticalSection(&cs);
276 - inputs[0] = texture;
277 - inputs[1] = (void*)width;
278 - inputs[2] = (void*)height;
279 - opcode = OP_CREATE;
280 - SetEvent(start);
281 - WaitForSingleObject(busy,INFINITE);
282 - LeaveCriticalSection(&cs);
 289+ EnterCriticalSection(&This->cs);
 290+ This->inputs[0] = texture;
 291+ This->inputs[1] = (void*)width;
 292+ This->inputs[2] = (void*)height;
 293+ This->opcode = OP_CREATE;
 294+ SetEvent(This->start);
 295+ WaitForSingleObject(This->busy,INFINITE);
 296+ LeaveCriticalSection(&This->cs);
283297 }
284298
285299 /**
286300 * Uploads the content of a surface to an OpenGL texture.
 301+ * @param This
 302+ * Pointer to glRenderer object
287303 * @param buffer
288304 * Contains the contents of the surface
289305 * @param bigbuffer
@@ -301,28 +317,30 @@
302318 * @param bpp
303319 * Number of bits per surface pixel
304320 */
305 -void glRenderer::UploadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
 321+void glRenderer_UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
306322 int bigx, int bigy, int pitch, int bigpitch, int bpp)
307323 {
308 - EnterCriticalSection(&cs);
309 - inputs[0] = buffer;
310 - inputs[1] = bigbuffer;
311 - inputs[2] = texture;
312 - inputs[3] = (void*)x;
313 - inputs[4] = (void*)y;
314 - inputs[5] = (void*)bigx;
315 - inputs[6] = (void*)bigy;
316 - inputs[7] = (void*)pitch;
317 - inputs[8] = (void*)bigpitch;
318 - inputs[9] = (void*)bpp;
319 - opcode = OP_UPLOAD;
320 - SetEvent(start);
321 - WaitForSingleObject(busy,INFINITE);
322 - LeaveCriticalSection(&cs);
 324+ EnterCriticalSection(&This->cs);
 325+ This->inputs[0] = buffer;
 326+ This->inputs[1] = bigbuffer;
 327+ This->inputs[2] = texture;
 328+ This->inputs[3] = (void*)x;
 329+ This->inputs[4] = (void*)y;
 330+ This->inputs[5] = (void*)bigx;
 331+ This->inputs[6] = (void*)bigy;
 332+ This->inputs[7] = (void*)pitch;
 333+ This->inputs[8] = (void*)bigpitch;
 334+ This->inputs[9] = (void*)bpp;
 335+ This->opcode = OP_UPLOAD;
 336+ SetEvent(This->start);
 337+ WaitForSingleObject(This->busy,INFINITE);
 338+ LeaveCriticalSection(&This->cs);
323339 }
324340
325341 /**
326342 * Downloads the contents of an OpenGL texture to a surface buffer.
 343+ * @param This
 344+ * Pointer to glRenderer object
327345 * @param buffer
328346 * Buffer to receive the surface contents
329347 * @param bigbuffer
@@ -341,43 +359,47 @@
342360 * @param bpp
343361 * Number of bits per surface pixel
344362 */
345 -void glRenderer::DownloadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
 363+void glRenderer_DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
346364 int bigx, int bigy, int pitch, int bigpitch, int bpp)
347365 {
348 - EnterCriticalSection(&cs);
349 - inputs[0] = buffer;
350 - inputs[1] = bigbuffer;
351 - inputs[2] = texture;
352 - inputs[3] = (void*)x;
353 - inputs[4] = (void*)y;
354 - inputs[5] = (void*)bigx;
355 - inputs[6] = (void*)bigy;
356 - inputs[7] = (void*)pitch;
357 - inputs[8] = (void*)bigpitch;
358 - inputs[9] = (void*)bpp;
359 - opcode = OP_DOWNLOAD;
360 - SetEvent(start);
361 - WaitForSingleObject(busy,INFINITE);
362 - LeaveCriticalSection(&cs);
 366+ EnterCriticalSection(&This->cs);
 367+ This->inputs[0] = buffer;
 368+ This->inputs[1] = bigbuffer;
 369+ This->inputs[2] = texture;
 370+ This->inputs[3] = (void*)x;
 371+ This->inputs[4] = (void*)y;
 372+ This->inputs[5] = (void*)bigx;
 373+ This->inputs[6] = (void*)bigy;
 374+ This->inputs[7] = (void*)pitch;
 375+ This->inputs[8] = (void*)bigpitch;
 376+ This->inputs[9] = (void*)bpp;
 377+ This->opcode = OP_DOWNLOAD;
 378+ SetEvent(This->start);
 379+ WaitForSingleObject(This->busy,INFINITE);
 380+ LeaveCriticalSection(&This->cs);
363381 }
364382
365383 /**
366384 * Deletes an OpenGL texture.
 385+ * @param This
 386+ * Pointer to glRenderer object
367387 * @param texture
368388 * OpenGL texture to be deleted
369389 */
370 -void glRenderer::DeleteTexture(TEXTURE * texture)
 390+void glRenderer_DeleteTexture(glRenderer *This, TEXTURE * texture)
371391 {
372 - EnterCriticalSection(&cs);
373 - inputs[0] = texture;
374 - opcode = OP_DELETETEX;
375 - SetEvent(start);
376 - WaitForSingleObject(busy,INFINITE);
377 - LeaveCriticalSection(&cs);
 392+ EnterCriticalSection(&This->cs);
 393+ This->inputs[0] = texture;
 394+ This->opcode = OP_DELETETEX;
 395+ SetEvent(This->start);
 396+ WaitForSingleObject(This->busy,INFINITE);
 397+ LeaveCriticalSection(&This->cs);
378398 }
379399
380400 /**
381401 * Copies the contents of one surface to another.
 402+ * @param This
 403+ * Pointer to glRenderer object
382404 * @param lpDestRect
383405 * Pointer to the coordinates to blit to. If NULL, blits to the entire surface.
384406 * @param src
@@ -399,10 +421,10 @@
400422 * @return
401423 * DD_OK if the call succeeds, or DDERR_WASSTILLDRAWING if busy.
402424 */
403 -HRESULT glRenderer::Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
 425+HRESULT glRenderer_Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
404426 glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
405427 {
406 - EnterCriticalSection(&cs);
 428+ EnterCriticalSection(&This->cs);
407429 RECT r,r2;
408430 if(((dest->ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
409431 (dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
@@ -409,26 +431,28 @@
410432 ((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
411433 !(dest->ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
412434 {
413 - GetClientRect(hWnd,&r);
414 - GetClientRect(RenderWnd->GetHWnd(),&r2);
 435+ GetClientRect(This->hWnd,&r);
 436+ GetClientRect(This->RenderWnd->GetHWnd(),&r2);
415437 if(memcmp(&r2,&r,sizeof(RECT)))
416 - SetWindowPos(RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
 438+ SetWindowPos(This->RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
417439 }
418 - inputs[0] = lpDestRect;
419 - inputs[1] = src;
420 - inputs[2] = dest;
421 - inputs[3] = lpSrcRect;
422 - inputs[4] = (void*)dwFlags;
423 - inputs[5] = lpDDBltFx;
424 - opcode = OP_BLT;
425 - SetEvent(start);
426 - WaitForSingleObject(busy,INFINITE);
427 - LeaveCriticalSection(&cs);
428 - return (HRESULT)outputs[0];
 440+ This->inputs[0] = lpDestRect;
 441+ This->inputs[1] = src;
 442+ This->inputs[2] = dest;
 443+ This->inputs[3] = lpSrcRect;
 444+ This->inputs[4] = (void*)dwFlags;
 445+ This->inputs[5] = lpDDBltFx;
 446+ This->opcode = OP_BLT;
 447+ SetEvent(This->start);
 448+ WaitForSingleObject(This->busy,INFINITE);
 449+ LeaveCriticalSection(&This->cs);
 450+ return (HRESULT)This->outputs[0];
429451 }
430452
431453 /**
432454 * Updates the display with the current primary texture.
 455+ * @param This
 456+ * Pointer to glRenderer object
433457 * @param texture
434458 * Texture to use as the primary
435459 * @param paltex
@@ -440,36 +464,40 @@
441465 * @param vsync
442466 * Vertical sync count
443467 */
444 -void glRenderer::DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync)
 468+void glRenderer_DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync)
445469 {
446 - EnterCriticalSection(&cs);
447 - inputs[0] = texture;
448 - inputs[1] = paltex;
449 - inputs[2] = dest;
450 - inputs[3] = src;
451 - inputs[4] = (void*)vsync;
452 - opcode = OP_DRAWSCREEN;
453 - SetEvent(start);
454 - WaitForSingleObject(busy,INFINITE);
455 - LeaveCriticalSection(&cs);
 470+ EnterCriticalSection(&This->cs);
 471+ This->inputs[0] = texture;
 472+ This->inputs[1] = paltex;
 473+ This->inputs[2] = dest;
 474+ This->inputs[3] = src;
 475+ This->inputs[4] = (void*)vsync;
 476+ This->opcode = OP_DRAWSCREEN;
 477+ SetEvent(This->start);
 478+ WaitForSingleObject(This->busy,INFINITE);
 479+ LeaveCriticalSection(&This->cs);
456480 }
457481
458482 /**
459483 * Ensures the renderer is set up for handling Direct3D commands.
 484+ * @param This
 485+ * Pointer to glRenderer object
460486 * @param zbuffer
461487 * Nonzero if a Z buffer is present.
462488 */
463 -void glRenderer::InitD3D(int zbuffer)
 489+void glRenderer_InitD3D(glRenderer *This, int zbuffer)
464490 {
465 - EnterCriticalSection(&cs);
466 - opcode = OP_INITD3D;
467 - SetEvent(start);
468 - WaitForSingleObject(busy,INFINITE);
469 - LeaveCriticalSection(&cs);
 491+ EnterCriticalSection(&This->cs);
 492+ This->opcode = OP_INITD3D;
 493+ SetEvent(This->start);
 494+ WaitForSingleObject(This->busy,INFINITE);
 495+ LeaveCriticalSection(&This->cs);
470496 }
471497
472498 /**
473499 * Clears the viewport.
 500+ * @param This
 501+ * Pointer to glRenderer object
474502 * @param target
475503 * Surface to be cleared
476504 * @param dwCount
@@ -487,37 +515,41 @@
488516 * @return
489517 * Returns D3D_OK
490518 */
491 -HRESULT glRenderer::Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
 519+HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
492520 {
493 - EnterCriticalSection(&cs);
494 - inputs[0] = target;
495 - inputs[1] = (void*)dwCount;
496 - inputs[2] = lpRects;
497 - inputs[3] = (void*)dwFlags;
498 - inputs[4] = (void*)dwColor;
499 - memcpy(&inputs[5],&dvZ,4);
500 - inputs[6] = (void*)dwStencil;
501 - opcode = OP_CLEAR;
502 - SetEvent(start);
503 - WaitForSingleObject(busy,INFINITE);
504 - LeaveCriticalSection(&cs);
505 - return (HRESULT)outputs[0];
 521+ EnterCriticalSection(&This->cs);
 522+ This->inputs[0] = target;
 523+ This->inputs[1] = (void*)dwCount;
 524+ This->inputs[2] = lpRects;
 525+ This->inputs[3] = (void*)dwFlags;
 526+ This->inputs[4] = (void*)dwColor;
 527+ memcpy(&This->inputs[5],&dvZ,4);
 528+ This->inputs[6] = (void*)dwStencil;
 529+ This->opcode = OP_CLEAR;
 530+ SetEvent(This->start);
 531+ WaitForSingleObject(This->busy,INFINITE);
 532+ LeaveCriticalSection(&This->cs);
 533+ return (HRESULT)This->outputs[0];
506534 }
507535
508536 /**
509537 * Instructs the OpenGL driver to send all queued commands to the GPU.
 538+ * @param This
 539+ * Pointer to glRenderer object
510540 */
511 -void glRenderer::Flush()
 541+void glRenderer_Flush(glRenderer *This)
512542 {
513 - EnterCriticalSection(&cs);
514 - opcode = OP_FLUSH;
515 - SetEvent(start);
516 - WaitForSingleObject(busy,INFINITE);
517 - LeaveCriticalSection(&cs);
 543+ EnterCriticalSection(&This->cs);
 544+ This->opcode = OP_FLUSH;
 545+ SetEvent(This->start);
 546+ WaitForSingleObject(This->busy,INFINITE);
 547+ LeaveCriticalSection(&This->cs);
518548 }
519549
520550 /**
521551 * Changes the window used for rendering.
 552+ * @param This
 553+ * Pointer to glRenderer object
522554 * @param width,height
523555 * Width and height of the new window.
524556 * @param fullscreen
@@ -525,9 +557,9 @@
526558 * @param newwnd
527559 * HWND of the new window
528560 */
529 -void glRenderer::SetWnd(int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd)
 561+void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd)
530562 {
531 - EnterCriticalSection(&cs);
 563+ EnterCriticalSection(&This->cs);
532564 if(fullscreen && newwnd)
533565 {
534566 SetWindowLongPtrA(newwnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
@@ -534,19 +566,21 @@
535567 SetWindowLongPtrA(newwnd,GWL_STYLE,WS_OVERLAPPED);
536568 ShowWindow(newwnd,SW_MAXIMIZE);
537569 }
538 - inputs[0] = (void*)width;
539 - inputs[1] = (void*)height;
540 - inputs[2] = (void*)bpp;
541 - inputs[3] = (void*)fullscreen;
542 - inputs[4] = (void*)frequency;
543 - inputs[5] = (void*)newwnd;
544 - opcode = OP_SETWND;
545 - SetEvent(start);
546 - WaitForObjectAndMessages(busy);
547 - LeaveCriticalSection(&cs);
 570+ This->inputs[0] = (void*)width;
 571+ This->inputs[1] = (void*)height;
 572+ This->inputs[2] = (void*)bpp;
 573+ This->inputs[3] = (void*)fullscreen;
 574+ This->inputs[4] = (void*)frequency;
 575+ This->inputs[5] = (void*)newwnd;
 576+ This->opcode = OP_SETWND;
 577+ SetEvent(This->start);
 578+ WaitForObjectAndMessages(This->busy);
 579+ LeaveCriticalSection(&This->cs);
548580 }
549581 /**
550582 * Draws one or more primitives to the currently selected render target.
 583+ * @param This
 584+ * Pointer to glRenderer object
551585 * @param device
552586 * glDirect3DDevice7 interface to use for drawing
553587 * @param mode
@@ -571,147 +605,163 @@
572606 * D3D_OK if the call succeeds, or D3DERR_INVALIDVERTEXTYPE if the vertex format
573607 * has no position coordinates.
574608 */
575 -HRESULT glRenderer::DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
 609+HRESULT glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
576610 DWORD indexcount, DWORD flags)
577611 {
578 - EnterCriticalSection(&cs);
579 - inputs[0] = device;
580 - inputs[1] = (void*)mode;
581 - inputs[2] = vertices;
582 - inputs[3] = texformats;
583 - inputs[4] = (void*)count;
584 - inputs[5] = indices;
585 - inputs[6] = (void*)indexcount;
586 - inputs[7] = (void*)flags;
587 - opcode = OP_DRAWPRIMITIVES;
588 - SetEvent(start);
589 - WaitForSingleObject(busy,INFINITE);
590 - LeaveCriticalSection(&cs);
591 - return (HRESULT)outputs[0];
 612+ EnterCriticalSection(&This->cs);
 613+ This->inputs[0] = device;
 614+ This->inputs[1] = (void*)mode;
 615+ This->inputs[2] = vertices;
 616+ This->inputs[3] = texformats;
 617+ This->inputs[4] = (void*)count;
 618+ This->inputs[5] = indices;
 619+ This->inputs[6] = (void*)indexcount;
 620+ This->inputs[7] = (void*)flags;
 621+ This->opcode = OP_DRAWPRIMITIVES;
 622+ SetEvent(This->start);
 623+ WaitForSingleObject(This->busy,INFINITE);
 624+ LeaveCriticalSection(&This->cs);
 625+ return (HRESULT)This->outputs[0];
592626 }
593627
594628 /**
595629 * Deletes a framebuffer object.
 630+ * @param This
 631+ * Pointer to glRenderer object
596632 * @param fbo
597633 * FBO Structure containing framebuffer to delete.
598634 */
599 -void glRenderer::DeleteFBO(FBO *fbo)
 635+void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo)
600636 {
601 - EnterCriticalSection(&cs);
602 - inputs[0] = fbo;
603 - opcode = OP_DELETEFBO;
604 - SetEvent(start);
605 - WaitForSingleObject(busy,INFINITE);
606 - LeaveCriticalSection(&cs);
 637+ EnterCriticalSection(&This->cs);
 638+ This->inputs[0] = fbo;
 639+ This->opcode = OP_DELETEFBO;
 640+ SetEvent(This->start);
 641+ WaitForSingleObject(This->busy,INFINITE);
 642+ LeaveCriticalSection(&This->cs);
607643 }
608644
609 -unsigned int glRenderer::GetScanLine()
 645+/**
 646+ * Gets an estimate of the scanline currently being drawn.
 647+ * @param This
 648+ * Pointer to glRenderer object
 649+ */
 650+unsigned int glRenderer_GetScanLine(glRenderer *This)
610651 {
611 - return timer.GetScanLine();
 652+ return This->timer.GetScanLine();
612653 }
613654
614655 /**
615656 * Main loop for glRenderer class
 657+ * @param This
 658+ * Pointer to glRenderer object
616659 * @return
617660 * Returns 0 to signal successful thread termination
618661 */
619 -DWORD glRenderer::_Entry()
 662+DWORD glRenderer__Entry(glRenderer *This)
620663 {
621664 float tmpfloats[16];
622 - EnterCriticalSection(&cs);
623 - _InitGL((int)inputs[0],(int)inputs[1],(int)inputs[2],(int)inputs[3],(unsigned int)inputs[4],(HWND)inputs[5],(glDirectDraw7*)inputs[6]);
624 - LeaveCriticalSection(&cs);
625 - SetEvent(busy);
 665+ EnterCriticalSection(&This->cs);
 666+ glRenderer__InitGL(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2],
 667+ (int)This->inputs[3],(unsigned int)This->inputs[4],(HWND)This->inputs[5],
 668+ (glDirectDraw7*)This->inputs[6]);
 669+ LeaveCriticalSection(&This->cs);
 670+ SetEvent(This->busy);
626671 while(1)
627672 {
628 - WaitForSingleObject(start,INFINITE);
629 - switch(opcode)
 673+ WaitForSingleObject(This->start,INFINITE);
 674+ switch(This->opcode)
630675 {
631676 case OP_DELETE:
632 - if(hRC)
 677+ if(This->hRC)
633678 {
634 - if(dib.enabled)
 679+ if(This->dib.enabled)
635680 {
636 - if(dib.hbitmap) DeleteObject(dib.hbitmap);
637 - if(dib.hdc) DeleteDC(dib.hdc);
638 - ZeroMemory(&dib,sizeof(DIB));
 681+ if(This->dib.hbitmap) DeleteObject(This->dib.hbitmap);
 682+ if(This->dib.hdc) DeleteDC(This->dib.hdc);
 683+ ZeroMemory(&This->dib,sizeof(DIB));
639684 }
640 - TextureManager_DeleteSamplers(texman);
641 - util->DeleteFBO(&fbo);
642 - if(PBO)
 685+ TextureManager_DeleteSamplers(This->texman);
 686+ This->util->DeleteFBO(&This->fbo);
 687+ if(This->PBO)
643688 {
644 - ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
645 - ext->glDeleteBuffers(1,&PBO);
646 - PBO = 0;
 689+ This->ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
 690+ This->ext->glDeleteBuffers(1,&This->PBO);
 691+ This->PBO = 0;
647692 }
648 - if(backbuffer)
 693+ if(This->backbuffer)
649694 {
650 - TextureManager__DeleteTexture(texman,backbuffer);
651 - delete backbuffer;
652 - backbuffer = NULL;
653 - backx = 0;
654 - backy = 0;
 695+ TextureManager__DeleteTexture(This->texman,This->backbuffer);
 696+ free(This->backbuffer);
 697+ This->backbuffer = NULL;
 698+ This->backx = 0;
 699+ This->backy = 0;
655700 }
656 - delete shaders;
657 - free(texman);
658 - free(ext);
659 - delete util;
660 - ext = NULL;
 701+ delete This->shaders;
 702+ free(This->texman);
 703+ free(This->ext);
 704+ delete This->util;
 705+ This->ext = NULL;
661706 wglMakeCurrent(NULL,NULL);
662 - wglDeleteContext(hRC);
663 - hRC = NULL;
 707+ wglDeleteContext(This->hRC);
 708+ This->hRC = NULL;
664709 };
665 - if(hDC) ReleaseDC(RenderWnd->GetHWnd(),hDC);
666 - hDC = NULL;
667 - delete RenderWnd;
668 - RenderWnd = NULL;
669 - SetEvent(busy);
 710+ if(This->hDC) ReleaseDC(This->RenderWnd->GetHWnd(),This->hDC);
 711+ This->hDC = NULL;
 712+ delete This->RenderWnd;
 713+ This->RenderWnd = NULL;
 714+ SetEvent(This->busy);
670715 return 0;
671716 break;
672717 case OP_SETWND:
673 - _SetWnd((int)inputs[0],(int)inputs[1],(int)inputs[2],(int)inputs[3],(unsigned int)inputs[4],(HWND)inputs[5]);
 718+ glRenderer__SetWnd(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2],
 719+ (int)This->inputs[3],(unsigned int)This->inputs[4],(HWND)This->inputs[5]);
674720 break;
675721 case OP_CREATE:
676 - _MakeTexture((TEXTURE*)inputs[0],(DWORD)inputs[1],(DWORD)inputs[2]);
677 - SetEvent(busy);
 722+ glRenderer__MakeTexture(This,(TEXTURE*)This->inputs[0],(DWORD)This->inputs[1],(DWORD)This->inputs[2]);
 723+ SetEvent(This->busy);
678724 break;
679725 case OP_UPLOAD:
680 - _UploadTexture((char*)inputs[0],(char*)inputs[1],(TEXTURE*)inputs[2],(int)inputs[3],
681 - (int)inputs[4],(int)inputs[5],(int)inputs[6],(int)inputs[7],(int)inputs[8],(int)inputs[9]);
682 - SetEvent(busy);
 726+ glRenderer__UploadTexture(This,(char*)This->inputs[0],(char*)This->inputs[1],(TEXTURE*)This->inputs[2],
 727+ (int)This->inputs[3],(int)This->inputs[4],(int)This->inputs[5],(int)This->inputs[6],
 728+ (int)This->inputs[7],(int)This->inputs[8],(int)This->inputs[9]);
 729+ SetEvent(This->busy);
683730 break;
684731 case OP_DOWNLOAD:
685 - _DownloadTexture((char*)inputs[0],(char*)inputs[1],(TEXTURE*)inputs[2],(int)inputs[3],
686 - (int)inputs[4],(int)inputs[5],(int)inputs[6],(int)inputs[7],(int)inputs[8],(int)inputs[9]);
687 - SetEvent(busy);
 732+ glRenderer__DownloadTexture(This,(char*)This->inputs[0],(char*)This->inputs[1],(TEXTURE*)This->inputs[2],
 733+ (int)This->inputs[3],(int)This->inputs[4],(int)This->inputs[5],(int)This->inputs[6],
 734+ (int)This->inputs[7],(int)This->inputs[8],(int)This->inputs[9]);
 735+ SetEvent(This->busy);
688736 break;
689737 case OP_DELETETEX:
690 - _DeleteTexture((TEXTURE*)inputs[0]);
 738+ glRenderer__DeleteTexture(This,(TEXTURE*)This->inputs[0]);
691739 break;
692740 case OP_BLT:
693 - _Blt((LPRECT)inputs[0],(glDirectDrawSurface7*)inputs[1],(glDirectDrawSurface7*)inputs[2],
694 - (LPRECT)inputs[3],(DWORD)inputs[4],(LPDDBLTFX)inputs[5]);
 741+ glRenderer__Blt(This,(LPRECT)This->inputs[0],(glDirectDrawSurface7*)This->inputs[1],
 742+ (glDirectDrawSurface7*)This->inputs[2],(LPRECT)This->inputs[3],(DWORD)This->inputs[4],(LPDDBLTFX)This->inputs[5]);
695743 break;
696744 case OP_DRAWSCREEN:
697 - _DrawScreen((TEXTURE*)inputs[0],(TEXTURE*)inputs[1],(glDirectDrawSurface7*)inputs[2],(glDirectDrawSurface7*)inputs[3],(GLint)inputs[4],true);
 745+ glRenderer__DrawScreen(This,(TEXTURE*)This->inputs[0],(TEXTURE*)This->inputs[1],
 746+ (glDirectDrawSurface7*)This->inputs[2],(glDirectDrawSurface7*)This->inputs[3],(GLint)This->inputs[4],true);
698747 break;
699748 case OP_INITD3D:
700 - _InitD3D((int)inputs[0]);
 749+ glRenderer__InitD3D(This,(int)This->inputs[0]);
701750 break;
702751 case OP_CLEAR:
703 - memcpy(&tmpfloats[0],&inputs[5],4);
704 - _Clear((glDirectDrawSurface7*)inputs[0],(DWORD)inputs[1],(LPD3DRECT)inputs[2],(DWORD)inputs[3],(DWORD)inputs[4],
705 - tmpfloats[0],(DWORD)inputs[6]);
 752+ memcpy(&tmpfloats[0],&This->inputs[5],4);
 753+ glRenderer__Clear(This,(glDirectDrawSurface7*)This->inputs[0],(DWORD)This->inputs[1],
 754+ (LPD3DRECT)This->inputs[2],(DWORD)This->inputs[3],(DWORD)This->inputs[4],tmpfloats[0],(DWORD)This->inputs[6]);
706755 break;
707756 case OP_FLUSH:
708 - _Flush();
 757+ glRenderer__Flush(This);
709758 break;
710759 case OP_DRAWPRIMITIVES:
711 - _DrawPrimitives((glDirect3DDevice7*)inputs[0],(GLenum)inputs[1],(GLVERTEX*)inputs[2],(int*)inputs[3],(DWORD)inputs[4],
712 - (LPWORD)inputs[5],(DWORD)inputs[6],(DWORD)inputs[7]);
 760+ glRenderer__DrawPrimitives(This,(glDirect3DDevice7*)This->inputs[0],(GLenum)This->inputs[1],
 761+ (GLVERTEX*)This->inputs[2],(int*)This->inputs[3],(DWORD)This->inputs[4],(LPWORD)This->inputs[5],
 762+ (DWORD)This->inputs[6],(DWORD)This->inputs[7]);
713763 break;
714764 case OP_DELETEFBO:
715 - _DeleteFBO((FBO*)inputs[0]);
 765+ glRenderer__DeleteFBO(This,(FBO*)This->inputs[0]);
716766 break;
717767 }
718768 }
@@ -720,6 +770,8 @@
721771
722772 /**
723773 * Creates a render window and initializes OpenGL.
 774+ * @param This
 775+ * Pointer to glRenderer object
724776 * @param width,height
725777 * Width and height of the render window.
726778 * @param bpp
@@ -734,14 +786,14 @@
735787 * @return
736788 * TRUE if OpenGL has been initialized, FALSE otherwise.
737789 */
738 -BOOL glRenderer::_InitGL(int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7)
 790+BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7)
739791 {
740792 EnterCriticalSection(&dll_cs);
741 - ddInterface = glDD7;
742 - if(hRC)
 793+ This->ddInterface = glDD7;
 794+ if(This->hRC)
743795 {
744796 wglMakeCurrent(NULL,NULL);
745 - wglDeleteContext(hRC);
 797+ wglDeleteContext(This->hRC);
746798 };
747799 PIXELFORMATDESCRIPTOR pfd;
748800 GLuint pf;
@@ -753,8 +805,8 @@
754806 pfd.cColorBits = bpp;
755807 pfd.iLayerType = PFD_MAIN_PLANE;
756808 InterlockedIncrement(&gllock);
757 - hDC = GetDC(RenderWnd->GetHWnd());
758 - if(!hDC)
 809+ This->hDC = GetDC(This->RenderWnd->GetHWnd());
 810+ if(!This->hDC)
759811 {
760812 DEBUG("glRenderer::InitGL: Can not create hDC\n");
761813 InterlockedDecrement(&gllock);
@@ -761,7 +813,7 @@
762814 LeaveCriticalSection(&dll_cs);
763815 return FALSE;
764816 }
765 - pf = ChoosePixelFormat(hDC,&pfd);
 817+ pf = ChoosePixelFormat(This->hDC,&pfd);
766818 if(!pf)
767819 {
768820 DEBUG("glRenderer::InitGL: Can not get pixelformat\n");
@@ -769,10 +821,10 @@
770822 LeaveCriticalSection(&dll_cs);
771823 return FALSE;
772824 }
773 - if(!SetPixelFormat(hDC,pf,&pfd))
 825+ if(!SetPixelFormat(This->hDC,pf,&pfd))
774826 DEBUG("glRenderer::InitGL: Can not set pixelformat\n");
775 - hRC = wglCreateContext(hDC);
776 - if(!hRC)
 827+ This->hRC = wglCreateContext(This->hDC);
 828+ if(!This->hRC)
777829 {
778830 DEBUG("glRenderer::InitGL: Can not create GL context\n");
779831 InterlockedDecrement(&gllock);
@@ -779,13 +831,13 @@
780832 LeaveCriticalSection(&dll_cs);
781833 return FALSE;
782834 }
783 - if(!wglMakeCurrent(hDC,hRC))
 835+ if(!wglMakeCurrent(This->hDC,This->hRC))
784836 {
785837 DEBUG("glRenderer::InitGL: Can not activate GL context\n");
786 - wglDeleteContext(hRC);
787 - hRC = NULL;
788 - ReleaseDC(RenderWnd->GetHWnd(),hDC);
789 - hDC = NULL;
 838+ wglDeleteContext(This->hRC);
 839+ This->hRC = NULL;
 840+ ReleaseDC(This->RenderWnd->GetHWnd(),This->hDC);
 841+ This->hDC = NULL;
790842 InterlockedDecrement(&gllock);
791843 LeaveCriticalSection(&dll_cs);
792844 return FALSE;
@@ -792,99 +844,100 @@
793845 }
794846 InterlockedDecrement(&gllock);
795847 LeaveCriticalSection(&dll_cs);
796 - ext = (glExtensions *)malloc(sizeof(glExtensions));
797 - glExtensions_Init(ext);
798 - util = new glUtil(ext);
799 - _SetSwap(1);
800 - SwapBuffers(hDC);
 848+ This->ext = (glExtensions *)malloc(sizeof(glExtensions));
 849+ glExtensions_Init(This->ext);
 850+ This->util = new glUtil(This->ext);
 851+ glRenderer__SetSwap(This,1);
 852+ SwapBuffers(This->hDC);
801853 glFinish();
802 - timer.Calibrate(height, frequency);
803 - _SetSwap(0);
804 - util->SetViewport(0,0,width,height);
 854+ This->timer.Calibrate(height, frequency);
 855+ glRenderer__SetSwap(This,0);
 856+ This->util->SetViewport(0,0,width,height);
805857 glViewport(0,0,width,height);
806 - util->SetDepthRange(0.0,1.0);
807 - util->DepthWrite(true);
808 - util->DepthTest(false);
809 - util->MatrixMode(GL_MODELVIEW);
 858+ This->util->SetDepthRange(0.0,1.0);
 859+ This->util->DepthWrite(true);
 860+ This->util->DepthTest(false);
 861+ This->util->MatrixMode(GL_MODELVIEW);
810862 glDisable(GL_DEPTH_TEST);
811 - util->SetDepthComp(GL_LESS);
 863+ This->util->SetDepthComp(GL_LESS);
812864 const GLubyte *glver = glGetString(GL_VERSION);
813 - gl_caps.Version = (GLfloat)atof((char*)glver);
814 - if(gl_caps.Version >= 2)
 865+ This->gl_caps.Version = (GLfloat)atof((char*)glver);
 866+ if(This->gl_caps.Version >= 2)
815867 {
816868 glver = glGetString(GL_SHADING_LANGUAGE_VERSION);
817 - gl_caps.ShaderVer = (GLfloat)atof((char*)glver);
 869+ This->gl_caps.ShaderVer = (GLfloat)atof((char*)glver);
818870 }
819 - else gl_caps.ShaderVer = 0;
820 - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl_caps.TextureMax);
821 - shaders = new ShaderManager(ext);
822 - fbo.fbo = 0;
823 - util->InitFBO(&fbo);
824 - util->ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
825 - util->ClearDepth(1.0);
826 - util->ClearStencil(0);
827 - util->EnableArray(-1,false);
828 - util->BlendFunc(GL_ONE,GL_ZERO);
829 - util->BlendEnable(false);
 871+ else This->gl_caps.ShaderVer = 0;
 872+ glGetIntegerv(GL_MAX_TEXTURE_SIZE,&This->gl_caps.TextureMax);
 873+ This->shaders = new ShaderManager(This->ext);
 874+ This->fbo.fbo = 0;
 875+ This->util->InitFBO(&This->fbo);
 876+ This->util->ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
 877+ This->util->ClearDepth(1.0);
 878+ This->util->ClearStencil(0);
 879+ This->util->EnableArray(-1,false);
 880+ This->util->BlendFunc(GL_ONE,GL_ZERO);
 881+ This->util->BlendEnable(false);
830882 glClear(GL_COLOR_BUFFER_BIT);
831883 glFlush();
832 - util->SetScissor(false,0,0,0,0);
 884+ This->util->SetScissor(false,0,0,0,0);
833885 glDisable(GL_SCISSOR_TEST);
834 - util->SetCull(D3DCULL_CCW);
 886+ This->util->SetCull(D3DCULL_CCW);
835887 glEnable(GL_CULL_FACE);
836 - SwapBuffers(hDC);
837 - texman = TextureManager_Create(ext);
838 - TextureManager_SetActiveTexture(texman,0);
839 - _SetFogColor(0);
840 - _SetFogStart(0);
841 - _SetFogEnd(1);
842 - _SetFogDensity(1);
843 - util->SetPolyMode(D3DFILL_SOLID);
844 - util->SetShadeMode(D3DSHADE_GOURAUD);
 888+ SwapBuffers(This->hDC);
 889+ This->texman = TextureManager_Create(This->ext);
 890+ TextureManager_SetActiveTexture(This->texman,0);
 891+ glRenderer__SetFogColor(This,0);
 892+ glRenderer__SetFogStart(This,0);
 893+ glRenderer__SetFogEnd(This,1);
 894+ glRenderer__SetFogDensity(This,1);
 895+ This->util->SetPolyMode(D3DFILL_SOLID);
 896+ This->util->SetShadeMode(D3DSHADE_GOURAUD);
845897 if(hWnd)
846898 {
847 - dib.enabled = true;
848 - dib.width = width;
849 - dib.height = height;
850 - dib.pitch = (((width<<3)+31)&~31) >>3;
851 - dib.pixels = NULL;
852 - dib.hdc = CreateCompatibleDC(NULL);
853 - ZeroMemory(&dib.info,sizeof(BITMAPINFO));
854 - dib.info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
855 - dib.info.bmiHeader.biBitCount = 32;
856 - dib.info.bmiHeader.biWidth = width;
857 - dib.info.bmiHeader.biHeight = height;
858 - dib.info.bmiHeader.biCompression = BI_RGB;
859 - dib.info.bmiHeader.biPlanes = 1;
860 - dib.hbitmap = CreateDIBSection(dib.hdc,&dib.info,DIB_RGB_COLORS,(void**)&dib.pixels,NULL,0);
 899+ This->dib.enabled = true;
 900+ This->dib.width = width;
 901+ This->dib.height = height;
 902+ This->dib.pitch = (((width<<3)+31)&~31) >>3;
 903+ This->dib.pixels = NULL;
 904+ This->dib.hdc = CreateCompatibleDC(NULL);
 905+ ZeroMemory(&This->dib.info,sizeof(BITMAPINFO));
 906+ This->dib.info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 907+ This->dib.info.bmiHeader.biBitCount = 32;
 908+ This->dib.info.bmiHeader.biWidth = width;
 909+ This->dib.info.bmiHeader.biHeight = height;
 910+ This->dib.info.bmiHeader.biCompression = BI_RGB;
 911+ This->dib.info.bmiHeader.biPlanes = 1;
 912+ This->dib.hbitmap = CreateDIBSection(This->dib.hdc,&This->dib.info,
 913+ DIB_RGB_COLORS,(void**)&This->dib.pixels,NULL,0);
861914 }
862 - ext->glGenBuffers(1,&PBO);
863 - ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,PBO);
864 - ext->glBufferData(GL_PIXEL_PACK_BUFFER,width*height*4,NULL,GL_STREAM_READ);
865 - ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
866 - TextureManager_InitSamplers(texman);
 915+ This->ext->glGenBuffers(1,&This->PBO);
 916+ This->ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,This->PBO);
 917+ This->ext->glBufferData(GL_PIXEL_PACK_BUFFER,width*height*4,NULL,GL_STREAM_READ);
 918+ This->ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
 919+ TextureManager_InitSamplers(This->texman);
867920 TRACE_SYSINFO();
868921 return TRUE;
869922 }
870923
871 -void glRenderer::_Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
 924+void glRenderer__Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
872925 glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
873926 {
874927 LONG sizes[6];
875 - ddInterface->GetSizes(sizes);
 928+ This->ddInterface->GetSizes(sizes);
876929 DWORD shaderid;
877930 if (lpDDBltFx) shaderid = PackROPBits(lpDDBltFx->dwROP, dwFlags);
878931 else shaderid = dwFlags & 0xF2FAADFF;
879 - shaders->SetShader(shaderid, NULL, NULL, 1);
880 - GenShader2D *shader = &shaders->gen2d->genshaders2D[shaders->gen3d->current_genshader];
881 - util->BlendEnable(false);
882 - util->SetFBO(dest);
883 - util->SetViewport(0,0,dest->fakex,dest->fakey);
 932+ This->shaders->SetShader(shaderid, NULL, NULL, 1);
 933+ GenShader2D *shader = &This->shaders->gen2d->genshaders2D[This->shaders->gen3d->current_genshader];
 934+ This->util->BlendEnable(false);
 935+ This->util->SetFBO(dest);
 936+ This->util->SetViewport(0,0,dest->fakex,dest->fakey);
884937 RECT destrect;
885938 DDSURFACEDESC2 ddsd;
886939 ddsd.dwSize = sizeof(DDSURFACEDESC2);
887940 dest->GetSurfaceDesc(&ddsd);
888 - util->DepthTest(false);
 941+ This->util->DepthTest(false);
889942 if(!lpDestRect)
890943 {
891944 destrect.left = 0;
@@ -905,48 +958,48 @@
906959 srcrect.bottom = ddsdSrc.dwHeight;
907960 }
908961 else srcrect = *lpSrcRect;
909 - bltvertices[1].x = bltvertices[3].x = (GLfloat)destrect.left * ((GLfloat)dest->fakex/(GLfloat)ddsd.dwWidth);
910 - bltvertices[0].x = bltvertices[2].x = (GLfloat)destrect.right * ((GLfloat)dest->fakex/(GLfloat)ddsd.dwWidth);
911 - bltvertices[0].y = bltvertices[1].y = (GLfloat)dest->fakey-((GLfloat)destrect.top * ((GLfloat)dest->fakey/(GLfloat)ddsd.dwHeight));
912 - bltvertices[2].y = bltvertices[3].y = (GLfloat)dest->fakey-((GLfloat)destrect.bottom * ((GLfloat)dest->fakey/(GLfloat)ddsd.dwHeight));
913 - bltvertices[1].s = bltvertices[3].s = (GLfloat)srcrect.left / (GLfloat)ddsdSrc.dwWidth;
914 - bltvertices[0].s = bltvertices[2].s = (GLfloat)srcrect.right / (GLfloat)ddsdSrc.dwWidth;
915 - bltvertices[0].t = bltvertices[1].t = (GLfloat)srcrect.top / (GLfloat)ddsdSrc.dwHeight;
916 - bltvertices[2].t = bltvertices[3].t = (GLfloat)srcrect.bottom / (GLfloat)ddsdSrc.dwHeight;
 962+ This->bltvertices[1].x = This->bltvertices[3].x = (GLfloat)destrect.left * ((GLfloat)dest->fakex/(GLfloat)ddsd.dwWidth);
 963+ This->bltvertices[0].x = This->bltvertices[2].x = (GLfloat)destrect.right * ((GLfloat)dest->fakex/(GLfloat)ddsd.dwWidth);
 964+ This->bltvertices[0].y = This->bltvertices[1].y = (GLfloat)dest->fakey-((GLfloat)destrect.top * ((GLfloat)dest->fakey/(GLfloat)ddsd.dwHeight));
 965+ This->bltvertices[2].y = This->bltvertices[3].y = (GLfloat)dest->fakey-((GLfloat)destrect.bottom * ((GLfloat)dest->fakey/(GLfloat)ddsd.dwHeight));
 966+ This->bltvertices[1].s = This->bltvertices[3].s = (GLfloat)srcrect.left / (GLfloat)ddsdSrc.dwWidth;
 967+ This->bltvertices[0].s = This->bltvertices[2].s = (GLfloat)srcrect.right / (GLfloat)ddsdSrc.dwWidth;
 968+ This->bltvertices[0].t = This->bltvertices[1].t = (GLfloat)srcrect.top / (GLfloat)ddsdSrc.dwHeight;
 969+ This->bltvertices[2].t = This->bltvertices[3].t = (GLfloat)srcrect.bottom / (GLfloat)ddsdSrc.dwHeight;
917970 if(dest->zbuffer) glClear(GL_DEPTH_BUFFER_BIT);
918971 if(dwFlags & DDBLT_COLORFILL)
919972 {
920 - switch(ddInterface->GetBPP())
 973+ switch(This->ddInterface->GetBPP())
921974 {
922975 case 8:
923 - bltvertices[0].r = bltvertices[0].g = bltvertices[0].b =
924 - bltvertices[1].r = bltvertices[1].g = bltvertices[1].b =
925 - bltvertices[2].r = bltvertices[2].g = bltvertices[2].b =
926 - bltvertices[3].r = bltvertices[3].g = bltvertices[3].b = (GLubyte)lpDDBltFx->dwFillColor;
 976+ This->bltvertices[0].r = This->bltvertices[0].g = This->bltvertices[0].b =
 977+ This->bltvertices[1].r = This->bltvertices[1].g = This->bltvertices[1].b =
 978+ This->bltvertices[2].r = This->bltvertices[2].g = This->bltvertices[2].b =
 979+ This->bltvertices[3].r = This->bltvertices[3].g = This->bltvertices[3].b = (GLubyte)lpDDBltFx->dwFillColor;
927980 break;
928981 case 15:
929 - bltvertices[0].r = bltvertices[1].r = bltvertices[2].r = bltvertices[3].r =
 982+ This->bltvertices[0].r = This->bltvertices[1].r = This->bltvertices[2].r = This->bltvertices[3].r =
930983 _5to8bit((lpDDBltFx->dwFillColor>>10) & 31);
931 - bltvertices[0].g = bltvertices[1].g = bltvertices[2].g = bltvertices[3].g =
 984+ This->bltvertices[0].g = This->bltvertices[1].g = This->bltvertices[2].g = This->bltvertices[3].g =
932985 _5to8bit((lpDDBltFx->dwFillColor>>5) & 31);
933 - bltvertices[0].b = bltvertices[1].b = bltvertices[2].b = bltvertices[3].b =
 986+ This->bltvertices[0].b = This->bltvertices[1].b = This->bltvertices[2].b = This->bltvertices[3].b =
934987 _5to8bit(lpDDBltFx->dwFillColor & 31);
935988 break;
936989 case 16:
937 - bltvertices[0].r = bltvertices[1].r = bltvertices[2].r = bltvertices[3].r =
 990+ This->bltvertices[0].r = This->bltvertices[1].r = This->bltvertices[2].r = This->bltvertices[3].r =
938991 _5to8bit((lpDDBltFx->dwFillColor>>11) & 31);
939 - bltvertices[0].g = bltvertices[1].g = bltvertices[2].g = bltvertices[3].g =
 992+ This->bltvertices[0].g = This->bltvertices[1].g = This->bltvertices[2].g = This->bltvertices[3].g =
940993 _6to8bit((lpDDBltFx->dwFillColor>>5) & 63);
941 - bltvertices[0].b = bltvertices[1].b = bltvertices[2].b = bltvertices[3].b =
 994+ This->bltvertices[0].b = This->bltvertices[1].b = This->bltvertices[2].b = This->bltvertices[3].b =
942995 _5to8bit(lpDDBltFx->dwFillColor & 31);
943996 break;
944997 case 24:
945998 case 32:
946 - bltvertices[0].r = bltvertices[1].r = bltvertices[2].r = bltvertices[3].r =
 999+ This->bltvertices[0].r = This->bltvertices[1].r = This->bltvertices[2].r = This->bltvertices[3].r =
9471000 ((lpDDBltFx->dwFillColor>>16) & 255);
948 - bltvertices[0].g = bltvertices[1].g = bltvertices[2].g = bltvertices[3].g =
 1001+ This->bltvertices[0].g = This->bltvertices[1].g = This->bltvertices[2].g = This->bltvertices[3].g =
9491002 ((lpDDBltFx->dwFillColor>>8) & 255);
950 - bltvertices[0].b = bltvertices[1].b = bltvertices[2].b = bltvertices[3].b =
 1003+ This->bltvertices[0].b = This->bltvertices[1].b = This->bltvertices[2].b = This->bltvertices[3].b =
9511004 (lpDDBltFx->dwFillColor & 255);
9521005 default:
9531006 break;
@@ -954,20 +1007,20 @@
9551008 }
9561009 if((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
9571010 {
958 - switch(ddInterface->GetBPP())
 1011+ switch(This->ddInterface->GetBPP())
9591012 {
9601013 case 8:
961 - if(ext->glver_major >= 3) ext->glUniform3i(shader->shader.uniforms[4],src->colorkey[0].key.dwColorSpaceHighValue,0,0);
962 - else ext->glUniform3i(shader->shader.uniforms[4],src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
 1014+ if(This->ext->glver_major >= 3) This->ext->glUniform3i(shader->shader.uniforms[4],src->colorkey[0].key.dwColorSpaceHighValue,0,0);
 1015+ else This->ext->glUniform3i(shader->shader.uniforms[4],src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
9631016 src->colorkey[0].key.dwColorSpaceHighValue);
9641017 break;
9651018 case 15:
966 - ext->glUniform3i(shader->shader.uniforms[4],_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>10 & 31),
 1019+ This->ext->glUniform3i(shader->shader.uniforms[4],_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>10 & 31),
9671020 _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 31),
9681021 _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
9691022 break;
9701023 case 16:
971 - ext->glUniform3i(shader->shader.uniforms[4],_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>11 & 31),
 1024+ This->ext->glUniform3i(shader->shader.uniforms[4],_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>11 & 31),
9721025 _6to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 63),
9731026 _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
9741027 break;
@@ -974,139 +1027,141 @@
9751028 case 24:
9761029 case 32:
9771030 default:
978 - ext->glUniform3i(shader->shader.uniforms[4],(src->colorkey[0].key.dwColorSpaceHighValue>>16 & 255),
 1031+ This->ext->glUniform3i(shader->shader.uniforms[4],(src->colorkey[0].key.dwColorSpaceHighValue>>16 & 255),
9791032 (src->colorkey[0].key.dwColorSpaceHighValue>>8 & 255),
9801033 (src->colorkey[0].key.dwColorSpaceHighValue & 255));
9811034 break;
9821035 }
983 - ext->glUniform1i(shader->shader.uniforms[1],0);
 1036+ This->ext->glUniform1i(shader->shader.uniforms[1],0);
9841037 }
9851038 else if(!(dwFlags & DDBLT_COLORFILL))
9861039 {
987 - ext->glUniform1i(shader->shader.uniforms[1],0);
 1040+ This->ext->glUniform1i(shader->shader.uniforms[1],0);
9881041 }
9891042 if(src)
9901043 {
991 - TextureManager_SetTexture(texman,0,src->GetTexture());
992 - if(ext->GLEXT_ARB_sampler_objects)
 1044+ TextureManager_SetTexture(This->texman,0,src->GetTexture());
 1045+ if(This->ext->GLEXT_ARB_sampler_objects)
9931046 {
994 - if((dxglcfg.scalingfilter == 0) || (ddInterface->GetBPP() == 8)) src->SetFilter(0,GL_NEAREST,GL_NEAREST,ext,texman);
995 - else src->SetFilter(0,GL_LINEAR,GL_LINEAR,ext,texman);
 1047+ if((dxglcfg.scalingfilter == 0) || (This->ddInterface->GetBPP() == 8))
 1048+ src->SetFilter(0,GL_NEAREST,GL_NEAREST,This->ext,This->texman);
 1049+ else src->SetFilter(0,GL_LINEAR,GL_LINEAR,This->ext,This->texman);
9961050 }
9971051 }
998 - else TextureManager_SetTexture(texman,0,NULL);
999 - ext->glUniform4f(shader->shader.uniforms[0],0,(GLfloat)dest->fakex,0,(GLfloat)dest->fakey);
 1052+ else TextureManager_SetTexture(This->texman,0,NULL);
 1053+ This->ext->glUniform4f(shader->shader.uniforms[0],0,(GLfloat)dest->fakex,0,(GLfloat)dest->fakey);
10001054 dest->dirty |= 2;
1001 - util->EnableArray(shader->shader.attribs[0],true);
1002 - ext->glVertexAttribPointer(shader->shader.attribs[0],2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
 1055+ This->util->EnableArray(shader->shader.attribs[0],true);
 1056+ This->ext->glVertexAttribPointer(shader->shader.attribs[0],2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
10031057 if(shader->shader.attribs[1] != -1)
10041058 {
1005 - util->EnableArray(shader->shader.attribs[1],true);
1006 - ext->glVertexAttribPointer(shader->shader.attribs[0],3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
 1059+ This->util->EnableArray(shader->shader.attribs[1],true);
 1060+ This->ext->glVertexAttribPointer(shader->shader.attribs[0],3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&This->bltvertices[0].r);
10071061 }
10081062 if(!(dwFlags & DDBLT_COLORFILL))
10091063 {
1010 - util->EnableArray(shader->shader.attribs[3],true);
1011 - ext->glVertexAttribPointer(shader->shader.attribs[3],2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
 1064+ This->util->EnableArray(shader->shader.attribs[3],true);
 1065+ This->ext->glVertexAttribPointer(shader->shader.attribs[3],2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].s);
10121066 }
1013 - util->SetCull(D3DCULL_NONE);
1014 - util->SetPolyMode(D3DFILL_SOLID);
1015 - ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
1016 - util->SetFBO((FBO*)NULL);
 1067+ This->util->SetCull(D3DCULL_NONE);
 1068+ This->util->SetPolyMode(D3DFILL_SOLID);
 1069+ This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
 1070+ This->util->SetFBO((FBO*)NULL);
10171071 if(((ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
10181072 (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
10191073 ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
1020 - !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))_DrawScreen(dest->texture,dest->paltex,dest,dest,0,false);
1021 - outputs[0] = DD_OK;
1022 - SetEvent(busy);
 1074+ !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
 1075+ glRenderer__DrawScreen(This,dest->texture,dest->paltex,dest,dest,0,false);
 1076+ This->outputs[0] = DD_OK;
 1077+ SetEvent(This->busy);
10231078 }
10241079
1025 -void glRenderer::_MakeTexture(TEXTURE *texture, DWORD width, DWORD height)
 1080+void glRenderer__MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height)
10261081 {
1027 - TextureManager__CreateTexture(texman,texture,width,height);
 1082+ TextureManager__CreateTexture(This->texman,texture,width,height);
10281083 }
10291084
1030 -void glRenderer::_DrawBackbuffer(TEXTURE **texture, int x, int y, int progtype)
 1085+void glRenderer__DrawBackbuffer(glRenderer *This, TEXTURE **texture, int x, int y, int progtype)
10311086 {
10321087 GLfloat view[4];
1033 - TextureManager_SetActiveTexture(texman,0);
1034 - if(!backbuffer)
 1088+ TextureManager_SetActiveTexture(This->texman,0);
 1089+ if(!This->backbuffer)
10351090 {
1036 - backbuffer = new TEXTURE;
1037 - ZeroMemory(backbuffer,sizeof(TEXTURE));
1038 - backbuffer->minfilter = backbuffer->magfilter = GL_LINEAR;
1039 - backbuffer->wraps = backbuffer->wrapt = GL_CLAMP_TO_EDGE;
1040 - backbuffer->pixelformat.dwFlags = DDPF_RGB;
1041 - backbuffer->pixelformat.dwBBitMask = 0xFF;
1042 - backbuffer->pixelformat.dwGBitMask = 0xFF00;
1043 - backbuffer->pixelformat.dwRBitMask = 0xFF0000;
1044 - backbuffer->pixelformat.dwRGBBitCount = 32;
1045 - TextureManager__CreateTexture(texman,backbuffer,x,y);
1046 - backx = x;
1047 - backy = y;
 1091+ This->backbuffer = (TEXTURE*)malloc(sizeof(TEXTURE));
 1092+ ZeroMemory(This->backbuffer,sizeof(TEXTURE));
 1093+ This->backbuffer->minfilter = This->backbuffer->magfilter = GL_LINEAR;
 1094+ This->backbuffer->wraps = This->backbuffer->wrapt = GL_CLAMP_TO_EDGE;
 1095+ This->backbuffer->pixelformat.dwFlags = DDPF_RGB;
 1096+ This->backbuffer->pixelformat.dwBBitMask = 0xFF;
 1097+ This->backbuffer->pixelformat.dwGBitMask = 0xFF00;
 1098+ This->backbuffer->pixelformat.dwRBitMask = 0xFF0000;
 1099+ This->backbuffer->pixelformat.dwRGBBitCount = 32;
 1100+ TextureManager__CreateTexture(This->texman,This->backbuffer,x,y);
 1101+ This->backx = x;
 1102+ This->backy = y;
10481103 }
1049 - if((backx != x) || (backy != y))
 1104+ if((This->backx != x) || (This->backy != y))
10501105 {
1051 - TextureManager__UploadTexture(texman,backbuffer,0,NULL,x,y);
1052 - backx = x;
1053 - backy = y;
 1106+ TextureManager__UploadTexture(This->texman,This->backbuffer,0,NULL,x,y);
 1107+ This->backx = x;
 1108+ This->backy = y;
10541109 }
1055 - util->SetFBO(&fbo,backbuffer,0,false);
 1110+ This->util->SetFBO(&This->fbo,This->backbuffer,0,false);
10561111 view[0] = view[2] = 0;
10571112 view[1] = (GLfloat)x;
10581113 view[3] = (GLfloat)y;
1059 - util->SetViewport(0,0,x,y);
 1114+ This->util->SetViewport(0,0,x,y);
10601115 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
1061 - TextureManager_SetTexture(texman,0,*texture);
1062 - *texture = backbuffer;
1063 - if(ext->GLEXT_ARB_sampler_objects) ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_LINEAR,GL_LINEAR,ext,texman);
1064 - ext->glUniform4f(shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
1065 - bltvertices[0].s = bltvertices[0].t = bltvertices[1].t = bltvertices[2].s = 1.;
1066 - bltvertices[1].s = bltvertices[2].t = bltvertices[3].s = bltvertices[3].t = 0.;
1067 - bltvertices[0].y = bltvertices[1].y = bltvertices[1].x = bltvertices[3].x = 0.;
1068 - bltvertices[0].x = bltvertices[2].x = (float)x;
1069 - bltvertices[2].y = bltvertices[3].y = (float)y;
1070 - util->EnableArray(shaders->shaders[progtype].pos,true);
1071 - ext->glVertexAttribPointer(shaders->shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
1072 - util->EnableArray(shaders->shaders[progtype].texcoord,true);
1073 - ext->glVertexAttribPointer(shaders->shaders[progtype].texcoord,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
1074 - util->SetCull(D3DCULL_NONE);
1075 - util->SetPolyMode(D3DFILL_SOLID);
1076 - ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
1077 - util->SetFBO((FBO*)NULL);
 1116+ TextureManager_SetTexture(This->texman,0,*texture);
 1117+ *texture = This->backbuffer;
 1118+ if(This->ext->GLEXT_ARB_sampler_objects) ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_LINEAR,GL_LINEAR,This->ext,This->texman);
 1119+ This->ext->glUniform4f(This->shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
 1120+ This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
 1121+ This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
 1122+ This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
 1123+ This->bltvertices[0].x = This->bltvertices[2].x = (float)x;
 1124+ This->bltvertices[2].y = This->bltvertices[3].y = (float)y;
 1125+ This->util->EnableArray(This->shaders->shaders[progtype].pos,true);
 1126+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
 1127+ This->util->EnableArray(This->shaders->shaders[progtype].texcoord,true);
 1128+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].s);
 1129+ This->util->SetCull(D3DCULL_NONE);
 1130+ This->util->SetPolyMode(D3DFILL_SOLID);
 1131+ This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
 1132+ This->util->SetFBO((FBO*)NULL);
10781133 }
10791134
1080 -void glRenderer::_DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync)
 1135+void glRenderer__DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync)
10811136 {
10821137 int progtype;
10831138 RECT r,r2;
1084 - util->BlendEnable(false);
 1139+ This->util->BlendEnable(false);
10851140 if((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
10861141 {
1087 - GetClientRect(hWnd,&r);
1088 - GetClientRect(RenderWnd->GetHWnd(),&r2);
 1142+ GetClientRect(This->hWnd,&r);
 1143+ GetClientRect(This->RenderWnd->GetHWnd(),&r2);
10891144 if(memcmp(&r2,&r,sizeof(RECT)))
1090 - SetWindowPos(RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
 1145+ SetWindowPos(This->RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
10911146 }
1092 - util->DepthTest(false);
 1147+ This->util->DepthTest(false);
10931148 RECT *viewrect = &r2;
1094 - _SetSwap(vsync);
 1149+ glRenderer__SetSwap(This,vsync);
10951150 LONG sizes[6];
10961151 GLfloat view[4];
10971152 GLint viewport[4];
10981153 if(src->dirty & 1)
10991154 {
1100 - _UploadTexture(src->buffer,src->bigbuffer,texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
 1155+ glRenderer__UploadTexture(This,src->buffer,src->bigbuffer,texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
11011156 src->fakex,src->fakey,src->ddsd.lPitch,
1102 - (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
 1157+ (NextMultipleOf4((This->ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
11031158 src->ddsd.ddpfPixelFormat.dwRGBBitCount);
11041159 src->dirty &= ~1;
11051160 }
11061161 if(dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
11071162 {
1108 - if(ddInterface->GetFullscreen())
 1163+ if(This->ddInterface->GetFullscreen())
11091164 {
1110 - ddInterface->GetSizes(sizes);
 1165+ This->ddInterface->GetSizes(sizes);
11111166 viewport[0] = viewport[1] = 0;
11121167 viewport[2] = sizes[4];
11131168 viewport[3] = sizes[5];
@@ -1120,8 +1175,8 @@
11211176 viewport[0] = viewport[1] = 0;
11221177 viewport[2] = viewrect->right;
11231178 viewport[3] = viewrect->bottom;
1124 - ClientToScreen(RenderWnd->GetHWnd(),(LPPOINT)&viewrect->left);
1125 - ClientToScreen(RenderWnd->GetHWnd(),(LPPOINT)&viewrect->right);
 1179+ ClientToScreen(This->RenderWnd->GetHWnd(),(LPPOINT)&viewrect->left);
 1180+ ClientToScreen(This->RenderWnd->GetHWnd(),(LPPOINT)&viewrect->right);
11261181 view[0] = (GLfloat)viewrect->left;
11271182 view[1] = (GLfloat)viewrect->right;
11281183 view[2] = (GLfloat)dest->fakey-(GLfloat)viewrect->top;
@@ -1135,179 +1190,181 @@
11361191 view[2] = 0;
11371192 view[3] = (GLfloat)dest->fakey;
11381193 }
1139 - util->SetFBO((FBO*)NULL);
 1194+ This->util->SetFBO((FBO*)NULL);
11401195 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
1141 - if(ddInterface->GetBPP() == 8)
 1196+ if(This->ddInterface->GetBPP() == 8)
11421197 {
1143 - shaders->SetShader(PROG_PAL256,NULL,NULL,0);
 1198+ This->shaders->SetShader(PROG_PAL256,NULL,NULL,0);
11441199 progtype = PROG_PAL256;
1145 - TextureManager__UploadTexture(texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1);
1146 - ext->glUniform1i(shaders->shaders[progtype].tex0,0);
1147 - ext->glUniform1i(shaders->shaders[progtype].pal,1);
1148 - TextureManager_SetTexture(texman,0,texture);
1149 - TextureManager_SetTexture(texman,1,paltex);
 1200+ TextureManager__UploadTexture(This->texman,paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1);
 1201+ This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
 1202+ This->ext->glUniform1i(This->shaders->shaders[progtype].pal,1);
 1203+ TextureManager_SetTexture(This->texman,0,texture);
 1204+ TextureManager_SetTexture(This->texman,1,paltex);
11501205 if(dxglcfg.scalingfilter)
11511206 {
1152 - _DrawBackbuffer(&texture,dest->fakex,dest->fakey,progtype);
1153 - shaders->SetShader(PROG_TEXTURE,NULL,NULL,0);
 1207+ glRenderer__DrawBackbuffer(This,&texture,dest->fakex,dest->fakey,progtype);
 1208+ This->shaders->SetShader(PROG_TEXTURE,NULL,NULL,0);
11541209 progtype = PROG_TEXTURE;
1155 - TextureManager_SetTexture(texman,0,texture);
1156 - ext->glUniform1i(shaders->shaders[progtype].tex0,0);
 1210+ TextureManager_SetTexture(This->texman,0,texture);
 1211+ This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
11571212 }
1158 - if(ext->GLEXT_ARB_sampler_objects)
 1213+ if(This->ext->GLEXT_ARB_sampler_objects)
11591214 {
1160 - ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_NEAREST,GL_NEAREST,ext,texman);
1161 - ((glDirectDrawSurface7*)NULL)->SetFilter(1,GL_NEAREST,GL_NEAREST,ext,texman);
 1215+ ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_NEAREST,GL_NEAREST,This->ext,This->texman);
 1216+ ((glDirectDrawSurface7*)NULL)->SetFilter(1,GL_NEAREST,GL_NEAREST,This->ext,This->texman);
11621217 }
11631218 }
11641219 else
11651220 {
1166 - shaders->SetShader(PROG_TEXTURE,NULL,NULL,0);
 1221+ This->shaders->SetShader(PROG_TEXTURE,NULL,NULL,0);
11671222 progtype = PROG_TEXTURE;
1168 - TextureManager_SetTexture(texman,0,texture);
1169 - ext->glUniform1i(shaders->shaders[progtype].tex0,0);
 1223+ TextureManager_SetTexture(This->texman,0,texture);
 1224+ This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
11701225 }
1171 - if(dxglcfg.scalingfilter && ext->GLEXT_ARB_sampler_objects) ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_LINEAR,GL_LINEAR,ext,texman);
1172 - else if(ext->GLEXT_ARB_sampler_objects) ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_NEAREST,GL_NEAREST,ext,texman);
1173 - util->SetViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
1174 - ext->glUniform4f(shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
1175 - if(ddInterface->GetFullscreen())
 1226+ if(dxglcfg.scalingfilter && This->ext->GLEXT_ARB_sampler_objects)
 1227+ ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_LINEAR,GL_LINEAR,This->ext,This->texman);
 1228+ else if(This->ext->GLEXT_ARB_sampler_objects)
 1229+ ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_NEAREST,GL_NEAREST,This->ext,This->texman);
 1230+ This->util->SetViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
 1231+ This->ext->glUniform4f(This->shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
 1232+ if(This->ddInterface->GetFullscreen())
11761233 {
1177 - bltvertices[0].x = bltvertices[2].x = (float)sizes[0];
1178 - bltvertices[0].y = bltvertices[1].y = bltvertices[1].x = bltvertices[3].x = 0.;
1179 - bltvertices[2].y = bltvertices[3].y = (float)sizes[1];
 1234+ This->bltvertices[0].x = This->bltvertices[2].x = (float)sizes[0];
 1235+ This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
 1236+ This->bltvertices[2].y = This->bltvertices[3].y = (float)sizes[1];
11801237 }
11811238 else
11821239 {
1183 - bltvertices[0].x = bltvertices[2].x = (float)dest->fakex;
1184 - bltvertices[0].y = bltvertices[1].y = bltvertices[1].x = bltvertices[3].x = 0.;
1185 - bltvertices[2].y = bltvertices[3].y = (float)dest->fakey;
 1240+ This->bltvertices[0].x = This->bltvertices[2].x = (float)dest->fakex;
 1241+ This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
 1242+ This->bltvertices[2].y = This->bltvertices[3].y = (float)dest->fakey;
11861243 }
1187 - bltvertices[0].s = bltvertices[0].t = bltvertices[1].t = bltvertices[2].s = 1.;
1188 - bltvertices[1].s = bltvertices[2].t = bltvertices[3].s = bltvertices[3].t = 0.;
1189 - util->EnableArray(shaders->shaders[progtype].pos,true);
1190 - ext->glVertexAttribPointer(shaders->shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
1191 - util->EnableArray(shaders->shaders[progtype].texcoord,true);
1192 - ext->glVertexAttribPointer(shaders->shaders[progtype].texcoord,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
1193 - if(shaders->shaders[progtype].rgb != -1)
 1244+ This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
 1245+ This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
 1246+ This->util->EnableArray(This->shaders->shaders[progtype].pos,true);
 1247+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
 1248+ This->util->EnableArray(This->shaders->shaders[progtype].texcoord,true);
 1249+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].s);
 1250+ if(This->shaders->shaders[progtype].rgb != -1)
11941251 {
1195 - util->EnableArray(shaders->shaders[progtype].rgb,true);
1196 - ext->glVertexAttribPointer(shaders->shaders[progtype].rgb,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
 1252+ This->util->EnableArray(This->shaders->shaders[progtype].rgb,true);
 1253+ This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].rgb,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&This->bltvertices[0].r);
11971254 }
1198 - util->SetCull(D3DCULL_NONE);
1199 - util->SetPolyMode(D3DFILL_SOLID);
1200 - ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
 1255+ This->util->SetCull(D3DCULL_NONE);
 1256+ This->util->SetPolyMode(D3DFILL_SOLID);
 1257+ This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
12011258 glFlush();
1202 - if(hWnd) SwapBuffers(hDC);
 1259+ if(This->hWnd) SwapBuffers(This->hDC);
12031260 else
12041261 {
12051262 glReadBuffer(GL_FRONT);
1206 - ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,PBO);
 1263+ This->ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,This->PBO);
12071264 GLint packalign;
12081265 glGetIntegerv(GL_PACK_ALIGNMENT,&packalign);
12091266 glPixelStorei(GL_PACK_ALIGNMENT,1);
1210 - ddInterface->GetSizes(sizes);
 1267+ This->ddInterface->GetSizes(sizes);
12111268 glReadPixels(0,0,sizes[4],sizes[5],GL_BGRA,GL_UNSIGNED_BYTE,0);
1212 - GLubyte *pixels = (GLubyte*)ext->glMapBuffer(GL_PIXEL_PACK_BUFFER,GL_READ_ONLY);
 1269+ GLubyte *pixels = (GLubyte*)This->ext->glMapBuffer(GL_PIXEL_PACK_BUFFER,GL_READ_ONLY);
12131270 for(int i = 0; i < sizes[5];i++)
12141271 {
1215 - memcpy(&dib.pixels[dib.pitch*i],
 1272+ memcpy(&This->dib.pixels[This->dib.pitch*i],
12161273 &pixels[((sizes[5]-1)-i)*(sizes[4]*4)],sizes[4]*4);
12171274 }
1218 - ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
1219 - ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
 1275+ This->ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
 1276+ This->ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
12201277 glPixelStorei(GL_PACK_ALIGNMENT,packalign);
1221 - HDC hRenderDC = (HDC)::GetDC(RenderWnd->GetHWnd());
 1278+ HDC hRenderDC = (HDC)::GetDC(This->RenderWnd->GetHWnd());
12221279 HGDIOBJ hPrevObj = 0;
12231280 POINT dest = {0,0};
12241281 POINT srcpoint = {0,0};
1225 - SIZE wnd = {dib.width,dib.height};
 1282+ SIZE wnd = {This->dib.width,This->dib.height};
12261283 BLENDFUNCTION func = {AC_SRC_OVER,0,255,AC_SRC_ALPHA};
1227 - hPrevObj = SelectObject(dib.hdc,dib.hbitmap);
1228 - ClientToScreen(RenderWnd->GetHWnd(),&dest);
1229 - UpdateLayeredWindow(RenderWnd->GetHWnd(),hRenderDC,&dest,&wnd,
1230 - dib.hdc,&srcpoint,0,&func,ULW_ALPHA);
1231 - SelectObject(dib.hdc,hPrevObj);
1232 - ReleaseDC(RenderWnd->GetHWnd(),hRenderDC);
 1284+ hPrevObj = SelectObject(This->dib.hdc,This->dib.hbitmap);
 1285+ ClientToScreen(This->RenderWnd->GetHWnd(),&dest);
 1286+ UpdateLayeredWindow(This->RenderWnd->GetHWnd(),hRenderDC,&dest,&wnd,
 1287+ This->dib.hdc,&srcpoint,0,&func,ULW_ALPHA);
 1288+ SelectObject(This->dib.hdc,hPrevObj);
 1289+ ReleaseDC(This->RenderWnd->GetHWnd(),hRenderDC);
12331290 }
1234 - if(setsync) SetEvent(busy);
 1291+ if(setsync) SetEvent(This->busy);
12351292
12361293 }
12371294
1238 -void glRenderer::_DeleteTexture(TEXTURE *texture)
 1295+void glRenderer__DeleteTexture(glRenderer *This, TEXTURE *texture)
12391296 {
1240 - TextureManager__DeleteTexture(texman,texture);
1241 - SetEvent(busy);
 1297+ TextureManager__DeleteTexture(This->texman,texture);
 1298+ SetEvent(This->busy);
12421299 }
12431300
1244 -void glRenderer::_InitD3D(int zbuffer)
 1301+void glRenderer__InitD3D(glRenderer *This, int zbuffer)
12451302 {
1246 - SetEvent(busy);
 1303+ SetEvent(This->busy);
12471304 glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
12481305 GLfloat ambient[] = {0.0,0.0,0.0,0.0};
1249 - if(zbuffer) util->DepthTest(true);
1250 - util->SetDepthComp(GL_LEQUAL);
 1306+ if(zbuffer) This->util->DepthTest(true);
 1307+ This->util->SetDepthComp(GL_LEQUAL);
12511308 GLfloat identity[16];
12521309 __gluMakeIdentityf(identity);
1253 - util->SetMatrix(GL_MODELVIEW,identity,identity,NULL);
1254 - util->SetMatrix(GL_PROJECTION,identity,NULL,NULL);
 1310+ This->util->SetMatrix(GL_MODELVIEW,identity,identity,NULL);
 1311+ This->util->SetMatrix(GL_PROJECTION,identity,NULL,NULL);
12551312 GLfloat one[4] = {1,1,1,1};
12561313 GLfloat zero[4] = {0,0,0,1};
1257 - util->SetMaterial(one,one,zero,zero,0);
 1314+ This->util->SetMaterial(one,one,zero,zero,0);
12581315 }
12591316
1260 -void glRenderer::_Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
 1317+void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
12611318 {
1262 - outputs[0] = (void*)D3D_OK;
 1319+ This->outputs[0] = (void*)D3D_OK;
12631320 GLfloat color[4];
12641321 dwordto4float(dwColor,color);
1265 - util->SetFBO(target);
 1322+ This->util->SetFBO(target);
12661323 int clearbits = 0;
12671324 if(dwFlags & D3DCLEAR_TARGET)
12681325 {
12691326 clearbits |= GL_COLOR_BUFFER_BIT;
1270 - util->ClearColor(color[0],color[1],color[2],color[3]);
 1327+ This->util->ClearColor(color[0],color[1],color[2],color[3]);
12711328 }
12721329 if(dwFlags & D3DCLEAR_ZBUFFER)
12731330 {
12741331 clearbits |= GL_DEPTH_BUFFER_BIT;
1275 - util->ClearDepth(dvZ);
 1332+ This->util->ClearDepth(dvZ);
12761333 }
12771334 if(dwFlags & D3DCLEAR_STENCIL)
12781335 {
12791336 clearbits |= GL_STENCIL_BUFFER_BIT;
1280 - util->ClearStencil(dwStencil);
 1337+ This->util->ClearStencil(dwStencil);
12811338 }
12821339 if(dwCount)
12831340 {
12841341 for(DWORD i = 0; i < dwCount; i++)
12851342 {
1286 - util->SetScissor(true,lpRects[i].x1,lpRects[i].y1,lpRects[i].x2,lpRects[i].y2);
 1343+ This->util->SetScissor(true,lpRects[i].x1,lpRects[i].y1,lpRects[i].x2,lpRects[i].y2);
12871344 glClear(clearbits);
12881345 }
1289 - util->SetScissor(false,0,0,0,0);
 1346+ This->util->SetScissor(false,0,0,0,0);
12901347 }
12911348 else glClear(clearbits);
12921349 if(target->zbuffer) target->zbuffer->dirty |= 2;
12931350 target->dirty |= 2;
1294 - SetEvent(busy);
 1351+ SetEvent(This->busy);
12951352 }
12961353
1297 -void glRenderer::_Flush()
 1354+void glRenderer__Flush(glRenderer *This)
12981355 {
12991356 glFlush();
1300 - SetEvent(busy);
 1357+ SetEvent(This->busy);
13011358 }
13021359
1303 -void glRenderer::_SetWnd(int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd)
 1360+void glRenderer__SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd)
13041361 {
1305 - if(newwnd != hWnd)
 1362+ if(newwnd != This->hWnd)
13061363 {
13071364 EnterCriticalSection(&dll_cs);
13081365 wglMakeCurrent(NULL, NULL);
1309 - ReleaseDC(hWnd,hDC);
1310 - delete RenderWnd;
1311 - RenderWnd = new glRenderWindow(width,height,fullscreen,newwnd,ddInterface);
 1366+ ReleaseDC(This->hWnd,This->hDC);
 1367+ delete This->RenderWnd;
 1368+ This->RenderWnd = new glRenderWindow(width,height,fullscreen,newwnd,This->ddInterface);
13121369 PIXELFORMATDESCRIPTOR pfd;
13131370 GLuint pf;
13141371 InterlockedIncrement(&gllock);
@@ -1318,29 +1375,29 @@
13191376 pfd.iPixelType = PFD_TYPE_RGBA;
13201377 pfd.cColorBits = bpp;
13211378 pfd.iLayerType = PFD_MAIN_PLANE;
1322 - hDC = GetDC(RenderWnd->GetHWnd());
1323 - if(!hDC)
 1379+ This->hDC = GetDC(This->RenderWnd->GetHWnd());
 1380+ if(!This->hDC)
13241381 DEBUG("glRenderer::SetWnd: Can not create hDC\n");
1325 - pf = ChoosePixelFormat(hDC,&pfd);
 1382+ pf = ChoosePixelFormat(This->hDC,&pfd);
13261383 if(!pf)
13271384 DEBUG("glRenderer::SetWnd: Can not get pixelformat\n");
1328 - if(!SetPixelFormat(hDC,pf,&pfd))
 1385+ if(!SetPixelFormat(This->hDC,pf,&pfd))
13291386 DEBUG("glRenderer::SetWnd: Can not set pixelformat\n");
1330 - if(!wglMakeCurrent(hDC,hRC))
 1387+ if(!wglMakeCurrent(This->hDC,This->hRC))
13311388 DEBUG("glRenderer::SetWnd: Can not activate GL context\n");
13321389 InterlockedDecrement(&gllock);
13331390 LeaveCriticalSection(&dll_cs);
1334 - _SetSwap(1);
1335 - SwapBuffers(hDC);
1336 - timer.Calibrate(height, frequency);
1337 - _SetSwap(0);
1338 - util->SetViewport(0,0,width,height);
 1391+ glRenderer__SetSwap(This,1);
 1392+ SwapBuffers(This->hDC);
 1393+ This->timer.Calibrate(height, frequency);
 1394+ glRenderer__SetSwap(This,0);
 1395+ This->util->SetViewport(0,0,width,height);
13391396 }
13401397
1341 - SetEvent(busy);
 1398+ SetEvent(This->busy);
13421399 }
13431400
1344 -void glRenderer::SetBlend(DWORD src, DWORD dest)
 1401+void glRenderer_SetBlend(glRenderer *This, DWORD src, DWORD dest)
13451402 {
13461403 GLenum glsrc, gldest;
13471404 bool bothalpha = false;
@@ -1439,10 +1496,10 @@
14401497 gldest = GL_SRC_ALPHA;
14411498 break;
14421499 }
1443 - util->BlendFunc(glsrc,gldest);
 1500+ This->util->BlendFunc(glsrc,gldest);
14441501 }
14451502
1446 -void glRenderer::_DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
 1503+void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
14471504 DWORD indexcount, DWORD flags)
14481505 {
14491506 bool transformed;
@@ -1455,26 +1512,26 @@
14561513 else transformed = false;
14571514 if(!vertices[0].data)
14581515 {
1459 - outputs[0] = (void*)DDERR_INVALIDPARAMS;
1460 - SetEvent(busy);
 1516+ This->outputs[0] = (void*)DDERR_INVALIDPARAMS;
 1517+ SetEvent(This->busy);
14611518 return;
14621519 }
14631520 __int64 shader = device->SelectShader(vertices);
1464 - shaders->SetShader(shader,device->texstages,texformats,2);
1465 - device->SetDepthComp(util);
1466 - if(device->renderstate[D3DRENDERSTATE_ZENABLE]) util->DepthTest(true);
1467 - else util->DepthTest(false);
1468 - if(device->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) util->DepthWrite(true);
1469 - else util->DepthWrite(false);
1470 - _GENSHADER prog = shaders->gen3d->genshaders[shaders->gen3d->current_genshader].shader;
1471 - util->EnableArray(prog.attribs[0],true);
1472 - ext->glVertexAttribPointer(prog.attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
 1521+ This->shaders->SetShader(shader,device->texstages,texformats,2);
 1522+ device->SetDepthComp(This->util);
 1523+ if(device->renderstate[D3DRENDERSTATE_ZENABLE]) This->util->DepthTest(true);
 1524+ else This->util->DepthTest(false);
 1525+ if(device->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) This->util->DepthWrite(true);
 1526+ else This->util->DepthWrite(false);
 1527+ _GENSHADER prog = This->shaders->gen3d->genshaders[This->shaders->gen3d->current_genshader].shader;
 1528+ This->util->EnableArray(prog.attribs[0],true);
 1529+ This->ext->glVertexAttribPointer(prog.attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
14731530 if(transformed)
14741531 {
14751532 if(prog.attribs[1] != -1)
14761533 {
1477 - util->EnableArray(prog.attribs[1],true);
1478 - ext->glVertexAttribPointer(prog.attribs[1],4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
 1534+ This->util->EnableArray(prog.attribs[1],true);
 1535+ This->ext->glVertexAttribPointer(prog.attribs[1],4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
14791536 }
14801537 }
14811538 for(i = 0; i < 5; i++)
@@ -1483,8 +1540,8 @@
14841541 {
14851542 if(prog.attribs[i+2] != -1)
14861543 {
1487 - util->EnableArray(prog.attribs[i+2],true);
1488 - ext->glVertexAttribPointer(prog.attribs[i+2],1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
 1544+ This->util->EnableArray(prog.attribs[i+2],true);
 1545+ This->ext->glVertexAttribPointer(prog.attribs[i+2],1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
14891546 }
14901547 }
14911548 }
@@ -1492,8 +1549,8 @@
14931550 {
14941551 if(prog.attribs[7] != -1)
14951552 {
1496 - util->EnableArray(prog.attribs[7],true);
1497 - ext->glVertexAttribPointer(prog.attribs[7],3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
 1553+ This->util->EnableArray(prog.attribs[7],true);
 1554+ This->ext->glVertexAttribPointer(prog.attribs[7],3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
14981555 }
14991556 }
15001557 for(i = 0; i < 2; i++)
@@ -1502,8 +1559,8 @@
15031560 {
15041561 if(prog.attribs[8+i] != -1)
15051562 {
1506 - util->EnableArray(prog.attribs[8+i],true);
1507 - ext->glVertexAttribPointer(prog.attribs[8+i],4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
 1563+ This->util->EnableArray(prog.attribs[8+i],true);
 1564+ This->ext->glVertexAttribPointer(prog.attribs[8+i],4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
15081565 }
15091566 }
15101567 }
@@ -1517,29 +1574,29 @@
15181575 case 0: // st
15191576 if(prog.attribs[i+18] != -1)
15201577 {
1521 - util->EnableArray(prog.attribs[i+18],true);
1522 - ext->glVertexAttribPointer(prog.attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
 1578+ This->util->EnableArray(prog.attribs[i+18],true);
 1579+ This->ext->glVertexAttribPointer(prog.attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
15231580 }
15241581 break;
15251582 case 1: // str
15261583 if(prog.attribs[i+26] != -1)
15271584 {
1528 - util->EnableArray(prog.attribs[i+26],true);
1529 - ext->glVertexAttribPointer(prog.attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
 1585+ This->util->EnableArray(prog.attribs[i+26],true);
 1586+ This->ext->glVertexAttribPointer(prog.attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
15301587 }
15311588 break;
15321589 case 2: // strq
15331590 if(prog.attribs[i+34] != -1)
15341591 {
1535 - util->EnableArray(prog.attribs[i+34],true);
1536 - ext->glVertexAttribPointer(prog.attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
 1592+ This->util->EnableArray(prog.attribs[i+34],true);
 1593+ This->ext->glVertexAttribPointer(prog.attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
15371594 }
15381595 break;
15391596 case 3: // s
15401597 if(prog.attribs[i+10] != -1)
15411598 {
1542 - util->EnableArray(prog.attribs[i+10],true);
1543 - ext->glVertexAttribPointer(prog.attribs[i+10],1,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
 1599+ This->util->EnableArray(prog.attribs[i+10],true);
 1600+ This->ext->glVertexAttribPointer(prog.attribs[i+10],1,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
15441601 }
15451602 break;
15461603 }
@@ -1546,10 +1603,10 @@
15471604
15481605 }
15491606 }
1550 - if(device->modelview_dirty) util->SetMatrix(GL_MODELVIEW,device->matView,device->matWorld,&device->modelview_dirty);
1551 - if(device->projection_dirty) util->SetMatrix(GL_PROJECTION,device->matProjection,NULL,&device->projection_dirty);
 1607+ if(device->modelview_dirty) This->util->SetMatrix(GL_MODELVIEW,device->matView,device->matWorld,&device->modelview_dirty);
 1608+ if(device->projection_dirty) This->util->SetMatrix(GL_PROJECTION,device->matProjection,NULL,&device->projection_dirty);
15521609
1553 - util->SetMaterial((GLfloat*)&device->material.ambient,(GLfloat*)&device->material.diffuse,(GLfloat*)&device->material.specular,
 1610+ This->util->SetMaterial((GLfloat*)&device->material.ambient,(GLfloat*)&device->material.diffuse,(GLfloat*)&device->material.specular,
15541611 (GLfloat*)&device->material.emissive,device->material.power);
15551612
15561613 int lightindex = 0;
@@ -1558,33 +1615,33 @@
15591616 {
15601617 if(device->gllights[i] != -1)
15611618 {
1562 - if(prog.uniforms[0] != -1) ext->glUniformMatrix4fv(prog.uniforms[0],1,false,device->matWorld);
 1619+ if(prog.uniforms[0] != -1) This->ext->glUniformMatrix4fv(prog.uniforms[0],1,false,device->matWorld);
15631620 if(prog.uniforms[20+(i*12)] != -1)
1564 - ext->glUniform4fv(prog.uniforms[20+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
 1621+ This->ext->glUniform4fv(prog.uniforms[20+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvDiffuse);
15651622 if(prog.uniforms[21+(i*12)] != -1)
1566 - ext->glUniform4fv(prog.uniforms[21+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvSpecular);
 1623+ This->ext->glUniform4fv(prog.uniforms[21+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvSpecular);
15671624 if(prog.uniforms[22+(i*12)] != -1)
1568 - ext->glUniform4fv(prog.uniforms[22+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvAmbient);
 1625+ This->ext->glUniform4fv(prog.uniforms[22+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dcvAmbient);
15691626 if(prog.uniforms[24+(i*12)] != -1)
1570 - ext->glUniform3fv(prog.uniforms[24+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvDirection);
 1627+ This->ext->glUniform3fv(prog.uniforms[24+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvDirection);
15711628 if(device->lights[device->gllights[i]]->light.dltType != D3DLIGHT_DIRECTIONAL)
15721629 {
15731630 if(prog.uniforms[23+(i*12)] != -1)
1574 - ext->glUniform3fv(prog.uniforms[23+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvPosition);
 1631+ This->ext->glUniform3fv(prog.uniforms[23+(i*12)],1,(GLfloat*)&device->lights[device->gllights[i]]->light.dvPosition);
15751632 if(prog.uniforms[25+(i*12)] != -1)
1576 - ext->glUniform1f(prog.uniforms[25+(i*12)],device->lights[device->gllights[i]]->light.dvRange);
 1633+ This->ext->glUniform1f(prog.uniforms[25+(i*12)],device->lights[device->gllights[i]]->light.dvRange);
15771634 if(prog.uniforms[26+(i*12)] != -1)
1578 - ext->glUniform1f(prog.uniforms[26+(i*12)],device->lights[device->gllights[i]]->light.dvFalloff);
 1635+ This->ext->glUniform1f(prog.uniforms[26+(i*12)],device->lights[device->gllights[i]]->light.dvFalloff);
15791636 if(prog.uniforms[27+(i*12)] != -1)
1580 - ext->glUniform1f(prog.uniforms[27+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation0);
 1637+ This->ext->glUniform1f(prog.uniforms[27+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation0);
15811638 if(prog.uniforms[28+(i*12)] != -1)
1582 - ext->glUniform1f(prog.uniforms[28+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation1);
 1639+ This->ext->glUniform1f(prog.uniforms[28+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation1);
15831640 if(prog.uniforms[29+(i*12)] != -1)
1584 - ext->glUniform1f(prog.uniforms[29+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation2);
 1641+ This->ext->glUniform1f(prog.uniforms[29+(i*12)],device->lights[device->gllights[i]]->light.dvAttenuation2);
15851642 if(prog.uniforms[30+(i*12)] != -1)
1586 - ext->glUniform1f(prog.uniforms[30+(i*12)],device->lights[device->gllights[i]]->light.dvTheta);
 1643+ This->ext->glUniform1f(prog.uniforms[30+(i*12)],device->lights[device->gllights[i]]->light.dvTheta);
15871644 if(prog.uniforms[31+(i*12)] != -1)
1588 - ext->glUniform1f(prog.uniforms[31+(i*12)],device->lights[device->gllights[i]]->light.dvPhi);
 1645+ This->ext->glUniform1f(prog.uniforms[31+(i*12)],device->lights[device->gllights[i]]->light.dvPhi);
15891646 }
15901647 }
15911648 lightindex++;
@@ -1592,7 +1649,7 @@
15931650
15941651 DWORD ambient = device->renderstate[D3DRENDERSTATE_AMBIENT];
15951652 if(prog.uniforms[136] != -1)
1596 - ext->glUniform4f(prog.uniforms[136],RGBA_GETRED(ambient),RGBA_GETGREEN(ambient),
 1653+ This->ext->glUniform4f(prog.uniforms[136],RGBA_GETRED(ambient),RGBA_GETGREEN(ambient),
15971654 RGBA_GETBLUE(ambient),RGBA_GETALPHA(ambient));
15981655 GLint keycolor[4];
15991656 for(i = 0; i < 8; i++)
@@ -1602,7 +1659,7 @@
16031660 {
16041661 if(device->texstages[i].texture->dirty & 1)
16051662 {
1606 - _UploadTexture(device->texstages[i].texture->buffer,device->texstages[i].texture->bigbuffer,
 1663+ glRenderer__UploadTexture(This,device->texstages[i].texture->buffer,device->texstages[i].texture->bigbuffer,
16071664 device->texstages[i].texture->texture,device->texstages[i].texture->ddsd.dwWidth,
16081665 device->texstages[i].texture->ddsd.dwHeight,device->texstages[i].texture->fakex,
16091666 device->texstages[i].texture->fakey,device->texstages[i].texture->ddsd.lPitch,
@@ -1611,60 +1668,60 @@
16121669 device->texstages[i].texture->dirty &= ~1;
16131670 }
16141671 if(device->texstages[i].texture)
1615 - device->texstages[i].texture->SetFilter(i,device->texstages[i].glmagfilter,device->texstages[i].glminfilter,ext,texman);
1616 - TextureManager_SetTexture(texman,i,device->texstages[i].texture->texture);
1617 - util->SetWrap(i,0,device->texstages[i].addressu,texman);
1618 - util->SetWrap(i,1,device->texstages[i].addressv,texman);
 1672+ device->texstages[i].texture->SetFilter(i,device->texstages[i].glmagfilter,device->texstages[i].glminfilter,This->ext,This->texman);
 1673+ TextureManager_SetTexture(This->texman,i,device->texstages[i].texture->texture);
 1674+ This->util->SetWrap(i,0,device->texstages[i].addressu,This->texman);
 1675+ This->util->SetWrap(i,1,device->texstages[i].addressv,This->texman);
16191676 }
1620 - TextureManager_SetTexture(texman,i,0);
1621 - ext->glUniform1i(prog.uniforms[128+i],i);
 1677+ TextureManager_SetTexture(This->texman,i,0);
 1678+ This->ext->glUniform1i(prog.uniforms[128+i],i);
16221679 if(device->renderstate[D3DRENDERSTATE_COLORKEYENABLE] && device->texstages[i].texture && (prog.uniforms[142+i] != -1))
16231680 {
16241681 if(device->texstages[i].texture->ddsd.dwFlags & DDSD_CKSRCBLT)
16251682 {
16261683 dwordto4int(device->texstages[i].texture->colorkey[0].key.dwColorSpaceLowValue,keycolor);
1627 - ext->glUniform4iv(prog.uniforms[142+i],1,keycolor);
 1684+ This->ext->glUniform4iv(prog.uniforms[142+i],1,keycolor);
16281685 }
16291686 }
16301687 }
1631 - if(prog.uniforms[137]!= -1) ext->glUniform1f(prog.uniforms[137],device->viewport.dwWidth);
1632 - if(prog.uniforms[138]!= -1) ext->glUniform1f(prog.uniforms[138],device->viewport.dwHeight);
1633 - if(prog.uniforms[139]!= -1) ext->glUniform1f(prog.uniforms[139],device->viewport.dwX);
1634 - if(prog.uniforms[140]!= -1) ext->glUniform1f(prog.uniforms[140],device->viewport.dwY);
1635 - if(prog.uniforms[141]!= -1) ext->glUniform1i(prog.uniforms[141],device->renderstate[D3DRENDERSTATE_ALPHAREF]);
1636 - util->SetFBO(device->glDDS7);
1637 - util->SetViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
1638 - util->SetDepthRange(device->viewport.dvMinZ,device->viewport.dvMaxZ);
1639 - if(device->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) util->BlendEnable(true);
1640 - else util->BlendEnable(false);
1641 - SetBlend(device->renderstate[D3DRENDERSTATE_SRCBLEND],device->renderstate[D3DRENDERSTATE_DESTBLEND]);
1642 - util->SetCull((D3DCULL)device->renderstate[D3DRENDERSTATE_CULLMODE]);
1643 - _SetFogColor(device->renderstate[D3DRENDERSTATE_FOGCOLOR]);
1644 - _SetFogStart(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGSTART]));
1645 - _SetFogEnd(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGEND]));
1646 - _SetFogDensity(*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGDENSITY]));
1647 - util->SetPolyMode((D3DFILLMODE)device->renderstate[D3DRENDERSTATE_FILLMODE]);
1648 - util->SetShadeMode((D3DSHADEMODE)device->renderstate[D3DRENDERSTATE_SHADEMODE]);
 1688+ if(prog.uniforms[137]!= -1) This->ext->glUniform1f(prog.uniforms[137],device->viewport.dwWidth);
 1689+ if(prog.uniforms[138]!= -1) This->ext->glUniform1f(prog.uniforms[138],device->viewport.dwHeight);
 1690+ if(prog.uniforms[139]!= -1) This->ext->glUniform1f(prog.uniforms[139],device->viewport.dwX);
 1691+ if(prog.uniforms[140]!= -1) This->ext->glUniform1f(prog.uniforms[140],device->viewport.dwY);
 1692+ if(prog.uniforms[141]!= -1) This->ext->glUniform1i(prog.uniforms[141],device->renderstate[D3DRENDERSTATE_ALPHAREF]);
 1693+ This->util->SetFBO(device->glDDS7);
 1694+ This->util->SetViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
 1695+ This->util->SetDepthRange(device->viewport.dvMinZ,device->viewport.dvMaxZ);
 1696+ if(device->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) This->util->BlendEnable(true);
 1697+ else This->util->BlendEnable(false);
 1698+ glRenderer_SetBlend(This,device->renderstate[D3DRENDERSTATE_SRCBLEND],device->renderstate[D3DRENDERSTATE_DESTBLEND]);
 1699+ This->util->SetCull((D3DCULL)device->renderstate[D3DRENDERSTATE_CULLMODE]);
 1700+ glRenderer__SetFogColor(This,device->renderstate[D3DRENDERSTATE_FOGCOLOR]);
 1701+ glRenderer__SetFogStart(This,*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGSTART]));
 1702+ glRenderer__SetFogEnd(This,*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGEND]));
 1703+ glRenderer__SetFogDensity(This,*(GLfloat*)(&device->renderstate[D3DRENDERSTATE_FOGDENSITY]));
 1704+ This->util->SetPolyMode((D3DFILLMODE)device->renderstate[D3DRENDERSTATE_FILLMODE]);
 1705+ This->util->SetShadeMode((D3DSHADEMODE)device->renderstate[D3DRENDERSTATE_SHADEMODE]);
16491706 if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
16501707 else glDrawArrays(mode,0,count);
16511708 if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
16521709 device->glDDS7->dirty |= 2;
16531710 if(flags & D3DDP_WAIT) glFlush();
1654 - outputs[0] = (void*)D3D_OK;
1655 - SetEvent(busy);
 1711+ This->outputs[0] = (void*)D3D_OK;
 1712+ SetEvent(This->busy);
16561713 return;
16571714 }
16581715
1659 -void glRenderer::_DeleteFBO(FBO *fbo)
 1716+void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo)
16601717 {
1661 - util->DeleteFBO(fbo);
1662 - SetEvent(busy);
 1718+ This->util->DeleteFBO(fbo);
 1719+ SetEvent(This->busy);
16631720 }
16641721
1665 -void glRenderer::_SetFogColor(DWORD color)
 1722+void glRenderer__SetFogColor(glRenderer *This, DWORD color)
16661723 {
1667 - if (color == fogcolor) return;
1668 - fogcolor = color;
 1724+ if (color == This->fogcolor) return;
 1725+ This->fogcolor = color;
16691726 GLfloat colors[4];
16701727 colors[0] = (GLfloat)((color >> 16) & 255) / 255.0f;
16711728 colors[1] = (GLfloat)((color >> 8) & 255) / 255.0f;
@@ -1673,23 +1730,25 @@
16741731 glFogfv(GL_FOG_COLOR, colors);
16751732 }
16761733
1677 -void glRenderer::_SetFogStart(GLfloat start)
 1734+void glRenderer__SetFogStart(glRenderer *This, GLfloat start)
16781735 {
1679 - if (start == fogstart) return;
1680 - fogstart = start;
 1736+ if (start == This->fogstart) return;
 1737+ This->fogstart = start;
16811738 glFogf(GL_FOG_START, start);
16821739 }
16831740
1684 -void glRenderer::_SetFogEnd(GLfloat end)
 1741+void glRenderer__SetFogEnd(glRenderer *This, GLfloat end)
16851742 {
1686 - if (end == fogend) return;
1687 - fogend = end;
 1743+ if (end == This->fogend) return;
 1744+ This->fogend = end;
16881745 glFogf(GL_FOG_END, end);
16891746 }
16901747
1691 -void glRenderer::_SetFogDensity(GLfloat density)
 1748+void glRenderer__SetFogDensity(glRenderer *This, GLfloat density)
16921749 {
1693 - if (density == fogdensity) return;
1694 - fogdensity = density;
 1750+ if (density == This->fogdensity) return;
 1751+ This->fogdensity = density;
16951752 glFogf(GL_FOG_DENSITY, density);
16961753 }
 1754+
 1755+}
\ No newline at end of file
Index: ddraw/glRenderer.h
@@ -66,65 +66,28 @@
6767 #define OP_DRAWPRIMITIVES 12
6868 #define OP_DELETEFBO 13
6969
70 -
 70+#ifdef __cplusplus
7171 class glDirectDraw7;
7272 class glDirect3DDevice7;
7373 class glDirectDrawSurface7;
7474 class glRenderWindow;
 75+extern "C" {
 76+#else
 77+typedef int glDirectDraw7;
 78+typedef int glDirect3DDevice7;
 79+typedef int glDirectDrawSurface7;
 80+typedef int glRenderWindow;
 81+#endif
7582
76 -/** @brief glRenderer class
77 - * OpenGL renderer class for DXGL.
 83+/** @brief glRenderer struct
 84+ * OpenGL renderer structure for DXGL.
7885 */
79 -class glRenderer
 86+typedef struct glRenderer
8087 {
81 -public:
82 - glRenderer(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7);
83 - ~glRenderer();
84 - static DWORD WINAPI ThreadEntry(void *entry);
85 - void UploadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
86 - void DownloadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
87 - HRESULT Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
88 - glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
89 - void MakeTexture(TEXTURE *texture, DWORD width, DWORD height);
90 - void DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync);
91 - void DeleteTexture(TEXTURE *texture);
92 - void InitD3D(int zbuffer);
93 - void Flush();
94 - void SetWnd(int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd);
95 - HRESULT Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
96 - HRESULT DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
97 - DWORD indexcount, DWORD flags);
98 - void DeleteFBO(FBO *fbo);
99 - unsigned int GetScanLine();
10088 HGLRC hRC;
10189 GLCAPS gl_caps;
10290 glExtensions *ext;
103 -private:
104 - // In-thread APIs
105 - DWORD _Entry();
106 - BOOL _InitGL(int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
107 - void _UploadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
108 - void _DownloadTexture(char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
109 - void _Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
110 - glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
111 - void _MakeTexture(TEXTURE *texture, DWORD width, DWORD height);
112 - void _DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync);
113 - void _DeleteTexture(TEXTURE *texture);
114 - void _DrawBackbuffer(TEXTURE **texture, int x, int y, int progtype);
115 - void _InitD3D(int zbuffer);
116 - void _Clear(glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
117 - void glRenderer::_DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
118 - DWORD indexcount, DWORD flags);
11991 glDirectDraw7 *ddInterface;
120 - void _Flush();
121 - void _SetWnd(int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd);
122 - void _DeleteFBO(FBO *fbo);
123 - void _SetFogColor(DWORD color);
124 - void _SetFogStart(GLfloat start);
125 - void _SetFogEnd(GLfloat end);
126 - void _SetFogDensity(GLfloat density);
127 - inline void _SetSwap(int swap);
128 - void SetBlend(DWORD src, DWORD dest);
12992 int opcode;
13093 void* inputs[32];
13194 void* outputs[32];
@@ -152,6 +115,53 @@
153116 TextureManager *texman;
154117 glUtil *util;
155118 ShaderManager *shaders;
156 -};
 119+} glRenderer;
157120
 121+void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7);
 122+void glRenderer_Delete(glRenderer *This);
 123+static DWORD WINAPI glRenderer_ThreadEntry(void *entry);
 124+void glRenderer_UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
 125+void glRenderer_DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
 126+HRESULT glRenderer_Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
 127+ glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
 128+void glRenderer_MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height);
 129+void glRenderer_DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync);
 130+void glRenderer_DeleteTexture(glRenderer *This, TEXTURE *texture);
 131+void glRenderer_InitD3D(glRenderer *This, int zbuffer);
 132+void glRenderer_Flush(glRenderer *This);
 133+void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd);
 134+HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
 135+HRESULT glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
 136+ DWORD indexcount, DWORD flags);
 137+void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo);
 138+unsigned int glRenderer_GetScanLine(glRenderer *This);
 139+// In-thread APIs
 140+DWORD glRenderer__Entry(glRenderer *This);
 141+BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
 142+void glRenderer__UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
 143+void glRenderer__DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
 144+void glRenderer__Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
 145+ glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
 146+void glRenderer__MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height);
 147+void glRenderer__DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync);
 148+void glRenderer__DeleteTexture(glRenderer *This, TEXTURE *texture);
 149+void glRenderer__DrawBackbuffer(glRenderer *This, TEXTURE **texture, int x, int y, int progtype);
 150+void glRenderer__InitD3D(glRenderer *This, int zbuffer);
 151+void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
 152+void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
 153+ DWORD indexcount, DWORD flags);
 154+void glRenderer__Flush(glRenderer *This);
 155+void glRenderer__SetWnd(glRenderer *This, int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd);
 156+void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo);
 157+void glRenderer__SetFogColor(glRenderer *This, DWORD color);
 158+void glRenderer__SetFogStart(glRenderer *This, GLfloat start);
 159+void glRenderer__SetFogEnd(glRenderer *This, GLfloat end);
 160+void glRenderer__SetFogDensity(glRenderer *This, GLfloat density);
 161+inline void glRenderer__SetSwap(glRenderer *This, int swap);
 162+void glRenderer_SetBlend(glRenderer *This, DWORD src, DWORD dest);
 163+
 164+#ifdef __cplusplus
 165+}
 166+#endif
 167+
158168 #endif //_GLRENDERER_H
\ No newline at end of file