Index: ddraw/ddraw.cpp |
— | — | @@ -40,8 +40,12 @@ |
41 | 41 | void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7)
|
42 | 42 | {
|
43 | 43 | 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);
|
46 | 50 | TRACE_EXIT(0,0);
|
47 | 51 | }
|
48 | 52 |
|
Index: ddraw/ddraw.h |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | extern DXGLCFG dxglcfg;
|
61 | 61 | extern DWORD gllock;
|
62 | 62 | extern const GUID device_template;
|
63 | | -class glRenderer;
|
| 63 | +struct glRenderer;
|
64 | 64 | class glDirectDraw7;
|
65 | 65 | void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
|
66 | 66 |
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -366,7 +366,7 @@ |
367 | 367 | d3ddesc3.dwMaxTextureRepeat = d3ddesc3.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
|
368 | 368 | scalex = scaley = 0;
|
369 | 369 | mhWorld = mhView = mhProjection = 0;
|
370 | | - renderer->InitD3D(zbuffer);
|
| 370 | + glRenderer_InitD3D(renderer,zbuffer);
|
371 | 371 | error = D3D_OK;
|
372 | 372 | TRACE_EXIT(-1,0);
|
373 | 373 | }
|
— | — | @@ -574,7 +574,7 @@ |
575 | 575 | TRACE_ENTER(7,14,this,8,dwCount,14,lpRects,9,dwFlags,9,dwColor,19,&dvZ,9,dwStencil);
|
576 | 576 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
577 | 577 | 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));
|
579 | 579 | }
|
580 | 580 | HRESULT WINAPI glDirect3DDevice7::ComputeSphereVisibility(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres,
|
581 | 581 | DWORD dwFlags, LPDWORD lpdwReturnValues)
|
— | — | @@ -802,7 +802,7 @@ |
803 | 803 | if(lpwIndices) AddStats(d3dptPrimitiveType,dwIndexCount,&stats);
|
804 | 804 | else AddStats(d3dptPrimitiveType,dwVertexCount,&stats);
|
805 | 805 | 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,
|
807 | 807 | dwVertexCount,lpwIndices,dwIndexCount,dwFlags));
|
808 | 808 | }
|
809 | 809 | HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
— | — | @@ -854,7 +854,7 @@ |
855 | 855 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
856 | 856 | if(!inscene) TRACE_RET(HRESULT,23,D3DERR_SCENE_NOT_IN_SCENE);
|
857 | 857 | inscene = false;
|
858 | | - renderer->Flush();
|
| 858 | + glRenderer_Flush(renderer);
|
859 | 859 | TRACE_EXIT(23,D3D_OK);
|
860 | 860 | return D3D_OK;
|
861 | 861 | }
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -629,7 +629,11 @@ |
630 | 630 | }
|
631 | 631 | free(surfaces);
|
632 | 632 | }
|
633 | | - if(renderer) delete renderer;
|
| 633 | + if(renderer)
|
| 634 | + {
|
| 635 | + glRenderer_Delete(renderer);
|
| 636 | + free(renderer);
|
| 637 | + }
|
634 | 638 | renderer = NULL;
|
635 | 639 | }
|
636 | 640 | TRACE_EXIT(-1,0);
|
— | — | @@ -1112,7 +1116,7 @@ |
1113 | 1117 | if(!renderer) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
|
1114 | 1118 | if(!primary) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
|
1115 | 1119 | if(!initialized) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
|
1116 | | - *lpdwScanLine = renderer->GetScanLine();
|
| 1120 | + *lpdwScanLine = glRenderer_GetScanLine(renderer);
|
1117 | 1121 | if(*lpdwScanLine >= primary->fakey) TRACE_RET(HRESULT,23,DDERR_VERTICALBLANKINPROGRESS);
|
1118 | 1122 | TRACE_EXIT(23,DD_OK);
|
1119 | 1123 | return DD_OK;
|
— | — | @@ -1125,7 +1129,7 @@ |
1126 | 1130 | if(!renderer) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
|
1127 | 1131 | if(!primary) TRACE_RET(HRESULT,23,DDERR_NOTINITIALIZED);
|
1128 | 1132 | 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;
|
1130 | 1134 | else *lpbIsInVB = FALSE;
|
1131 | 1135 | TRACE_EXIT(23,DD_OK);
|
1132 | 1136 | return DD_OK;
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | class glDirectDrawSurface7;
|
26 | 26 | struct glDirectDrawClipper;
|
27 | 27 | class glDirect3D7;
|
28 | | -class glRenderer;
|
| 28 | +struct glRenderer;
|
29 | 29 |
|
30 | 30 | class glDirectDraw1;
|
31 | 31 | class glDirectDraw2;
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -140,7 +140,7 @@ |
141 | 141 | paltex->pixelformat.dwGBitMask = 0xFF00;
|
142 | 142 | paltex->pixelformat.dwRBitMask = 0xFF;
|
143 | 143 | paltex->pixelformat.dwRGBBitCount = 32;
|
144 | | - ddInterface->renderer->MakeTexture(paltex,256,1);
|
| 144 | + glRenderer_MakeTexture(ddInterface->renderer,paltex,256,1);
|
145 | 145 | }
|
146 | 146 | else paltex = NULL;
|
147 | 147 | }
|
— | — | @@ -310,7 +310,7 @@ |
311 | 311 | else texture->minfilter = texture->magfilter = GL_NEAREST;
|
312 | 312 | }
|
313 | 313 | texture->wraps = texture->wrapt = GL_CLAMP_TO_EDGE;
|
314 | | - ddInterface->renderer->MakeTexture(texture,fakex,fakey);
|
| 314 | + glRenderer_MakeTexture(ddInterface->renderer,texture,fakex,fakey);
|
315 | 315 | }
|
316 | 316 |
|
317 | 317 | if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
|
— | — | @@ -356,21 +356,21 @@ |
357 | 357 | if(dds4) dds4->Release();
|
358 | 358 | if(paltex)
|
359 | 359 | {
|
360 | | - ddInterface->renderer->DeleteTexture(paltex);
|
| 360 | + glRenderer_DeleteTexture(ddInterface->renderer, paltex);
|
361 | 361 | delete paltex;
|
362 | 362 | }
|
363 | 363 | if(texture)
|
364 | 364 | {
|
365 | | - ddInterface->renderer->DeleteTexture(texture);
|
| 365 | + glRenderer_DeleteTexture(ddInterface->renderer, texture);
|
366 | 366 | delete texture;
|
367 | 367 | }
|
368 | 368 | if(stencil)
|
369 | 369 | {
|
370 | | - ddInterface->renderer->DeleteTexture(stencil);
|
| 370 | + glRenderer_DeleteTexture(ddInterface->renderer, stencil);
|
371 | 371 | delete stencil;
|
372 | 372 | }
|
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);
|
375 | 375 | if(bitmapinfo) free(bitmapinfo);
|
376 | 376 | if(palette) glDirectDrawPalette_Release(palette);
|
377 | 377 | if(backbuffer) backbuffer->Release();
|
— | — | @@ -615,7 +615,7 @@ |
616 | 616 | glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
|
617 | 617 | if(dirty & 1)
|
618 | 618 | {
|
619 | | - ddInterface->renderer->UploadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
| 619 | + glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
620 | 620 | fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
621 | 621 | ddsd.ddpfPixelFormat.dwRGBBitCount);
|
622 | 622 | dirty &= ~1;
|
— | — | @@ -622,7 +622,7 @@ |
623 | 623 | }
|
624 | 624 | if(src && (src->dirty & 1))
|
625 | 625 | {
|
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,
|
627 | 627 | src->fakex,src->fakey,src->ddsd.lPitch,
|
628 | 628 | (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
|
629 | 629 | src->ddsd.ddpfPixelFormat.dwRGBBitCount);
|
— | — | @@ -639,7 +639,7 @@ |
640 | 640 | if (error) TRACE_RET(HRESULT, 23, error);
|
641 | 641 | TRACE_RET(HRESULT,23,this->Blt(lpDestRect, ddInterface->tmpsurface, &tmprect, dwFlags, lpDDBltFx));
|
642 | 642 | }
|
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));
|
644 | 644 | }
|
645 | 645 | HRESULT WINAPI glDirectDrawSurface7::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
|
646 | 646 | {
|
— | — | @@ -769,7 +769,7 @@ |
770 | 770 | tmp = this;
|
771 | 771 | if(dirty & 1)
|
772 | 772 | {
|
773 | | - ddInterface->renderer->UploadTexture(buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
| 773 | + glRenderer_UploadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,
|
774 | 774 | fakex,fakey,ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*fakex)),
|
775 | 775 | ddsd.ddpfPixelFormat.dwRGBBitCount);
|
776 | 776 | dirty &= ~1;
|
— | — | @@ -780,7 +780,7 @@ |
781 | 781 | tmp = tmp->GetBackbuffer();
|
782 | 782 | if(tmp->dirty & 1)
|
783 | 783 | {
|
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,
|
785 | 785 | tmp->fakex,tmp->fakey,tmp->ddsd.lPitch,(NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*tmp->fakex)),
|
786 | 786 | tmp->ddsd.ddpfPixelFormat.dwRGBBitCount);
|
787 | 787 | tmp->dirty &= ~1;
|
— | — | @@ -1034,7 +1034,7 @@ |
1035 | 1035 | break;
|
1036 | 1036 | case 0:
|
1037 | 1037 | 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,
|
1039 | 1039 | (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount);
|
1040 | 1040 | ddsd.lpSurface = buffer;
|
1041 | 1041 | dirty &= ~2;
|
— | — | @@ -1049,7 +1049,7 @@ |
1050 | 1050 | if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
1051 | 1051 | bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOfWord(fakex) * fakey)/8);
|
1052 | 1052 | 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,
|
1054 | 1054 | (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount);
|
1055 | 1055 | dirty &= ~2;
|
1056 | 1056 | surfacetype = 0;
|
— | — | @@ -1113,8 +1113,8 @@ |
1114 | 1114 | }
|
1115 | 1115 | if(backbuffer) backbuffer->Restore2();
|
1116 | 1116 | 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);
|
1119 | 1119 | }
|
1120 | 1120 | TRACE_EXIT(0,0);
|
1121 | 1121 | }
|
— | — | @@ -1159,8 +1159,8 @@ |
1160 | 1160 | if(backbuffer) backbuffer->Restore();
|
1161 | 1161 | if(zbuffer) zbuffer->Restore();
|
1162 | 1162 | }
|
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);
|
1165 | 1165 | TRACE_EXIT(23,DD_OK);
|
1166 | 1166 | return DD_OK;
|
1167 | 1167 | }
|
— | — | @@ -1293,7 +1293,7 @@ |
1294 | 1294 | void glDirectDrawSurface7::RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface, int vsync)
|
1295 | 1295 | {
|
1296 | 1296 | 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);
|
1298 | 1298 | TRACE_EXIT(0,0);
|
1299 | 1299 | }
|
1300 | 1300 | // ddraw 2+ api
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -31,6 +31,8 @@ |
32 | 32 | #include "ShaderGen3D.h"
|
33 | 33 | #include "matrix.h"
|
34 | 34 |
|
| 35 | +extern "C" {
|
| 36 | +
|
35 | 37 | const GLushort bltindices[4] = {0,1,2,3};
|
36 | 38 |
|
37 | 39 | /**
|
— | — | @@ -59,21 +61,25 @@ |
60 | 62 |
|
61 | 63 | /**
|
62 | 64 | * Sets the Windows OpenGL swap interval
|
| 65 | + * @param This
|
| 66 | + * Pointer to glRenderer object
|
63 | 67 | * @param swap
|
64 | 68 | * Number of vertical retraces to wait per frame, 0 disable vsync
|
65 | 69 | */
|
66 | | -inline void glRenderer::_SetSwap(int swap)
|
| 70 | +inline void glRenderer__SetSwap(glRenderer *This, int swap)
|
67 | 71 | {
|
68 | | - if(swap != oldswap)
|
| 72 | + if(swap != This->oldswap)
|
69 | 73 | {
|
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;
|
73 | 77 | }
|
74 | 78 | }
|
75 | 79 |
|
76 | 80 | /**
|
77 | 81 | * Internal function for uploading surface content to an OpenGL texture
|
| 82 | + * @param This
|
| 83 | + * Pointer to glRenderer object
|
78 | 84 | * @param buffer
|
79 | 85 | * Contains the contents of the surface
|
80 | 86 | * @param bigbuffer
|
— | — | @@ -92,13 +98,13 @@ |
93 | 99 | * @param bpp
|
94 | 100 | * Number of bits per surface pixel
|
95 | 101 | */
|
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,
|
97 | 103 | int bigx, int bigy, int pitch, int bigpitch, int bpp)
|
98 | 104 | {
|
99 | 105 | if(bpp == 15) bpp = 16;
|
100 | 106 | if((x == bigx && y == bigy) || !bigbuffer)
|
101 | 107 | {
|
102 | | - TextureManager__UploadTexture(texman, texture, 0, buffer, x, y);
|
| 108 | + TextureManager__UploadTexture(This->texman, texture, 0, buffer, x, y);
|
103 | 109 | }
|
104 | 110 | else
|
105 | 111 | {
|
— | — | @@ -118,12 +124,14 @@ |
119 | 125 | break;
|
120 | 126 | break;
|
121 | 127 | }
|
122 | | - TextureManager__UploadTexture(texman,texture,0,bigbuffer,bigx,bigy);
|
| 128 | + TextureManager__UploadTexture(This->texman,texture,0,bigbuffer,bigx,bigy);
|
123 | 129 | }
|
124 | 130 | }
|
125 | 131 |
|
126 | 132 | /**
|
127 | 133 | * Internal function for downloading surface content from an OpenGL texture
|
| 134 | + * @param This
|
| 135 | + * Pointer to glRenderer object
|
128 | 136 | * @param buffer
|
129 | 137 | * Buffer to receive the surface contents
|
130 | 138 | * @param bigbuffer
|
— | — | @@ -142,16 +150,16 @@ |
143 | 151 | * @param bpp
|
144 | 152 | * Number of bits per surface pixel
|
145 | 153 | */
|
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,
|
147 | 155 | int bigx, int bigy, int pitch, int bigpitch, int bpp)
|
148 | 156 | {
|
149 | 157 | if((bigx == x && bigy == y) || !bigbuffer)
|
150 | 158 | {
|
151 | | - TextureManager__DownloadTexture(texman,texture,0,buffer);
|
| 159 | + TextureManager__DownloadTexture(This->texman,texture,0,buffer);
|
152 | 160 | }
|
153 | 161 | else
|
154 | 162 | {
|
155 | | - TextureManager__DownloadTexture(texman,texture,0,bigbuffer);
|
| 163 | + TextureManager__DownloadTexture(This->texman,texture,0,bigbuffer);
|
156 | 164 | switch(bpp)
|
157 | 165 | {
|
158 | 166 | case 8:
|
— | — | @@ -173,7 +181,9 @@ |
174 | 182 | }
|
175 | 183 |
|
176 | 184 | /**
|
177 | | - * Constructor for the glRenderer object
|
| 185 | + * Initializes a glRenderer object
|
| 186 | + * @param This
|
| 187 | + * Pointer to glRenderer object to initialize
|
178 | 188 | * @param width,height,bpp
|
179 | 189 | * Width, height, and BPP of the rendering window
|
180 | 190 | * @param fullscreen
|
— | — | @@ -184,60 +194,62 @@ |
185 | 195 | * @param glDD7
|
186 | 196 | * Pointer to the glDirectDraw7 object that is managing the glRenderer object
|
187 | 197 | */
|
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)
|
189 | 199 | {
|
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);
|
204 | 214 | if(fullscreen)
|
205 | 215 | {
|
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);
|
209 | 219 | }
|
210 | 220 | if(width)
|
211 | 221 | {
|
212 | 222 | // TODO: Adjust window rect
|
213 | 223 | }
|
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);
|
226 | 236 | }
|
227 | 237 |
|
228 | 238 | /**
|
229 | | - * Destructor for the glRenderer object
|
| 239 | + * Deletes a glRenderer object
|
| 240 | + * @param This
|
| 241 | + * Pointer to glRenderer object
|
230 | 242 | */
|
231 | | -glRenderer::~glRenderer()
|
| 243 | +void glRenderer_Delete(glRenderer *This)
|
232 | 244 | {
|
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);
|
242 | 254 | }
|
243 | 255 |
|
244 | 256 | /**
|
— | — | @@ -245,15 +257,17 @@ |
246 | 258 | * @param entry
|
247 | 259 | * Pointer to the inputs passed by the CreateThread function
|
248 | 260 | */
|
249 | | -DWORD WINAPI glRenderer::ThreadEntry(void *entry)
|
| 261 | +DWORD WINAPI glRenderer_ThreadEntry(void *entry)
|
250 | 262 | {
|
251 | 263 | void **inputsin = (void**)entry;
|
252 | 264 | glRenderer *This = (glRenderer*)inputsin[7];
|
253 | | - return This->_Entry();
|
| 265 | + return glRenderer__Entry(This);
|
254 | 266 | }
|
255 | 267 |
|
256 | 268 | /**
|
257 | 269 | * Creates an OpenGL texture.
|
| 270 | + * @param This
|
| 271 | + * Pointer to glRenderer object
|
258 | 272 | * @param min,mag
|
259 | 273 | * Minification and magnification filters for the OpenGL texture
|
260 | 274 | * @param wraps,wrapt
|
— | — | @@ -269,20 +283,22 @@ |
270 | 284 | * @return
|
271 | 285 | * Number representing the texture created by OpenGL.
|
272 | 286 | */
|
273 | | -void glRenderer::MakeTexture(TEXTURE *texture, DWORD width, DWORD height)
|
| 287 | +void glRenderer_MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height)
|
274 | 288 | {
|
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);
|
283 | 297 | }
|
284 | 298 |
|
285 | 299 | /**
|
286 | 300 | * Uploads the content of a surface to an OpenGL texture.
|
| 301 | + * @param This
|
| 302 | + * Pointer to glRenderer object
|
287 | 303 | * @param buffer
|
288 | 304 | * Contains the contents of the surface
|
289 | 305 | * @param bigbuffer
|
— | — | @@ -301,28 +317,30 @@ |
302 | 318 | * @param bpp
|
303 | 319 | * Number of bits per surface pixel
|
304 | 320 | */
|
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,
|
306 | 322 | int bigx, int bigy, int pitch, int bigpitch, int bpp)
|
307 | 323 | {
|
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);
|
323 | 339 | }
|
324 | 340 |
|
325 | 341 | /**
|
326 | 342 | * Downloads the contents of an OpenGL texture to a surface buffer.
|
| 343 | + * @param This
|
| 344 | + * Pointer to glRenderer object
|
327 | 345 | * @param buffer
|
328 | 346 | * Buffer to receive the surface contents
|
329 | 347 | * @param bigbuffer
|
— | — | @@ -341,43 +359,47 @@ |
342 | 360 | * @param bpp
|
343 | 361 | * Number of bits per surface pixel
|
344 | 362 | */
|
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,
|
346 | 364 | int bigx, int bigy, int pitch, int bigpitch, int bpp)
|
347 | 365 | {
|
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);
|
363 | 381 | }
|
364 | 382 |
|
365 | 383 | /**
|
366 | 384 | * Deletes an OpenGL texture.
|
| 385 | + * @param This
|
| 386 | + * Pointer to glRenderer object
|
367 | 387 | * @param texture
|
368 | 388 | * OpenGL texture to be deleted
|
369 | 389 | */
|
370 | | -void glRenderer::DeleteTexture(TEXTURE * texture)
|
| 390 | +void glRenderer_DeleteTexture(glRenderer *This, TEXTURE * texture)
|
371 | 391 | {
|
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);
|
378 | 398 | }
|
379 | 399 |
|
380 | 400 | /**
|
381 | 401 | * Copies the contents of one surface to another.
|
| 402 | + * @param This
|
| 403 | + * Pointer to glRenderer object
|
382 | 404 | * @param lpDestRect
|
383 | 405 | * Pointer to the coordinates to blit to. If NULL, blits to the entire surface.
|
384 | 406 | * @param src
|
— | — | @@ -399,10 +421,10 @@ |
400 | 422 | * @return
|
401 | 423 | * DD_OK if the call succeeds, or DDERR_WASSTILLDRAWING if busy.
|
402 | 424 | */
|
403 | | -HRESULT glRenderer::Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
| 425 | +HRESULT glRenderer_Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
404 | 426 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
405 | 427 | {
|
406 | | - EnterCriticalSection(&cs);
|
| 428 | + EnterCriticalSection(&This->cs);
|
407 | 429 | RECT r,r2;
|
408 | 430 | if(((dest->ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
409 | 431 | (dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
— | — | @@ -409,26 +431,28 @@ |
410 | 432 | ((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
411 | 433 | !(dest->ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
|
412 | 434 | {
|
413 | | - GetClientRect(hWnd,&r);
|
414 | | - GetClientRect(RenderWnd->GetHWnd(),&r2);
|
| 435 | + GetClientRect(This->hWnd,&r);
|
| 436 | + GetClientRect(This->RenderWnd->GetHWnd(),&r2);
|
415 | 437 | 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);
|
417 | 439 | }
|
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];
|
429 | 451 | }
|
430 | 452 |
|
431 | 453 | /**
|
432 | 454 | * Updates the display with the current primary texture.
|
| 455 | + * @param This
|
| 456 | + * Pointer to glRenderer object
|
433 | 457 | * @param texture
|
434 | 458 | * Texture to use as the primary
|
435 | 459 | * @param paltex
|
— | — | @@ -440,36 +464,40 @@ |
441 | 465 | * @param vsync
|
442 | 466 | * Vertical sync count
|
443 | 467 | */
|
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)
|
445 | 469 | {
|
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);
|
456 | 480 | }
|
457 | 481 |
|
458 | 482 | /**
|
459 | 483 | * Ensures the renderer is set up for handling Direct3D commands.
|
| 484 | + * @param This
|
| 485 | + * Pointer to glRenderer object
|
460 | 486 | * @param zbuffer
|
461 | 487 | * Nonzero if a Z buffer is present.
|
462 | 488 | */
|
463 | | -void glRenderer::InitD3D(int zbuffer)
|
| 489 | +void glRenderer_InitD3D(glRenderer *This, int zbuffer)
|
464 | 490 | {
|
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);
|
470 | 496 | }
|
471 | 497 |
|
472 | 498 | /**
|
473 | 499 | * Clears the viewport.
|
| 500 | + * @param This
|
| 501 | + * Pointer to glRenderer object
|
474 | 502 | * @param target
|
475 | 503 | * Surface to be cleared
|
476 | 504 | * @param dwCount
|
— | — | @@ -487,37 +515,41 @@ |
488 | 516 | * @return
|
489 | 517 | * Returns D3D_OK
|
490 | 518 | */
|
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)
|
492 | 520 | {
|
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];
|
506 | 534 | }
|
507 | 535 |
|
508 | 536 | /**
|
509 | 537 | * Instructs the OpenGL driver to send all queued commands to the GPU.
|
| 538 | + * @param This
|
| 539 | + * Pointer to glRenderer object
|
510 | 540 | */
|
511 | | -void glRenderer::Flush()
|
| 541 | +void glRenderer_Flush(glRenderer *This)
|
512 | 542 | {
|
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);
|
518 | 548 | }
|
519 | 549 |
|
520 | 550 | /**
|
521 | 551 | * Changes the window used for rendering.
|
| 552 | + * @param This
|
| 553 | + * Pointer to glRenderer object
|
522 | 554 | * @param width,height
|
523 | 555 | * Width and height of the new window.
|
524 | 556 | * @param fullscreen
|
— | — | @@ -525,9 +557,9 @@ |
526 | 558 | * @param newwnd
|
527 | 559 | * HWND of the new window
|
528 | 560 | */
|
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)
|
530 | 562 | {
|
531 | | - EnterCriticalSection(&cs);
|
| 563 | + EnterCriticalSection(&This->cs);
|
532 | 564 | if(fullscreen && newwnd)
|
533 | 565 | {
|
534 | 566 | SetWindowLongPtrA(newwnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
|
— | — | @@ -534,19 +566,21 @@ |
535 | 567 | SetWindowLongPtrA(newwnd,GWL_STYLE,WS_OVERLAPPED);
|
536 | 568 | ShowWindow(newwnd,SW_MAXIMIZE);
|
537 | 569 | }
|
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);
|
548 | 580 | }
|
549 | 581 | /**
|
550 | 582 | * Draws one or more primitives to the currently selected render target.
|
| 583 | + * @param This
|
| 584 | + * Pointer to glRenderer object
|
551 | 585 | * @param device
|
552 | 586 | * glDirect3DDevice7 interface to use for drawing
|
553 | 587 | * @param mode
|
— | — | @@ -571,147 +605,163 @@ |
572 | 606 | * D3D_OK if the call succeeds, or D3DERR_INVALIDVERTEXTYPE if the vertex format
|
573 | 607 | * has no position coordinates.
|
574 | 608 | */
|
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,
|
576 | 610 | DWORD indexcount, DWORD flags)
|
577 | 611 | {
|
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];
|
592 | 626 | }
|
593 | 627 |
|
594 | 628 | /**
|
595 | 629 | * Deletes a framebuffer object.
|
| 630 | + * @param This
|
| 631 | + * Pointer to glRenderer object
|
596 | 632 | * @param fbo
|
597 | 633 | * FBO Structure containing framebuffer to delete.
|
598 | 634 | */
|
599 | | -void glRenderer::DeleteFBO(FBO *fbo)
|
| 635 | +void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo)
|
600 | 636 | {
|
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);
|
607 | 643 | }
|
608 | 644 |
|
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)
|
610 | 651 | {
|
611 | | - return timer.GetScanLine();
|
| 652 | + return This->timer.GetScanLine();
|
612 | 653 | }
|
613 | 654 |
|
614 | 655 | /**
|
615 | 656 | * Main loop for glRenderer class
|
| 657 | + * @param This
|
| 658 | + * Pointer to glRenderer object
|
616 | 659 | * @return
|
617 | 660 | * Returns 0 to signal successful thread termination
|
618 | 661 | */
|
619 | | -DWORD glRenderer::_Entry()
|
| 662 | +DWORD glRenderer__Entry(glRenderer *This)
|
620 | 663 | {
|
621 | 664 | 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);
|
626 | 671 | while(1)
|
627 | 672 | {
|
628 | | - WaitForSingleObject(start,INFINITE);
|
629 | | - switch(opcode)
|
| 673 | + WaitForSingleObject(This->start,INFINITE);
|
| 674 | + switch(This->opcode)
|
630 | 675 | {
|
631 | 676 | case OP_DELETE:
|
632 | | - if(hRC)
|
| 677 | + if(This->hRC)
|
633 | 678 | {
|
634 | | - if(dib.enabled)
|
| 679 | + if(This->dib.enabled)
|
635 | 680 | {
|
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));
|
639 | 684 | }
|
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)
|
643 | 688 | {
|
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;
|
647 | 692 | }
|
648 | | - if(backbuffer)
|
| 693 | + if(This->backbuffer)
|
649 | 694 | {
|
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;
|
655 | 700 | }
|
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;
|
661 | 706 | wglMakeCurrent(NULL,NULL);
|
662 | | - wglDeleteContext(hRC);
|
663 | | - hRC = NULL;
|
| 707 | + wglDeleteContext(This->hRC);
|
| 708 | + This->hRC = NULL;
|
664 | 709 | };
|
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);
|
670 | 715 | return 0;
|
671 | 716 | break;
|
672 | 717 | 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]);
|
674 | 720 | break;
|
675 | 721 | 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);
|
678 | 724 | break;
|
679 | 725 | 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);
|
683 | 730 | break;
|
684 | 731 | 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);
|
688 | 736 | break;
|
689 | 737 | case OP_DELETETEX:
|
690 | | - _DeleteTexture((TEXTURE*)inputs[0]);
|
| 738 | + glRenderer__DeleteTexture(This,(TEXTURE*)This->inputs[0]);
|
691 | 739 | break;
|
692 | 740 | 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]);
|
695 | 743 | break;
|
696 | 744 | 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);
|
698 | 747 | break;
|
699 | 748 | case OP_INITD3D:
|
700 | | - _InitD3D((int)inputs[0]);
|
| 749 | + glRenderer__InitD3D(This,(int)This->inputs[0]);
|
701 | 750 | break;
|
702 | 751 | 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]);
|
706 | 755 | break;
|
707 | 756 | case OP_FLUSH:
|
708 | | - _Flush();
|
| 757 | + glRenderer__Flush(This);
|
709 | 758 | break;
|
710 | 759 | 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]);
|
713 | 763 | break;
|
714 | 764 | case OP_DELETEFBO:
|
715 | | - _DeleteFBO((FBO*)inputs[0]);
|
| 765 | + glRenderer__DeleteFBO(This,(FBO*)This->inputs[0]);
|
716 | 766 | break;
|
717 | 767 | }
|
718 | 768 | }
|
— | — | @@ -720,6 +770,8 @@ |
721 | 771 |
|
722 | 772 | /**
|
723 | 773 | * Creates a render window and initializes OpenGL.
|
| 774 | + * @param This
|
| 775 | + * Pointer to glRenderer object
|
724 | 776 | * @param width,height
|
725 | 777 | * Width and height of the render window.
|
726 | 778 | * @param bpp
|
— | — | @@ -734,14 +786,14 @@ |
735 | 787 | * @return
|
736 | 788 | * TRUE if OpenGL has been initialized, FALSE otherwise.
|
737 | 789 | */
|
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)
|
739 | 791 | {
|
740 | 792 | EnterCriticalSection(&dll_cs);
|
741 | | - ddInterface = glDD7;
|
742 | | - if(hRC)
|
| 793 | + This->ddInterface = glDD7;
|
| 794 | + if(This->hRC)
|
743 | 795 | {
|
744 | 796 | wglMakeCurrent(NULL,NULL);
|
745 | | - wglDeleteContext(hRC);
|
| 797 | + wglDeleteContext(This->hRC);
|
746 | 798 | };
|
747 | 799 | PIXELFORMATDESCRIPTOR pfd;
|
748 | 800 | GLuint pf;
|
— | — | @@ -753,8 +805,8 @@ |
754 | 806 | pfd.cColorBits = bpp;
|
755 | 807 | pfd.iLayerType = PFD_MAIN_PLANE;
|
756 | 808 | InterlockedIncrement(&gllock);
|
757 | | - hDC = GetDC(RenderWnd->GetHWnd());
|
758 | | - if(!hDC)
|
| 809 | + This->hDC = GetDC(This->RenderWnd->GetHWnd());
|
| 810 | + if(!This->hDC)
|
759 | 811 | {
|
760 | 812 | DEBUG("glRenderer::InitGL: Can not create hDC\n");
|
761 | 813 | InterlockedDecrement(&gllock);
|
— | — | @@ -761,7 +813,7 @@ |
762 | 814 | LeaveCriticalSection(&dll_cs);
|
763 | 815 | return FALSE;
|
764 | 816 | }
|
765 | | - pf = ChoosePixelFormat(hDC,&pfd);
|
| 817 | + pf = ChoosePixelFormat(This->hDC,&pfd);
|
766 | 818 | if(!pf)
|
767 | 819 | {
|
768 | 820 | DEBUG("glRenderer::InitGL: Can not get pixelformat\n");
|
— | — | @@ -769,10 +821,10 @@ |
770 | 822 | LeaveCriticalSection(&dll_cs);
|
771 | 823 | return FALSE;
|
772 | 824 | }
|
773 | | - if(!SetPixelFormat(hDC,pf,&pfd))
|
| 825 | + if(!SetPixelFormat(This->hDC,pf,&pfd))
|
774 | 826 | 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)
|
777 | 829 | {
|
778 | 830 | DEBUG("glRenderer::InitGL: Can not create GL context\n");
|
779 | 831 | InterlockedDecrement(&gllock);
|
— | — | @@ -779,13 +831,13 @@ |
780 | 832 | LeaveCriticalSection(&dll_cs);
|
781 | 833 | return FALSE;
|
782 | 834 | }
|
783 | | - if(!wglMakeCurrent(hDC,hRC))
|
| 835 | + if(!wglMakeCurrent(This->hDC,This->hRC))
|
784 | 836 | {
|
785 | 837 | 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;
|
790 | 842 | InterlockedDecrement(&gllock);
|
791 | 843 | LeaveCriticalSection(&dll_cs);
|
792 | 844 | return FALSE;
|
— | — | @@ -792,99 +844,100 @@ |
793 | 845 | }
|
794 | 846 | InterlockedDecrement(&gllock);
|
795 | 847 | 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);
|
801 | 853 | 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);
|
805 | 857 | 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);
|
810 | 862 | glDisable(GL_DEPTH_TEST);
|
811 | | - util->SetDepthComp(GL_LESS);
|
| 863 | + This->util->SetDepthComp(GL_LESS);
|
812 | 864 | 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)
|
815 | 867 | {
|
816 | 868 | glver = glGetString(GL_SHADING_LANGUAGE_VERSION);
|
817 | | - gl_caps.ShaderVer = (GLfloat)atof((char*)glver);
|
| 869 | + This->gl_caps.ShaderVer = (GLfloat)atof((char*)glver);
|
818 | 870 | }
|
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);
|
830 | 882 | glClear(GL_COLOR_BUFFER_BIT);
|
831 | 883 | glFlush();
|
832 | | - util->SetScissor(false,0,0,0,0);
|
| 884 | + This->util->SetScissor(false,0,0,0,0);
|
833 | 885 | glDisable(GL_SCISSOR_TEST);
|
834 | | - util->SetCull(D3DCULL_CCW);
|
| 886 | + This->util->SetCull(D3DCULL_CCW);
|
835 | 887 | 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);
|
845 | 897 | if(hWnd)
|
846 | 898 | {
|
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);
|
861 | 914 | }
|
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);
|
867 | 920 | TRACE_SYSINFO();
|
868 | 921 | return TRUE;
|
869 | 922 | }
|
870 | 923 |
|
871 | | -void glRenderer::_Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
| 924 | +void glRenderer__Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
872 | 925 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
873 | 926 | {
|
874 | 927 | LONG sizes[6];
|
875 | | - ddInterface->GetSizes(sizes);
|
| 928 | + This->ddInterface->GetSizes(sizes);
|
876 | 929 | DWORD shaderid;
|
877 | 930 | if (lpDDBltFx) shaderid = PackROPBits(lpDDBltFx->dwROP, dwFlags);
|
878 | 931 | 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);
|
884 | 937 | RECT destrect;
|
885 | 938 | DDSURFACEDESC2 ddsd;
|
886 | 939 | ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
887 | 940 | dest->GetSurfaceDesc(&ddsd);
|
888 | | - util->DepthTest(false);
|
| 941 | + This->util->DepthTest(false);
|
889 | 942 | if(!lpDestRect)
|
890 | 943 | {
|
891 | 944 | destrect.left = 0;
|
— | — | @@ -905,48 +958,48 @@ |
906 | 959 | srcrect.bottom = ddsdSrc.dwHeight;
|
907 | 960 | }
|
908 | 961 | 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;
|
917 | 970 | if(dest->zbuffer) glClear(GL_DEPTH_BUFFER_BIT);
|
918 | 971 | if(dwFlags & DDBLT_COLORFILL)
|
919 | 972 | {
|
920 | | - switch(ddInterface->GetBPP())
|
| 973 | + switch(This->ddInterface->GetBPP())
|
921 | 974 | {
|
922 | 975 | 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;
|
927 | 980 | break;
|
928 | 981 | 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 =
|
930 | 983 | _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 =
|
932 | 985 | _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 =
|
934 | 987 | _5to8bit(lpDDBltFx->dwFillColor & 31);
|
935 | 988 | break;
|
936 | 989 | 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 =
|
938 | 991 | _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 =
|
940 | 993 | _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 =
|
942 | 995 | _5to8bit(lpDDBltFx->dwFillColor & 31);
|
943 | 996 | break;
|
944 | 997 | case 24:
|
945 | 998 | 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 =
|
947 | 1000 | ((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 =
|
949 | 1002 | ((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 =
|
951 | 1004 | (lpDDBltFx->dwFillColor & 255);
|
952 | 1005 | default:
|
953 | 1006 | break;
|
— | — | @@ -954,20 +1007,20 @@ |
955 | 1008 | }
|
956 | 1009 | if((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
|
957 | 1010 | {
|
958 | | - switch(ddInterface->GetBPP())
|
| 1011 | + switch(This->ddInterface->GetBPP())
|
959 | 1012 | {
|
960 | 1013 | 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,
|
963 | 1016 | src->colorkey[0].key.dwColorSpaceHighValue);
|
964 | 1017 | break;
|
965 | 1018 | 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),
|
967 | 1020 | _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 31),
|
968 | 1021 | _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
969 | 1022 | break;
|
970 | 1023 | 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),
|
972 | 1025 | _6to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 63),
|
973 | 1026 | _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
974 | 1027 | break;
|
— | — | @@ -974,139 +1027,141 @@ |
975 | 1028 | case 24:
|
976 | 1029 | case 32:
|
977 | 1030 | 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),
|
979 | 1032 | (src->colorkey[0].key.dwColorSpaceHighValue>>8 & 255),
|
980 | 1033 | (src->colorkey[0].key.dwColorSpaceHighValue & 255));
|
981 | 1034 | break;
|
982 | 1035 | }
|
983 | | - ext->glUniform1i(shader->shader.uniforms[1],0);
|
| 1036 | + This->ext->glUniform1i(shader->shader.uniforms[1],0);
|
984 | 1037 | }
|
985 | 1038 | else if(!(dwFlags & DDBLT_COLORFILL))
|
986 | 1039 | {
|
987 | | - ext->glUniform1i(shader->shader.uniforms[1],0);
|
| 1040 | + This->ext->glUniform1i(shader->shader.uniforms[1],0);
|
988 | 1041 | }
|
989 | 1042 | if(src)
|
990 | 1043 | {
|
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)
|
993 | 1046 | {
|
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);
|
996 | 1050 | }
|
997 | 1051 | }
|
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);
|
1000 | 1054 | 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);
|
1003 | 1057 | if(shader->shader.attribs[1] != -1)
|
1004 | 1058 | {
|
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);
|
1007 | 1061 | }
|
1008 | 1062 | if(!(dwFlags & DDBLT_COLORFILL))
|
1009 | 1063 | {
|
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);
|
1012 | 1066 | }
|
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);
|
1017 | 1071 | if(((ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
1018 | 1072 | (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
1019 | 1073 | ((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);
|
1023 | 1078 | }
|
1024 | 1079 |
|
1025 | | -void glRenderer::_MakeTexture(TEXTURE *texture, DWORD width, DWORD height)
|
| 1080 | +void glRenderer__MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height)
|
1026 | 1081 | {
|
1027 | | - TextureManager__CreateTexture(texman,texture,width,height);
|
| 1082 | + TextureManager__CreateTexture(This->texman,texture,width,height);
|
1028 | 1083 | }
|
1029 | 1084 |
|
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)
|
1031 | 1086 | {
|
1032 | 1087 | GLfloat view[4];
|
1033 | | - TextureManager_SetActiveTexture(texman,0);
|
1034 | | - if(!backbuffer)
|
| 1088 | + TextureManager_SetActiveTexture(This->texman,0);
|
| 1089 | + if(!This->backbuffer)
|
1035 | 1090 | {
|
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;
|
1048 | 1103 | }
|
1049 | | - if((backx != x) || (backy != y))
|
| 1104 | + if((This->backx != x) || (This->backy != y))
|
1050 | 1105 | {
|
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;
|
1054 | 1109 | }
|
1055 | | - util->SetFBO(&fbo,backbuffer,0,false);
|
| 1110 | + This->util->SetFBO(&This->fbo,This->backbuffer,0,false);
|
1056 | 1111 | view[0] = view[2] = 0;
|
1057 | 1112 | view[1] = (GLfloat)x;
|
1058 | 1113 | view[3] = (GLfloat)y;
|
1059 | | - util->SetViewport(0,0,x,y);
|
| 1114 | + This->util->SetViewport(0,0,x,y);
|
1060 | 1115 | 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);
|
1078 | 1133 | }
|
1079 | 1134 |
|
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)
|
1081 | 1136 | {
|
1082 | 1137 | int progtype;
|
1083 | 1138 | RECT r,r2;
|
1084 | | - util->BlendEnable(false);
|
| 1139 | + This->util->BlendEnable(false);
|
1085 | 1140 | if((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
1086 | 1141 | {
|
1087 | | - GetClientRect(hWnd,&r);
|
1088 | | - GetClientRect(RenderWnd->GetHWnd(),&r2);
|
| 1142 | + GetClientRect(This->hWnd,&r);
|
| 1143 | + GetClientRect(This->RenderWnd->GetHWnd(),&r2);
|
1089 | 1144 | 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);
|
1091 | 1146 | }
|
1092 | | - util->DepthTest(false);
|
| 1147 | + This->util->DepthTest(false);
|
1093 | 1148 | RECT *viewrect = &r2;
|
1094 | | - _SetSwap(vsync);
|
| 1149 | + glRenderer__SetSwap(This,vsync);
|
1095 | 1150 | LONG sizes[6];
|
1096 | 1151 | GLfloat view[4];
|
1097 | 1152 | GLint viewport[4];
|
1098 | 1153 | if(src->dirty & 1)
|
1099 | 1154 | {
|
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,
|
1101 | 1156 | src->fakex,src->fakey,src->ddsd.lPitch,
|
1102 | | - (NextMultipleOf4((ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
|
| 1157 | + (NextMultipleOf4((This->ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
|
1103 | 1158 | src->ddsd.ddpfPixelFormat.dwRGBBitCount);
|
1104 | 1159 | src->dirty &= ~1;
|
1105 | 1160 | }
|
1106 | 1161 | if(dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
1107 | 1162 | {
|
1108 | | - if(ddInterface->GetFullscreen())
|
| 1163 | + if(This->ddInterface->GetFullscreen())
|
1109 | 1164 | {
|
1110 | | - ddInterface->GetSizes(sizes);
|
| 1165 | + This->ddInterface->GetSizes(sizes);
|
1111 | 1166 | viewport[0] = viewport[1] = 0;
|
1112 | 1167 | viewport[2] = sizes[4];
|
1113 | 1168 | viewport[3] = sizes[5];
|
— | — | @@ -1120,8 +1175,8 @@ |
1121 | 1176 | viewport[0] = viewport[1] = 0;
|
1122 | 1177 | viewport[2] = viewrect->right;
|
1123 | 1178 | 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);
|
1126 | 1181 | view[0] = (GLfloat)viewrect->left;
|
1127 | 1182 | view[1] = (GLfloat)viewrect->right;
|
1128 | 1183 | view[2] = (GLfloat)dest->fakey-(GLfloat)viewrect->top;
|
— | — | @@ -1135,179 +1190,181 @@ |
1136 | 1191 | view[2] = 0;
|
1137 | 1192 | view[3] = (GLfloat)dest->fakey;
|
1138 | 1193 | }
|
1139 | | - util->SetFBO((FBO*)NULL);
|
| 1194 | + This->util->SetFBO((FBO*)NULL);
|
1140 | 1195 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
1141 | | - if(ddInterface->GetBPP() == 8)
|
| 1196 | + if(This->ddInterface->GetBPP() == 8)
|
1142 | 1197 | {
|
1143 | | - shaders->SetShader(PROG_PAL256,NULL,NULL,0);
|
| 1198 | + This->shaders->SetShader(PROG_PAL256,NULL,NULL,0);
|
1144 | 1199 | 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);
|
1150 | 1205 | if(dxglcfg.scalingfilter)
|
1151 | 1206 | {
|
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);
|
1154 | 1209 | 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);
|
1157 | 1212 | }
|
1158 | | - if(ext->GLEXT_ARB_sampler_objects)
|
| 1213 | + if(This->ext->GLEXT_ARB_sampler_objects)
|
1159 | 1214 | {
|
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);
|
1162 | 1217 | }
|
1163 | 1218 | }
|
1164 | 1219 | else
|
1165 | 1220 | {
|
1166 | | - shaders->SetShader(PROG_TEXTURE,NULL,NULL,0);
|
| 1221 | + This->shaders->SetShader(PROG_TEXTURE,NULL,NULL,0);
|
1167 | 1222 | 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);
|
1170 | 1225 | }
|
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())
|
1176 | 1233 | {
|
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];
|
1180 | 1237 | }
|
1181 | 1238 | else
|
1182 | 1239 | {
|
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;
|
1186 | 1243 | }
|
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)
|
1194 | 1251 | {
|
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);
|
1197 | 1254 | }
|
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);
|
1201 | 1258 | glFlush();
|
1202 | | - if(hWnd) SwapBuffers(hDC);
|
| 1259 | + if(This->hWnd) SwapBuffers(This->hDC);
|
1203 | 1260 | else
|
1204 | 1261 | {
|
1205 | 1262 | glReadBuffer(GL_FRONT);
|
1206 | | - ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,PBO);
|
| 1263 | + This->ext->glBindBuffer(GL_PIXEL_PACK_BUFFER,This->PBO);
|
1207 | 1264 | GLint packalign;
|
1208 | 1265 | glGetIntegerv(GL_PACK_ALIGNMENT,&packalign);
|
1209 | 1266 | glPixelStorei(GL_PACK_ALIGNMENT,1);
|
1210 | | - ddInterface->GetSizes(sizes);
|
| 1267 | + This->ddInterface->GetSizes(sizes);
|
1211 | 1268 | 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);
|
1213 | 1270 | for(int i = 0; i < sizes[5];i++)
|
1214 | 1271 | {
|
1215 | | - memcpy(&dib.pixels[dib.pitch*i],
|
| 1272 | + memcpy(&This->dib.pixels[This->dib.pitch*i],
|
1216 | 1273 | &pixels[((sizes[5]-1)-i)*(sizes[4]*4)],sizes[4]*4);
|
1217 | 1274 | }
|
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);
|
1220 | 1277 | glPixelStorei(GL_PACK_ALIGNMENT,packalign);
|
1221 | | - HDC hRenderDC = (HDC)::GetDC(RenderWnd->GetHWnd());
|
| 1278 | + HDC hRenderDC = (HDC)::GetDC(This->RenderWnd->GetHWnd());
|
1222 | 1279 | HGDIOBJ hPrevObj = 0;
|
1223 | 1280 | POINT dest = {0,0};
|
1224 | 1281 | POINT srcpoint = {0,0};
|
1225 | | - SIZE wnd = {dib.width,dib.height};
|
| 1282 | + SIZE wnd = {This->dib.width,This->dib.height};
|
1226 | 1283 | 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);
|
1233 | 1290 | }
|
1234 | | - if(setsync) SetEvent(busy);
|
| 1291 | + if(setsync) SetEvent(This->busy);
|
1235 | 1292 |
|
1236 | 1293 | }
|
1237 | 1294 |
|
1238 | | -void glRenderer::_DeleteTexture(TEXTURE *texture)
|
| 1295 | +void glRenderer__DeleteTexture(glRenderer *This, TEXTURE *texture)
|
1239 | 1296 | {
|
1240 | | - TextureManager__DeleteTexture(texman,texture);
|
1241 | | - SetEvent(busy);
|
| 1297 | + TextureManager__DeleteTexture(This->texman,texture);
|
| 1298 | + SetEvent(This->busy);
|
1242 | 1299 | }
|
1243 | 1300 |
|
1244 | | -void glRenderer::_InitD3D(int zbuffer)
|
| 1301 | +void glRenderer__InitD3D(glRenderer *This, int zbuffer)
|
1245 | 1302 | {
|
1246 | | - SetEvent(busy);
|
| 1303 | + SetEvent(This->busy);
|
1247 | 1304 | glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
1248 | 1305 | 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);
|
1251 | 1308 | GLfloat identity[16];
|
1252 | 1309 | __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);
|
1255 | 1312 | GLfloat one[4] = {1,1,1,1};
|
1256 | 1313 | GLfloat zero[4] = {0,0,0,1};
|
1257 | | - util->SetMaterial(one,one,zero,zero,0);
|
| 1314 | + This->util->SetMaterial(one,one,zero,zero,0);
|
1258 | 1315 | }
|
1259 | 1316 |
|
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)
|
1261 | 1318 | {
|
1262 | | - outputs[0] = (void*)D3D_OK;
|
| 1319 | + This->outputs[0] = (void*)D3D_OK;
|
1263 | 1320 | GLfloat color[4];
|
1264 | 1321 | dwordto4float(dwColor,color);
|
1265 | | - util->SetFBO(target);
|
| 1322 | + This->util->SetFBO(target);
|
1266 | 1323 | int clearbits = 0;
|
1267 | 1324 | if(dwFlags & D3DCLEAR_TARGET)
|
1268 | 1325 | {
|
1269 | 1326 | 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]);
|
1271 | 1328 | }
|
1272 | 1329 | if(dwFlags & D3DCLEAR_ZBUFFER)
|
1273 | 1330 | {
|
1274 | 1331 | clearbits |= GL_DEPTH_BUFFER_BIT;
|
1275 | | - util->ClearDepth(dvZ);
|
| 1332 | + This->util->ClearDepth(dvZ);
|
1276 | 1333 | }
|
1277 | 1334 | if(dwFlags & D3DCLEAR_STENCIL)
|
1278 | 1335 | {
|
1279 | 1336 | clearbits |= GL_STENCIL_BUFFER_BIT;
|
1280 | | - util->ClearStencil(dwStencil);
|
| 1337 | + This->util->ClearStencil(dwStencil);
|
1281 | 1338 | }
|
1282 | 1339 | if(dwCount)
|
1283 | 1340 | {
|
1284 | 1341 | for(DWORD i = 0; i < dwCount; i++)
|
1285 | 1342 | {
|
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);
|
1287 | 1344 | glClear(clearbits);
|
1288 | 1345 | }
|
1289 | | - util->SetScissor(false,0,0,0,0);
|
| 1346 | + This->util->SetScissor(false,0,0,0,0);
|
1290 | 1347 | }
|
1291 | 1348 | else glClear(clearbits);
|
1292 | 1349 | if(target->zbuffer) target->zbuffer->dirty |= 2;
|
1293 | 1350 | target->dirty |= 2;
|
1294 | | - SetEvent(busy);
|
| 1351 | + SetEvent(This->busy);
|
1295 | 1352 | }
|
1296 | 1353 |
|
1297 | | -void glRenderer::_Flush()
|
| 1354 | +void glRenderer__Flush(glRenderer *This)
|
1298 | 1355 | {
|
1299 | 1356 | glFlush();
|
1300 | | - SetEvent(busy);
|
| 1357 | + SetEvent(This->busy);
|
1301 | 1358 | }
|
1302 | 1359 |
|
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)
|
1304 | 1361 | {
|
1305 | | - if(newwnd != hWnd)
|
| 1362 | + if(newwnd != This->hWnd)
|
1306 | 1363 | {
|
1307 | 1364 | EnterCriticalSection(&dll_cs);
|
1308 | 1365 | 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);
|
1312 | 1369 | PIXELFORMATDESCRIPTOR pfd;
|
1313 | 1370 | GLuint pf;
|
1314 | 1371 | InterlockedIncrement(&gllock);
|
— | — | @@ -1318,29 +1375,29 @@ |
1319 | 1376 | pfd.iPixelType = PFD_TYPE_RGBA;
|
1320 | 1377 | pfd.cColorBits = bpp;
|
1321 | 1378 | pfd.iLayerType = PFD_MAIN_PLANE;
|
1322 | | - hDC = GetDC(RenderWnd->GetHWnd());
|
1323 | | - if(!hDC)
|
| 1379 | + This->hDC = GetDC(This->RenderWnd->GetHWnd());
|
| 1380 | + if(!This->hDC)
|
1324 | 1381 | DEBUG("glRenderer::SetWnd: Can not create hDC\n");
|
1325 | | - pf = ChoosePixelFormat(hDC,&pfd);
|
| 1382 | + pf = ChoosePixelFormat(This->hDC,&pfd);
|
1326 | 1383 | if(!pf)
|
1327 | 1384 | DEBUG("glRenderer::SetWnd: Can not get pixelformat\n");
|
1328 | | - if(!SetPixelFormat(hDC,pf,&pfd))
|
| 1385 | + if(!SetPixelFormat(This->hDC,pf,&pfd))
|
1329 | 1386 | DEBUG("glRenderer::SetWnd: Can not set pixelformat\n");
|
1330 | | - if(!wglMakeCurrent(hDC,hRC))
|
| 1387 | + if(!wglMakeCurrent(This->hDC,This->hRC))
|
1331 | 1388 | DEBUG("glRenderer::SetWnd: Can not activate GL context\n");
|
1332 | 1389 | InterlockedDecrement(&gllock);
|
1333 | 1390 | 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);
|
1339 | 1396 | }
|
1340 | 1397 |
|
1341 | | - SetEvent(busy);
|
| 1398 | + SetEvent(This->busy);
|
1342 | 1399 | }
|
1343 | 1400 |
|
1344 | | -void glRenderer::SetBlend(DWORD src, DWORD dest)
|
| 1401 | +void glRenderer_SetBlend(glRenderer *This, DWORD src, DWORD dest)
|
1345 | 1402 | {
|
1346 | 1403 | GLenum glsrc, gldest;
|
1347 | 1404 | bool bothalpha = false;
|
— | — | @@ -1439,10 +1496,10 @@ |
1440 | 1497 | gldest = GL_SRC_ALPHA;
|
1441 | 1498 | break;
|
1442 | 1499 | }
|
1443 | | - util->BlendFunc(glsrc,gldest);
|
| 1500 | + This->util->BlendFunc(glsrc,gldest);
|
1444 | 1501 | }
|
1445 | 1502 |
|
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,
|
1447 | 1504 | DWORD indexcount, DWORD flags)
|
1448 | 1505 | {
|
1449 | 1506 | bool transformed;
|
— | — | @@ -1455,26 +1512,26 @@ |
1456 | 1513 | else transformed = false;
|
1457 | 1514 | if(!vertices[0].data)
|
1458 | 1515 | {
|
1459 | | - outputs[0] = (void*)DDERR_INVALIDPARAMS;
|
1460 | | - SetEvent(busy);
|
| 1516 | + This->outputs[0] = (void*)DDERR_INVALIDPARAMS;
|
| 1517 | + SetEvent(This->busy);
|
1461 | 1518 | return;
|
1462 | 1519 | }
|
1463 | 1520 | __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);
|
1473 | 1530 | if(transformed)
|
1474 | 1531 | {
|
1475 | 1532 | if(prog.attribs[1] != -1)
|
1476 | 1533 | {
|
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);
|
1479 | 1536 | }
|
1480 | 1537 | }
|
1481 | 1538 | for(i = 0; i < 5; i++)
|
— | — | @@ -1483,8 +1540,8 @@ |
1484 | 1541 | {
|
1485 | 1542 | if(prog.attribs[i+2] != -1)
|
1486 | 1543 | {
|
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);
|
1489 | 1546 | }
|
1490 | 1547 | }
|
1491 | 1548 | }
|
— | — | @@ -1492,8 +1549,8 @@ |
1493 | 1550 | {
|
1494 | 1551 | if(prog.attribs[7] != -1)
|
1495 | 1552 | {
|
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);
|
1498 | 1555 | }
|
1499 | 1556 | }
|
1500 | 1557 | for(i = 0; i < 2; i++)
|
— | — | @@ -1502,8 +1559,8 @@ |
1503 | 1560 | {
|
1504 | 1561 | if(prog.attribs[8+i] != -1)
|
1505 | 1562 | {
|
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);
|
1508 | 1565 | }
|
1509 | 1566 | }
|
1510 | 1567 | }
|
— | — | @@ -1517,29 +1574,29 @@ |
1518 | 1575 | case 0: // st
|
1519 | 1576 | if(prog.attribs[i+18] != -1)
|
1520 | 1577 | {
|
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);
|
1523 | 1580 | }
|
1524 | 1581 | break;
|
1525 | 1582 | case 1: // str
|
1526 | 1583 | if(prog.attribs[i+26] != -1)
|
1527 | 1584 | {
|
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);
|
1530 | 1587 | }
|
1531 | 1588 | break;
|
1532 | 1589 | case 2: // strq
|
1533 | 1590 | if(prog.attribs[i+34] != -1)
|
1534 | 1591 | {
|
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);
|
1537 | 1594 | }
|
1538 | 1595 | break;
|
1539 | 1596 | case 3: // s
|
1540 | 1597 | if(prog.attribs[i+10] != -1)
|
1541 | 1598 | {
|
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);
|
1544 | 1601 | }
|
1545 | 1602 | break;
|
1546 | 1603 | }
|
— | — | @@ -1546,10 +1603,10 @@ |
1547 | 1604 |
|
1548 | 1605 | }
|
1549 | 1606 | }
|
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);
|
1552 | 1609 |
|
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,
|
1554 | 1611 | (GLfloat*)&device->material.emissive,device->material.power);
|
1555 | 1612 |
|
1556 | 1613 | int lightindex = 0;
|
— | — | @@ -1558,33 +1615,33 @@ |
1559 | 1616 | {
|
1560 | 1617 | if(device->gllights[i] != -1)
|
1561 | 1618 | {
|
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);
|
1563 | 1620 | 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);
|
1565 | 1622 | 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);
|
1567 | 1624 | 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);
|
1569 | 1626 | 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);
|
1571 | 1628 | if(device->lights[device->gllights[i]]->light.dltType != D3DLIGHT_DIRECTIONAL)
|
1572 | 1629 | {
|
1573 | 1630 | 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);
|
1575 | 1632 | 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);
|
1577 | 1634 | 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);
|
1579 | 1636 | 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);
|
1581 | 1638 | 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);
|
1583 | 1640 | 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);
|
1585 | 1642 | 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);
|
1587 | 1644 | 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);
|
1589 | 1646 | }
|
1590 | 1647 | }
|
1591 | 1648 | lightindex++;
|
— | — | @@ -1592,7 +1649,7 @@ |
1593 | 1650 |
|
1594 | 1651 | DWORD ambient = device->renderstate[D3DRENDERSTATE_AMBIENT];
|
1595 | 1652 | 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),
|
1597 | 1654 | RGBA_GETBLUE(ambient),RGBA_GETALPHA(ambient));
|
1598 | 1655 | GLint keycolor[4];
|
1599 | 1656 | for(i = 0; i < 8; i++)
|
— | — | @@ -1602,7 +1659,7 @@ |
1603 | 1660 | {
|
1604 | 1661 | if(device->texstages[i].texture->dirty & 1)
|
1605 | 1662 | {
|
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,
|
1607 | 1664 | device->texstages[i].texture->texture,device->texstages[i].texture->ddsd.dwWidth,
|
1608 | 1665 | device->texstages[i].texture->ddsd.dwHeight,device->texstages[i].texture->fakex,
|
1609 | 1666 | device->texstages[i].texture->fakey,device->texstages[i].texture->ddsd.lPitch,
|
— | — | @@ -1611,60 +1668,60 @@ |
1612 | 1669 | device->texstages[i].texture->dirty &= ~1;
|
1613 | 1670 | }
|
1614 | 1671 | 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);
|
1619 | 1676 | }
|
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);
|
1622 | 1679 | if(device->renderstate[D3DRENDERSTATE_COLORKEYENABLE] && device->texstages[i].texture && (prog.uniforms[142+i] != -1))
|
1623 | 1680 | {
|
1624 | 1681 | if(device->texstages[i].texture->ddsd.dwFlags & DDSD_CKSRCBLT)
|
1625 | 1682 | {
|
1626 | 1683 | 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);
|
1628 | 1685 | }
|
1629 | 1686 | }
|
1630 | 1687 | }
|
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]);
|
1649 | 1706 | if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
|
1650 | 1707 | else glDrawArrays(mode,0,count);
|
1651 | 1708 | if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
|
1652 | 1709 | device->glDDS7->dirty |= 2;
|
1653 | 1710 | 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);
|
1656 | 1713 | return;
|
1657 | 1714 | }
|
1658 | 1715 |
|
1659 | | -void glRenderer::_DeleteFBO(FBO *fbo)
|
| 1716 | +void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo)
|
1660 | 1717 | {
|
1661 | | - util->DeleteFBO(fbo);
|
1662 | | - SetEvent(busy);
|
| 1718 | + This->util->DeleteFBO(fbo);
|
| 1719 | + SetEvent(This->busy);
|
1663 | 1720 | }
|
1664 | 1721 |
|
1665 | | -void glRenderer::_SetFogColor(DWORD color)
|
| 1722 | +void glRenderer__SetFogColor(glRenderer *This, DWORD color)
|
1666 | 1723 | {
|
1667 | | - if (color == fogcolor) return;
|
1668 | | - fogcolor = color;
|
| 1724 | + if (color == This->fogcolor) return;
|
| 1725 | + This->fogcolor = color;
|
1669 | 1726 | GLfloat colors[4];
|
1670 | 1727 | colors[0] = (GLfloat)((color >> 16) & 255) / 255.0f;
|
1671 | 1728 | colors[1] = (GLfloat)((color >> 8) & 255) / 255.0f;
|
— | — | @@ -1673,23 +1730,25 @@ |
1674 | 1731 | glFogfv(GL_FOG_COLOR, colors);
|
1675 | 1732 | }
|
1676 | 1733 |
|
1677 | | -void glRenderer::_SetFogStart(GLfloat start)
|
| 1734 | +void glRenderer__SetFogStart(glRenderer *This, GLfloat start)
|
1678 | 1735 | {
|
1679 | | - if (start == fogstart) return;
|
1680 | | - fogstart = start;
|
| 1736 | + if (start == This->fogstart) return;
|
| 1737 | + This->fogstart = start;
|
1681 | 1738 | glFogf(GL_FOG_START, start);
|
1682 | 1739 | }
|
1683 | 1740 |
|
1684 | | -void glRenderer::_SetFogEnd(GLfloat end)
|
| 1741 | +void glRenderer__SetFogEnd(glRenderer *This, GLfloat end)
|
1685 | 1742 | {
|
1686 | | - if (end == fogend) return;
|
1687 | | - fogend = end;
|
| 1743 | + if (end == This->fogend) return;
|
| 1744 | + This->fogend = end;
|
1688 | 1745 | glFogf(GL_FOG_END, end);
|
1689 | 1746 | }
|
1690 | 1747 |
|
1691 | | -void glRenderer::_SetFogDensity(GLfloat density)
|
| 1748 | +void glRenderer__SetFogDensity(glRenderer *This, GLfloat density)
|
1692 | 1749 | {
|
1693 | | - if (density == fogdensity) return;
|
1694 | | - fogdensity = density;
|
| 1750 | + if (density == This->fogdensity) return;
|
| 1751 | + This->fogdensity = density;
|
1695 | 1752 | glFogf(GL_FOG_DENSITY, density);
|
1696 | 1753 | }
|
| 1754 | +
|
| 1755 | +} |
\ No newline at end of file |
Index: ddraw/glRenderer.h |
— | — | @@ -66,65 +66,28 @@ |
67 | 67 | #define OP_DRAWPRIMITIVES 12
|
68 | 68 | #define OP_DELETEFBO 13
|
69 | 69 |
|
70 | | -
|
| 70 | +#ifdef __cplusplus
|
71 | 71 | class glDirectDraw7;
|
72 | 72 | class glDirect3DDevice7;
|
73 | 73 | class glDirectDrawSurface7;
|
74 | 74 | 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
|
75 | 82 |
|
76 | | -/** @brief glRenderer class
|
77 | | - * OpenGL renderer class for DXGL.
|
| 83 | +/** @brief glRenderer struct
|
| 84 | + * OpenGL renderer structure for DXGL.
|
78 | 85 | */
|
79 | | -class glRenderer
|
| 86 | +typedef struct glRenderer
|
80 | 87 | {
|
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();
|
100 | 88 | HGLRC hRC;
|
101 | 89 | GLCAPS gl_caps;
|
102 | 90 | 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);
|
119 | 91 | 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);
|
129 | 92 | int opcode;
|
130 | 93 | void* inputs[32];
|
131 | 94 | void* outputs[32];
|
— | — | @@ -152,6 +115,53 @@ |
153 | 116 | TextureManager *texman;
|
154 | 117 | glUtil *util;
|
155 | 118 | ShaderManager *shaders;
|
156 | | -};
|
| 119 | +} glRenderer;
|
157 | 120 |
|
| 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 | +
|
158 | 168 | #endif //_GLRENDERER_H |
\ No newline at end of file |