Index: ddraw/BufferObject.cpp |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 |
|
23 | 23 | extern "C" {
|
24 | 24 |
|
25 | | -void BufferObject_Create(BufferObject **out, glExtensions *ext, glUtil *util)
|
| 25 | +void BufferObject_Create(BufferObject **out, glExtensions *ext, struct glUtil *util)
|
26 | 26 | {
|
27 | 27 | BufferObject *buffer = (BufferObject*)malloc(sizeof(BufferObject));
|
28 | 28 | if (!buffer)
|
— | — | @@ -30,8 +30,10 @@ |
31 | 31 | return;
|
32 | 32 | }
|
33 | 33 | ZeroMemory(buffer, sizeof(BufferObject));
|
| 34 | + buffer->refcount = 1;
|
34 | 35 | buffer->ext = ext;
|
35 | 36 | buffer->util = util;
|
| 37 | + glUtil_AddRef(util);
|
36 | 38 | ext->glGenBuffers(1, &buffer->buffer);
|
37 | 39 | *out = buffer;
|
38 | 40 | }
|
— | — | @@ -47,6 +49,7 @@ |
48 | 50 | if (!This->refcount)
|
49 | 51 | {
|
50 | 52 | This->ext->glDeleteBuffers(1, &This->buffer);
|
| 53 | + glUtil_Release(This->util);
|
51 | 54 | free(This);
|
52 | 55 | }
|
53 | 56 | }
|
— | — | @@ -63,19 +66,19 @@ |
64 | 67 | }
|
65 | 68 | else
|
66 | 69 | {
|
67 | | - This->util->BindBuffer(This, target);
|
| 70 | + glUtil_BindBuffer(This->util, This, target);
|
68 | 71 | This->ext->glBufferData(target, size, data, usage);
|
69 | | - This->util->UndoBindBuffer(target);
|
| 72 | + glUtil_UndoBindBuffer(This->util, target);
|
70 | 73 | }
|
71 | 74 | }
|
72 | 75 |
|
73 | 76 | void BufferObject_Bind(BufferObject *This, GLenum target)
|
74 | 77 | {
|
75 | | - This->util->BindBuffer(This, target);
|
| 78 | + glUtil_BindBuffer(This->util, This, target);
|
76 | 79 | }
|
77 | 80 | void BufferObject_Unbind(BufferObject *This, GLenum target)
|
78 | 81 | {
|
79 | | - This->util->BindBuffer(NULL, target);
|
| 82 | + glUtil_BindBuffer(This->util, NULL, target);
|
80 | 83 | }
|
81 | 84 |
|
82 | 85 | void *BufferObject_Map(BufferObject *This, GLenum target, GLenum access)
|
— | — | @@ -91,9 +94,9 @@ |
92 | 95 | }
|
93 | 96 | else
|
94 | 97 | {
|
95 | | - This->util->BindBuffer(This, target);
|
| 98 | + glUtil_BindBuffer(This->util, This, target);
|
96 | 99 | ptr = This->ext->glMapBuffer(target, access);
|
97 | | - This->util->UndoBindBuffer(target);
|
| 100 | + glUtil_UndoBindBuffer(This->util, target);
|
98 | 101 | }
|
99 | 102 | return ptr;
|
100 | 103 | }
|
— | — | @@ -110,9 +113,9 @@ |
111 | 114 | }
|
112 | 115 | else
|
113 | 116 | {
|
114 | | - This->util->BindBuffer(This, target);
|
| 117 | + glUtil_BindBuffer(This->util, This, target);
|
115 | 118 | ret = This->ext->glUnmapBuffer(target);
|
116 | | - This->util->UndoBindBuffer(target);
|
| 119 | + glUtil_UndoBindBuffer(This->util, target);
|
117 | 120 | }
|
118 | 121 | return ret;
|
119 | 122 | }
|
Index: ddraw/BufferObject.h |
— | — | @@ -21,11 +21,9 @@ |
22 | 22 |
|
23 | 23 | #ifdef __cplusplus
|
24 | 24 | extern "C" {
|
25 | | -class glUtil;
|
26 | | -#else
|
27 | | -typedef int glUtil;
|
28 | 25 | #endif
|
29 | 26 |
|
| 27 | +struct glUtil;
|
30 | 28 |
|
31 | 29 | typedef struct BufferObject
|
32 | 30 | {
|
— | — | @@ -38,10 +36,10 @@ |
39 | 37 | BOOL bound;
|
40 | 38 | BOOL target;
|
41 | 39 | glExtensions *ext;
|
42 | | - glUtil *util;
|
| 40 | + struct glUtil *util;
|
43 | 41 | } BufferObject;
|
44 | 42 |
|
45 | | -void BufferObject_Create(BufferObject **out, glExtensions *ext, glUtil *util);
|
| 43 | +void BufferObject_Create(BufferObject **out, glExtensions *ext, struct glUtil *util);
|
46 | 44 | void BufferObject_AddRef(BufferObject *This);
|
47 | 45 | void BufferObject_Release(BufferObject *This);
|
48 | 46 | void BufferObject_SetData(BufferObject *This, GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage);
|
Index: ddraw/glExtensions.h |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | extern "C" {
|
36 | 36 | #endif
|
37 | 37 |
|
38 | | -typedef struct
|
| 38 | +typedef struct glExtensions
|
39 | 39 | {
|
40 | 40 | GLuint(APIENTRY *glCreateShader) (GLenum type);
|
41 | 41 | void (APIENTRY *glShaderSource) (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -889,7 +889,7 @@ |
890 | 890 | ZeroMemory(&This->dib,sizeof(DIB));
|
891 | 891 | }
|
892 | 892 | TextureManager_DeleteSamplers(This->texman);
|
893 | | - This->util->DeleteFBO(&This->fbo);
|
| 893 | + glUtil_DeleteFBO(This->util, &This->fbo);
|
894 | 894 | if(This->pbo)
|
895 | 895 | {
|
896 | 896 | BufferObject_Release(This->pbo);
|
— | — | @@ -904,10 +904,10 @@ |
905 | 905 | This->backy = 0;
|
906 | 906 | }
|
907 | 907 | ShaderManager_Delete(This->shaders);
|
| 908 | + glUtil_Release(This->util);
|
908 | 909 | free(This->shaders);
|
909 | 910 | free(This->texman);
|
910 | 911 | free(This->ext);
|
911 | | - delete This->util;
|
912 | 912 | This->ext = NULL;
|
913 | 913 | wglMakeCurrent(NULL,NULL);
|
914 | 914 | wglDeleteContext(This->hRC);
|
— | — | @@ -1082,21 +1082,21 @@ |
1083 | 1083 | LeaveCriticalSection(&dll_cs);
|
1084 | 1084 | This->ext = (glExtensions *)malloc(sizeof(glExtensions));
|
1085 | 1085 | glExtensions_Init(This->ext);
|
1086 | | - This->util = new glUtil(This->ext);
|
| 1086 | + glUtil_Create(This->ext, &This->util);
|
1087 | 1087 | glRenderer__SetSwap(This,1);
|
1088 | 1088 | glFinish();
|
1089 | 1089 | DXGLTimer_Init(&This->timer);
|
1090 | 1090 | DXGLTimer_Calibrate(&This->timer, height, frequency);
|
1091 | 1091 | glRenderer__SetSwap(This,0);
|
1092 | | - This->util->SetViewport(0,0,width,height);
|
| 1092 | + glUtil_SetViewport(This->util,0,0,width,height);
|
1093 | 1093 | glViewport(0,0,width,height);
|
1094 | | - This->util->SetDepthRange(0.0,1.0);
|
1095 | | - This->util->DepthWrite(true);
|
1096 | | - This->util->DepthTest(false);
|
1097 | | - This->util->MatrixMode(GL_MODELVIEW);
|
| 1094 | + glUtil_SetDepthRange(This->util,0.0,1.0);
|
| 1095 | + glUtil_DepthWrite(This->util,TRUE);
|
| 1096 | + glUtil_DepthTest(This->util,FALSE);
|
| 1097 | + glUtil_MatrixMode(This->util,GL_MODELVIEW);
|
1098 | 1098 | glDisable(GL_DEPTH_TEST);
|
1099 | 1099 | glDisable(GL_DITHER);
|
1100 | | - This->util->SetDepthComp(GL_LESS);
|
| 1100 | + glUtil_SetDepthComp(This->util,GL_LESS);
|
1101 | 1101 | const GLubyte *glver = glGetString(GL_VERSION);
|
1102 | 1102 | This->gl_caps.Version = (GLfloat)atof((char*)glver);
|
1103 | 1103 | if(This->gl_caps.Version >= 2)
|
— | — | @@ -1109,18 +1109,18 @@ |
1110 | 1110 | This->shaders = (ShaderManager*)malloc(sizeof(ShaderManager));
|
1111 | 1111 | ShaderManager_Init(This->ext, This->shaders);
|
1112 | 1112 | This->fbo.fbo = 0;
|
1113 | | - This->util->InitFBO(&This->fbo);
|
1114 | | - This->util->ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
1115 | | - This->util->ClearDepth(1.0);
|
1116 | | - This->util->ClearStencil(0);
|
1117 | | - This->util->EnableArray(-1,false);
|
1118 | | - This->util->BlendFunc(GL_ONE,GL_ZERO);
|
1119 | | - This->util->BlendEnable(false);
|
| 1113 | + glUtil_InitFBO(This->util,&This->fbo);
|
| 1114 | + glUtil_ClearColor(This->util, 0.0f, 0.0f, 0.0f, 0.0f);
|
| 1115 | + glUtil_ClearDepth(This->util, 1.0);
|
| 1116 | + glUtil_ClearStencil(This->util, 0);
|
| 1117 | + glUtil_EnableArray(This->util,-1,FALSE);
|
| 1118 | + glUtil_BlendFunc(This->util,GL_ONE,GL_ZERO);
|
| 1119 | + glUtil_BlendEnable(This->util,FALSE);
|
1120 | 1120 | glClear(GL_COLOR_BUFFER_BIT);
|
1121 | 1121 | glFlush();
|
1122 | | - This->util->SetScissor(false,0,0,0,0);
|
| 1122 | + glUtil_SetScissor(This->util,FALSE,0,0,0,0);
|
1123 | 1123 | glDisable(GL_SCISSOR_TEST);
|
1124 | | - This->util->SetCull(D3DCULL_CCW);
|
| 1124 | + glUtil_SetCull(This->util,D3DCULL_CCW);
|
1125 | 1125 | glEnable(GL_CULL_FACE);
|
1126 | 1126 | SwapBuffers(This->hDC);
|
1127 | 1127 | This->texman = TextureManager_Create(This->ext);
|
— | — | @@ -1129,11 +1129,11 @@ |
1130 | 1130 | glRenderer__SetFogStart(This,0);
|
1131 | 1131 | glRenderer__SetFogEnd(This,1);
|
1132 | 1132 | glRenderer__SetFogDensity(This,1);
|
1133 | | - This->util->SetPolyMode(D3DFILL_SOLID);
|
1134 | | - This->util->SetShadeMode(D3DSHADE_GOURAUD);
|
| 1133 | + glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
|
| 1134 | + glUtil_SetShadeMode(This->util, D3DSHADE_GOURAUD);
|
1135 | 1135 | if(hWnd)
|
1136 | 1136 | {
|
1137 | | - This->dib.enabled = true;
|
| 1137 | + This->dib.enabled = TRUE;
|
1138 | 1138 | This->dib.width = width;
|
1139 | 1139 | This->dib.height = height;
|
1140 | 1140 | This->dib.pitch = (((width<<3)+31)&~31) >>3;
|
— | — | @@ -1390,18 +1390,18 @@ |
1391 | 1391 | }
|
1392 | 1392 | ShaderManager_SetShader(This->shaders, shaderid, NULL, 1);
|
1393 | 1393 | GenShader2D *shader = &This->shaders->gen2d->genshaders2D[This->shaders->gen3d->current_genshader];
|
1394 | | - This->util->BlendEnable(false);
|
| 1394 | + glUtil_BlendEnable(This->util, FALSE);
|
1395 | 1395 | do
|
1396 | 1396 | {
|
1397 | | - if (This->util->SetFBO(dest) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 1397 | + if (glUtil_SetFBOSurface(This->util, dest) == GL_FRAMEBUFFER_COMPLETE) break;
|
1398 | 1398 | if (!dest->texture->internalformats[1]) break;
|
1399 | 1399 | TextureManager_FixTexture(This->texman, dest->texture, (dest->bigbuffer ? dest->bigbuffer : dest->buffer), &dest->dirty, dest->miplevel);
|
1400 | | - This->util->SetFBO((FBO*)NULL);
|
| 1400 | + glUtil_SetFBO(This->util, NULL);
|
1401 | 1401 | dest->fbo.fbcolor = NULL;
|
1402 | 1402 | dest->fbo.fbz = NULL;
|
1403 | 1403 | } while (1);
|
1404 | | - This->util->SetViewport(0,0,dest->fakex,dest->fakey);
|
1405 | | - This->util->DepthTest(false);
|
| 1404 | + glUtil_SetViewport(This->util,0,0,dest->fakex,dest->fakey);
|
| 1405 | + glUtil_DepthTest(This->util, FALSE);
|
1406 | 1406 | DDSURFACEDESC2 ddsdSrc;
|
1407 | 1407 | ddsdSrc.dwSize = sizeof(DDSURFACEDESC2);
|
1408 | 1408 | if(src) src->GetSurfaceDesc(&ddsdSrc);
|
— | — | @@ -1477,8 +1477,8 @@ |
1478 | 1478 | {
|
1479 | 1479 | TextureManager_SetTexture(This->texman, 3, dest->stencil);
|
1480 | 1480 | This->ext->glUniform1i(shader->shader.uniforms[4],3);
|
1481 | | - This->util->EnableArray(shader->shader.attribs[5],true);
|
1482 | | - This->ext->glVertexAttribPointer(shader->shader.attribs[5], 2, GL_FLOAT, false, sizeof(BltVertex), &This->bltvertices[0].stencils);
|
| 1481 | + glUtil_EnableArray(This->util, shader->shader.attribs[5], TRUE);
|
| 1482 | + This->ext->glVertexAttribPointer(shader->shader.attribs[5], 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].stencils);
|
1483 | 1483 | }
|
1484 | 1484 | if(src)
|
1485 | 1485 | {
|
— | — | @@ -1497,22 +1497,22 @@ |
1498 | 1498 | if(dest) This->ext->glUniform4i(shader->shader.uniforms[11], dest->texture->colorsizes[0], dest->texture->colorsizes[1],
|
1499 | 1499 | dest->texture->colorsizes[2], dest->texture->colorsizes[3]);
|
1500 | 1500 | dest->dirty |= 2;
|
1501 | | - This->util->EnableArray(shader->shader.attribs[0],true);
|
1502 | | - This->ext->glVertexAttribPointer(shader->shader.attribs[0],2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
|
| 1501 | + glUtil_EnableArray(This->util, shader->shader.attribs[0], TRUE);
|
| 1502 | + This->ext->glVertexAttribPointer(shader->shader.attribs[0],2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].x);
|
1503 | 1503 | if(!(dwFlags & DDBLT_COLORFILL))
|
1504 | 1504 | {
|
1505 | | - This->util->EnableArray(shader->shader.attribs[3],true);
|
1506 | | - This->ext->glVertexAttribPointer(shader->shader.attribs[3],2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].s);
|
| 1505 | + glUtil_EnableArray(This->util, shader->shader.attribs[3], TRUE);
|
| 1506 | + This->ext->glVertexAttribPointer(shader->shader.attribs[3],2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].s);
|
1507 | 1507 | }
|
1508 | 1508 | if (usedest)
|
1509 | 1509 | {
|
1510 | | - This->util->EnableArray(shader->shader.attribs[4], true);
|
1511 | | - This->ext->glVertexAttribPointer(shader->shader.attribs[4],2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].dests);
|
| 1510 | + glUtil_EnableArray(This->util, shader->shader.attribs[4], TRUE);
|
| 1511 | + This->ext->glVertexAttribPointer(shader->shader.attribs[4],2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].dests);
|
1512 | 1512 | }
|
1513 | | - This->util->SetCull(D3DCULL_NONE);
|
1514 | | - This->util->SetPolyMode(D3DFILL_SOLID);
|
| 1513 | + glUtil_SetCull(This->util, D3DCULL_NONE);
|
| 1514 | + glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
|
1515 | 1515 | This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
|
1516 | | - This->util->SetFBO((FBO*)NULL);
|
| 1516 | + glUtil_SetFBO(This->util, NULL);
|
1517 | 1517 | if(((ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
1518 | 1518 | (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
1519 | 1519 | ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
— | — | @@ -1552,11 +1552,11 @@ |
1553 | 1553 | This->backx = x;
|
1554 | 1554 | This->backy = y;
|
1555 | 1555 | }
|
1556 | | - This->util->SetFBO(&This->fbo,This->backbuffer,0,false);
|
| 1556 | + glUtil_SetFBOTextures(This->util,&This->fbo,This->backbuffer,0,FALSE);
|
1557 | 1557 | view[0] = view[2] = 0;
|
1558 | 1558 | view[1] = (GLfloat)x;
|
1559 | 1559 | view[3] = (GLfloat)y;
|
1560 | | - This->util->SetViewport(0,0,x,y);
|
| 1560 | + glUtil_SetViewport(This->util,0,0,x,y);
|
1561 | 1561 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
1562 | 1562 | TextureManager_SetTexture(This->texman,0,*texture);
|
1563 | 1563 | *texture = This->backbuffer;
|
— | — | @@ -1567,14 +1567,14 @@ |
1568 | 1568 | This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
|
1569 | 1569 | This->bltvertices[0].x = This->bltvertices[2].x = (float)x;
|
1570 | 1570 | This->bltvertices[2].y = This->bltvertices[3].y = (float)y;
|
1571 | | - This->util->EnableArray(This->shaders->shaders[progtype].pos,true);
|
1572 | | - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
|
1573 | | - This->util->EnableArray(This->shaders->shaders[progtype].texcoord,true);
|
1574 | | - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].s);
|
1575 | | - This->util->SetCull(D3DCULL_NONE);
|
1576 | | - This->util->SetPolyMode(D3DFILL_SOLID);
|
| 1571 | + glUtil_EnableArray(This->util,This->shaders->shaders[progtype].pos,TRUE);
|
| 1572 | + This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].x);
|
| 1573 | + glUtil_EnableArray(This->util,This->shaders->shaders[progtype].texcoord,TRUE);
|
| 1574 | + This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].s);
|
| 1575 | + glUtil_SetCull(This->util,D3DCULL_NONE);
|
| 1576 | + glUtil_SetPolyMode(This->util,D3DFILL_SOLID);
|
1577 | 1577 | This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
|
1578 | | - This->util->SetFBO((FBO*)NULL);
|
| 1578 | + glUtil_SetFBO(This->util, NULL);
|
1579 | 1579 | }
|
1580 | 1580 |
|
1581 | 1581 | void glRenderer__DrawBackbufferRect(glRenderer *This, TEXTURE *texture, RECT srcrect, int progtype)
|
— | — | @@ -1606,14 +1606,14 @@ |
1607 | 1607 | This->backx = x;
|
1608 | 1608 | This->backy = y;
|
1609 | 1609 | }
|
1610 | | - This->util->SetFBO(&This->fbo, This->backbuffer, 0, false);
|
| 1610 | + glUtil_SetFBOTextures(This->util, &This->fbo, This->backbuffer, 0, FALSE);
|
1611 | 1611 | view[0] = view[2] = 0;
|
1612 | 1612 | view[1] = (GLfloat)This->backx;
|
1613 | 1613 | view[3] = (GLfloat)This->backy;
|
1614 | | - This->util->SetViewport(0, 0, This->backx, This->backy);
|
1615 | | - This->util->SetScissor(true, 0, 0, This->backx, This->backy);
|
| 1614 | + glUtil_SetViewport(This->util, 0, 0, This->backx, This->backy);
|
| 1615 | + glUtil_SetScissor(This->util, TRUE, 0, 0, This->backx, This->backy);
|
1616 | 1616 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
1617 | | - This->util->SetScissor(false, 0, 0, 0, 0);
|
| 1617 | + glUtil_SetScissor(This->util, FALSE, 0, 0, 0, 0);
|
1618 | 1618 | TextureManager_SetTexture(This->texman, 0, texture);
|
1619 | 1619 | This->ext->glUniform4f(This->shaders->shaders[progtype].view, view[0], view[1], view[2], view[3]);
|
1620 | 1620 | This->bltvertices[1].s = This->bltvertices[3].s = (GLfloat)srcrect.left / (GLfloat)texture->width;
|
— | — | @@ -1624,14 +1624,14 @@ |
1625 | 1625 | This->bltvertices[0].x = This->bltvertices[2].x = (float)x;
|
1626 | 1626 | This->bltvertices[0].y = This->bltvertices[1].y = 0.;
|
1627 | 1627 | This->bltvertices[2].y = This->bltvertices[3].y = (float)y;
|
1628 | | - This->util->EnableArray(This->shaders->shaders[progtype].pos, true);
|
1629 | | - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos, 2, GL_FLOAT, false, sizeof(BltVertex), &This->bltvertices[0].x);
|
1630 | | - This->util->EnableArray(This->shaders->shaders[progtype].texcoord, true);
|
1631 | | - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord, 2, GL_FLOAT, false, sizeof(BltVertex), &This->bltvertices[0].s);
|
1632 | | - This->util->SetCull(D3DCULL_NONE);
|
1633 | | - This->util->SetPolyMode(D3DFILL_SOLID);
|
| 1628 | + glUtil_EnableArray(This->util, This->shaders->shaders[progtype].pos, TRUE);
|
| 1629 | + This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].x);
|
| 1630 | + glUtil_EnableArray(This->util, This->shaders->shaders[progtype].texcoord, TRUE);
|
| 1631 | + This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].s);
|
| 1632 | + glUtil_SetCull(This->util, D3DCULL_NONE);
|
| 1633 | + glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
|
1634 | 1634 | This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP, 0, 3, 4, GL_UNSIGNED_SHORT, bltindices);
|
1635 | | - This->util->SetFBO((FBO*)NULL);
|
| 1635 | + glUtil_SetFBO(This->util, NULL);
|
1636 | 1636 | }
|
1637 | 1637 |
|
1638 | 1638 | void glRenderer__DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync)
|
— | — | @@ -1638,7 +1638,7 @@ |
1639 | 1639 | {
|
1640 | 1640 | int progtype;
|
1641 | 1641 | RECT r,r2;
|
1642 | | - This->util->BlendEnable(false);
|
| 1642 | + glUtil_BlendEnable(This->util, FALSE);
|
1643 | 1643 | if((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
1644 | 1644 | {
|
1645 | 1645 | GetClientRect(This->hWnd,&r);
|
— | — | @@ -1646,7 +1646,7 @@ |
1647 | 1647 | if(memcmp(&r2,&r,sizeof(RECT)))
|
1648 | 1648 | SetWindowPos(This->RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
|
1649 | 1649 | }
|
1650 | | - This->util->DepthTest(false);
|
| 1650 | + glUtil_DepthTest(This->util, FALSE);
|
1651 | 1651 | RECT *viewrect = &r2;
|
1652 | 1652 | glRenderer__SetSwap(This,vsync);
|
1653 | 1653 | LONG sizes[6];
|
— | — | @@ -1693,7 +1693,7 @@ |
1694 | 1694 | view[2] = 0;
|
1695 | 1695 | view[3] = (GLfloat)dest->fakey;
|
1696 | 1696 | }
|
1697 | | - This->util->SetFBO((FBO*)NULL);
|
| 1697 | + glUtil_SetFBO(This->util, NULL);
|
1698 | 1698 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
1699 | 1699 | if(This->ddInterface->GetBPP() == 8)
|
1700 | 1700 | {
|
— | — | @@ -1729,7 +1729,7 @@ |
1730 | 1730 | ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_LINEAR,GL_LINEAR,This->ext,This->texman);
|
1731 | 1731 | else if(This->ext->GLEXT_ARB_sampler_objects)
|
1732 | 1732 | ((glDirectDrawSurface7*)NULL)->SetFilter(0,GL_NEAREST,GL_NEAREST,This->ext,This->texman);
|
1733 | | - This->util->SetViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
|
| 1733 | + glUtil_SetViewport(This->util,viewport[0],viewport[1],viewport[2],viewport[3]);
|
1734 | 1734 | This->ext->glUniform4f(This->shaders->shaders[progtype].view,view[0],view[1],view[2],view[3]);
|
1735 | 1735 | if(This->ddInterface->GetFullscreen())
|
1736 | 1736 | {
|
— | — | @@ -1745,12 +1745,12 @@ |
1746 | 1746 | }
|
1747 | 1747 | This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
|
1748 | 1748 | This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
|
1749 | | - This->util->EnableArray(This->shaders->shaders[progtype].pos,true);
|
1750 | | - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
|
1751 | | - This->util->EnableArray(This->shaders->shaders[progtype].texcoord,true);
|
1752 | | - This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].s);
|
1753 | | - This->util->SetCull(D3DCULL_NONE);
|
1754 | | - This->util->SetPolyMode(D3DFILL_SOLID);
|
| 1749 | + glUtil_EnableArray(This->util, This->shaders->shaders[progtype].pos, TRUE);
|
| 1750 | + This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].x);
|
| 1751 | + glUtil_EnableArray(This->util, This->shaders->shaders[progtype].texcoord, TRUE);
|
| 1752 | + This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].texcoord,2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].s);
|
| 1753 | + glUtil_SetCull(This->util, D3DCULL_NONE);
|
| 1754 | + glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
|
1755 | 1755 | This->ext->glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
|
1756 | 1756 | glFlush();
|
1757 | 1757 | if(This->hWnd) SwapBuffers(This->hDC);
|
— | — | @@ -1895,17 +1895,17 @@ |
1896 | 1896 | SetEvent(This->busy);
|
1897 | 1897 | glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
1898 | 1898 | GLfloat ambient[] = {0.0,0.0,0.0,0.0};
|
1899 | | - if(zbuffer) This->util->DepthTest(true);
|
1900 | | - This->util->SetDepthComp(GL_LEQUAL);
|
| 1899 | + if (zbuffer) glUtil_DepthTest(This->util, TRUE);
|
| 1900 | + glUtil_SetDepthComp(This->util, GL_LEQUAL);
|
1901 | 1901 | GLfloat identity[16];
|
1902 | 1902 | __gluMakeIdentityf(identity);
|
1903 | | - This->util->SetMatrix(GL_MODELVIEW,identity,identity,NULL);
|
1904 | | - This->util->SetMatrix(GL_PROJECTION,identity,NULL,NULL);
|
| 1903 | + glUtil_SetMatrix(This->util, GL_MODELVIEW, identity, identity, NULL);
|
| 1904 | + glUtil_SetMatrix(This->util, GL_PROJECTION, identity, NULL, NULL);
|
1905 | 1905 | for (int i = 0; i < 24; i++)
|
1906 | 1906 | memcpy(&This->transform[i], identity, sizeof(D3DMATRIX));
|
1907 | 1907 | GLfloat one[4] = {1,1,1,1};
|
1908 | 1908 | GLfloat zero[4] = {0,0,0,1};
|
1909 | | - This->util->SetMaterial(one,one,zero,zero,0);
|
| 1909 | + glUtil_SetMaterial(This->util, one, one, zero, zero, 0);
|
1910 | 1910 | ZeroMemory(&This->material, sizeof(D3DMATERIAL7));
|
1911 | 1911 | ZeroMemory(&This->lights, 8 * sizeof(D3DLIGHT7));
|
1912 | 1912 | memcpy(&This->renderstate, &renderstate_default, 153 * sizeof(DWORD));
|
— | — | @@ -1928,10 +1928,10 @@ |
1929 | 1929 | dwordto4float(dwColor,color);
|
1930 | 1930 | do
|
1931 | 1931 | {
|
1932 | | - if (This->util->SetFBO(target) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 1932 | + if (glUtil_SetFBOSurface(This->util, target) == GL_FRAMEBUFFER_COMPLETE) break;
|
1933 | 1933 | if (!target->texture->internalformats[1]) break;
|
1934 | 1934 | TextureManager_FixTexture(This->texman, target->texture, (target->bigbuffer ? target->bigbuffer : target->buffer), &target->dirty, target->miplevel);
|
1935 | | - This->util->SetFBO((FBO*)NULL);
|
| 1935 | + glUtil_SetFBO(This->util, NULL);
|
1936 | 1936 | target->fbo.fbcolor = NULL;
|
1937 | 1937 | target->fbo.fbz = NULL;
|
1938 | 1938 | } while (1);
|
— | — | @@ -1939,27 +1939,27 @@ |
1940 | 1940 | if(dwFlags & D3DCLEAR_TARGET)
|
1941 | 1941 | {
|
1942 | 1942 | clearbits |= GL_COLOR_BUFFER_BIT;
|
1943 | | - This->util->ClearColor(color[0],color[1],color[2],color[3]);
|
| 1943 | + glUtil_ClearColor(This->util, color[0], color[1], color[2], color[3]);
|
1944 | 1944 | }
|
1945 | 1945 | if(dwFlags & D3DCLEAR_ZBUFFER)
|
1946 | 1946 | {
|
1947 | 1947 | clearbits |= GL_DEPTH_BUFFER_BIT;
|
1948 | | - This->util->ClearDepth(dvZ);
|
1949 | | - This->util->DepthWrite(true);
|
| 1948 | + glUtil_ClearDepth(This->util, dvZ);
|
| 1949 | + glUtil_DepthWrite(This->util, TRUE);
|
1950 | 1950 | }
|
1951 | 1951 | if(dwFlags & D3DCLEAR_STENCIL)
|
1952 | 1952 | {
|
1953 | 1953 | clearbits |= GL_STENCIL_BUFFER_BIT;
|
1954 | | - This->util->ClearStencil(dwStencil);
|
| 1954 | + glUtil_ClearStencil(This->util, dwStencil);
|
1955 | 1955 | }
|
1956 | 1956 | if(dwCount)
|
1957 | 1957 | {
|
1958 | 1958 | for(DWORD i = 0; i < dwCount; i++)
|
1959 | 1959 | {
|
1960 | | - This->util->SetScissor(true,lpRects[i].x1,lpRects[i].y1,lpRects[i].x2,lpRects[i].y2);
|
| 1960 | + glUtil_SetScissor(This->util, TRUE, lpRects[i].x1, lpRects[i].y1, lpRects[i].x2, lpRects[i].y2);
|
1961 | 1961 | glClear(clearbits);
|
1962 | 1962 | }
|
1963 | | - This->util->SetScissor(false,0,0,0,0);
|
| 1963 | + glUtil_SetScissor(This->util, false, 0, 0, 0, 0);
|
1964 | 1964 | }
|
1965 | 1965 | else glClear(clearbits);
|
1966 | 1966 | if(target->zbuffer) target->zbuffer->dirty |= 2;
|
— | — | @@ -2009,7 +2009,7 @@ |
2010 | 2010 | DXGLTimer_Init(&This->timer);
|
2011 | 2011 | DXGLTimer_Calibrate(&This->timer, height, frequency);
|
2012 | 2012 | glRenderer__SetSwap(This,0);
|
2013 | | - This->util->SetViewport(0,0,width,height);
|
| 2013 | + glUtil_SetViewport(This->util, 0, 0, width, height);
|
2014 | 2014 | }
|
2015 | 2015 |
|
2016 | 2016 | SetEvent(This->busy);
|
— | — | @@ -2114,7 +2114,7 @@ |
2115 | 2115 | gldest = GL_SRC_ALPHA;
|
2116 | 2116 | break;
|
2117 | 2117 | }
|
2118 | | - This->util->BlendFunc(glsrc,gldest);
|
| 2118 | + glUtil_BlendFunc(This->util, glsrc, gldest);
|
2119 | 2119 | }
|
2120 | 2120 |
|
2121 | 2121 | void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
|
— | — | @@ -2154,19 +2154,19 @@ |
2155 | 2155 | if (vertices[7].data) This->shaderstate3d.stateid |= (1i64 << 37);
|
2156 | 2156 | ShaderManager_SetShader(This->shaders,This->shaderstate3d.stateid,This->shaderstate3d.texstageid,2);
|
2157 | 2157 | glRenderer__SetDepthComp(This);
|
2158 | | - if(This->renderstate[D3DRENDERSTATE_ZENABLE]) This->util->DepthTest(true);
|
2159 | | - else This->util->DepthTest(false);
|
2160 | | - if(This->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) This->util->DepthWrite(true);
|
2161 | | - else This->util->DepthWrite(false);
|
| 2158 | + if(This->renderstate[D3DRENDERSTATE_ZENABLE]) glUtil_DepthTest(This->util, TRUE);
|
| 2159 | + else glUtil_DepthTest(This->util, FALSE);
|
| 2160 | + if (This->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) glUtil_DepthWrite(This->util, TRUE);
|
| 2161 | + else glUtil_DepthWrite(This->util, FALSE);
|
2162 | 2162 | _GENSHADER *prog = &This->shaders->gen3d->genshaders[This->shaders->gen3d->current_genshader].shader;
|
2163 | | - This->util->EnableArray(prog->attribs[0],true);
|
2164 | | - This->ext->glVertexAttribPointer(prog->attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
|
| 2163 | + glUtil_EnableArray(This->util, prog->attribs[0], TRUE);
|
| 2164 | + This->ext->glVertexAttribPointer(prog->attribs[0],3,GL_FLOAT,GL_FALSE,vertices[0].stride,vertices[0].data);
|
2165 | 2165 | if(transformed)
|
2166 | 2166 | {
|
2167 | 2167 | if(prog->attribs[1] != -1)
|
2168 | 2168 | {
|
2169 | | - This->util->EnableArray(prog->attribs[1],true);
|
2170 | | - This->ext->glVertexAttribPointer(prog->attribs[1],4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
|
| 2169 | + glUtil_EnableArray(This->util, prog->attribs[1], TRUE);
|
| 2170 | + This->ext->glVertexAttribPointer(prog->attribs[1],4,GL_FLOAT,GL_FALSE,vertices[1].stride,vertices[1].data);
|
2171 | 2171 | }
|
2172 | 2172 | }
|
2173 | 2173 | for(i = 0; i < 5; i++)
|
— | — | @@ -2175,8 +2175,8 @@ |
2176 | 2176 | {
|
2177 | 2177 | if(prog->attribs[i+2] != -1)
|
2178 | 2178 | {
|
2179 | | - This->util->EnableArray(prog->attribs[i+2],true);
|
2180 | | - This->ext->glVertexAttribPointer(prog->attribs[i+2],1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
|
| 2179 | + glUtil_EnableArray(This->util, prog->attribs[i + 2], TRUE);
|
| 2180 | + This->ext->glVertexAttribPointer(prog->attribs[i+2],1,GL_FLOAT,GL_FALSE,vertices[i+2].stride,vertices[i+2].data);
|
2181 | 2181 | }
|
2182 | 2182 | }
|
2183 | 2183 | }
|
— | — | @@ -2184,8 +2184,8 @@ |
2185 | 2185 | {
|
2186 | 2186 | if(prog->attribs[7] != -1)
|
2187 | 2187 | {
|
2188 | | - This->util->EnableArray(prog->attribs[7],true);
|
2189 | | - This->ext->glVertexAttribPointer(prog->attribs[7],3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
|
| 2188 | + glUtil_EnableArray(This->util, prog->attribs[7], TRUE);
|
| 2189 | + This->ext->glVertexAttribPointer(prog->attribs[7],3,GL_FLOAT,GL_FALSE,vertices[7].stride,vertices[7].data);
|
2190 | 2190 | }
|
2191 | 2191 | }
|
2192 | 2192 | for(i = 0; i < 2; i++)
|
— | — | @@ -2194,8 +2194,8 @@ |
2195 | 2195 | {
|
2196 | 2196 | if(prog->attribs[8+i] != -1)
|
2197 | 2197 | {
|
2198 | | - This->util->EnableArray(prog->attribs[8+i],true);
|
2199 | | - This->ext->glVertexAttribPointer(prog->attribs[8+i],4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
|
| 2198 | + glUtil_EnableArray(This->util, prog->attribs[8 + i], TRUE);
|
| 2199 | + This->ext->glVertexAttribPointer(prog->attribs[8+i],4,GL_UNSIGNED_BYTE,GL_TRUE,vertices[i+8].stride,vertices[i+8].data);
|
2200 | 2200 | }
|
2201 | 2201 | }
|
2202 | 2202 | }
|
— | — | @@ -2209,28 +2209,28 @@ |
2210 | 2210 | case 1: // s
|
2211 | 2211 | if (prog->attribs[i + 10] != -1)
|
2212 | 2212 | {
|
2213 | | - This->util->EnableArray(prog->attribs[i + 10], true);
|
2214 | | - This->ext->glVertexAttribPointer(prog->attribs[i + 10], 1, GL_FLOAT, false, vertices[i + 10].stride, vertices[i + 10].data);
|
| 2213 | + glUtil_EnableArray(This->util, prog->attribs[i + 10], TRUE);
|
| 2214 | + This->ext->glVertexAttribPointer(prog->attribs[i + 10], 1, GL_FLOAT, GL_FALSE, vertices[i + 10].stride, vertices[i + 10].data);
|
2215 | 2215 | }
|
2216 | 2216 | break;
|
2217 | 2217 | case 2: // st
|
2218 | 2218 | if(prog->attribs[i+18] != -1)
|
2219 | 2219 | {
|
2220 | | - This->util->EnableArray(prog->attribs[i+18],true);
|
2221 | | - This->ext->glVertexAttribPointer(prog->attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 2220 | + glUtil_EnableArray(This->util, prog->attribs[i + 18], TRUE);
|
| 2221 | + This->ext->glVertexAttribPointer(prog->attribs[i+18],2,GL_FLOAT,GL_FALSE,vertices[i+10].stride,vertices[i+10].data);
|
2222 | 2222 | }
|
2223 | 2223 | break;
|
2224 | 2224 | case 3: // str
|
2225 | 2225 | if(prog->attribs[i+26] != -1)
|
2226 | 2226 | {
|
2227 | | - This->util->EnableArray(prog->attribs[i+26],true);
|
2228 | | - This->ext->glVertexAttribPointer(prog->attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 2227 | + glUtil_EnableArray(This->util, prog->attribs[i + 26], TRUE);
|
| 2228 | + This->ext->glVertexAttribPointer(prog->attribs[i+26],3,GL_FLOAT,GL_FALSE,vertices[i+10].stride,vertices[i+10].data);
|
2229 | 2229 | }
|
2230 | 2230 | break;
|
2231 | 2231 | case 4: // strq
|
2232 | 2232 | if(prog->attribs[i+34] != -1)
|
2233 | 2233 | {
|
2234 | | - This->util->EnableArray(prog->attribs[i+34],true);
|
| 2234 | + glUtil_EnableArray(This->util, prog->attribs[i + 34], TRUE);
|
2235 | 2235 | This->ext->glVertexAttribPointer(prog->attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
2236 | 2236 | }
|
2237 | 2237 | break;
|
— | — | @@ -2238,12 +2238,12 @@ |
2239 | 2239 |
|
2240 | 2240 | }
|
2241 | 2241 | }
|
2242 | | - This->util->SetMatrix(GL_MODELVIEW, (GLfloat*)&This->transform[D3DTRANSFORMSTATE_VIEW],
|
| 2242 | + glUtil_SetMatrix(This->util, GL_MODELVIEW, (GLfloat*)&This->transform[D3DTRANSFORMSTATE_VIEW],
|
2243 | 2243 | (GLfloat*)&This->transform[D3DTRANSFORMSTATE_WORLD],NULL);
|
2244 | | - This->util->SetMatrix(GL_PROJECTION, (GLfloat*)&This->transform[D3DTRANSFORMSTATE_PROJECTION], NULL, NULL);
|
| 2244 | + glUtil_SetMatrix(This->util, GL_PROJECTION, (GLfloat*)&This->transform[D3DTRANSFORMSTATE_PROJECTION], NULL, NULL);
|
2245 | 2245 |
|
2246 | | - This->util->SetMaterial((GLfloat*)&This->material.ambient,(GLfloat*)&This->material.diffuse,(GLfloat*)&This->material.specular,
|
2247 | | - (GLfloat*)&This->material.emissive,This->material.power);
|
| 2246 | + glUtil_SetMaterial(This->util, (GLfloat*)&This->material.ambient, (GLfloat*)&This->material.diffuse, (GLfloat*)&This->material.specular,
|
| 2247 | + (GLfloat*)&This->material.emissive, This->material.power);
|
2248 | 2248 |
|
2249 | 2249 | int lightindex = 0;
|
2250 | 2250 | char lightname[] = "lightX.xxxxxxxxxxxxxxxx";
|
— | — | @@ -2307,8 +2307,8 @@ |
2308 | 2308 | if(This->texstages[i].texture)
|
2309 | 2309 | This->texstages[i].texture->SetFilter(i,This->texstages[i].glmagfilter,This->texstages[i].glminfilter,This->ext,This->texman);
|
2310 | 2310 | TextureManager_SetTexture(This->texman,i,This->texstages[i].texture->texture);
|
2311 | | - This->util->SetWrap(i,0,This->texstages[i].addressu,This->texman);
|
2312 | | - This->util->SetWrap(i,1,This->texstages[i].addressv,This->texman);
|
| 2311 | + glUtil_SetWrap(This->util, i, 0, This->texstages[i].addressu, This->texman);
|
| 2312 | + glUtil_SetWrap(This->util, i, 1, This->texstages[i].addressv, This->texman);
|
2313 | 2313 | }
|
2314 | 2314 | TextureManager_SetTexture(This->texman,i,0);
|
2315 | 2315 | This->ext->glUniform1i(prog->uniforms[128+i],i);
|
— | — | @@ -2334,29 +2334,29 @@ |
2335 | 2335 | if(prog->uniforms[150]!= -1) This->ext->glUniform4iv(prog->uniforms[150],1,(GLint*)device->glDDS7->texture->colorbits);
|
2336 | 2336 | do
|
2337 | 2337 | {
|
2338 | | - if (This->util->SetFBO(device->glDDS7) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 2338 | + if (glUtil_SetFBOSurface(This->util, device->glDDS7) == GL_FRAMEBUFFER_COMPLETE) break;
|
2339 | 2339 | if (!device->glDDS7->texture->internalformats[1]) break;
|
2340 | 2340 | TextureManager_FixTexture(This->texman, device->glDDS7->texture,
|
2341 | 2341 | (device->glDDS7->bigbuffer ? device->glDDS7->bigbuffer : device->glDDS7->buffer), &device->glDDS7->dirty, device->glDDS7->miplevel);
|
2342 | | - This->util->SetFBO((FBO*)NULL);
|
| 2342 | + glUtil_SetFBO(This->util, NULL);
|
2343 | 2343 | device->glDDS7->fbo.fbcolor = NULL;
|
2344 | 2344 | device->glDDS7->fbo.fbz = NULL;
|
2345 | 2345 | } while (1);
|
2346 | | - This->util->SetViewport((int)((float)This->viewport.dwX*device->glDDS7->mulx),
|
| 2346 | + glUtil_SetViewport(This->util, (int)((float)This->viewport.dwX*device->glDDS7->mulx),
|
2347 | 2347 | (int)((float)This->viewport.dwY*device->glDDS7->muly),
|
2348 | 2348 | (int)((float)This->viewport.dwWidth*device->glDDS7->mulx),
|
2349 | 2349 | (int)((float)This->viewport.dwHeight*device->glDDS7->muly));
|
2350 | | - This->util->SetDepthRange(This->viewport.dvMinZ,This->viewport.dvMaxZ);
|
2351 | | - if(This->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) This->util->BlendEnable(true);
|
2352 | | - else This->util->BlendEnable(false);
|
| 2350 | + glUtil_SetDepthRange(This->util, This->viewport.dvMinZ, This->viewport.dvMaxZ);
|
| 2351 | + if (This->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) glUtil_BlendEnable(This->util, TRUE);
|
| 2352 | + else glUtil_BlendEnable(This->util, FALSE);
|
2353 | 2353 | glRenderer__SetBlend(This,This->renderstate[D3DRENDERSTATE_SRCBLEND],This->renderstate[D3DRENDERSTATE_DESTBLEND]);
|
2354 | | - This->util->SetCull((D3DCULL)This->renderstate[D3DRENDERSTATE_CULLMODE]);
|
| 2354 | + glUtil_SetCull(This->util, (D3DCULL)This->renderstate[D3DRENDERSTATE_CULLMODE]);
|
2355 | 2355 | glRenderer__SetFogColor(This,This->renderstate[D3DRENDERSTATE_FOGCOLOR]);
|
2356 | 2356 | glRenderer__SetFogStart(This,*(GLfloat*)(&This->renderstate[D3DRENDERSTATE_FOGSTART]));
|
2357 | 2357 | glRenderer__SetFogEnd(This,*(GLfloat*)(&This->renderstate[D3DRENDERSTATE_FOGEND]));
|
2358 | 2358 | glRenderer__SetFogDensity(This,*(GLfloat*)(&This->renderstate[D3DRENDERSTATE_FOGDENSITY]));
|
2359 | | - This->util->SetPolyMode((D3DFILLMODE)This->renderstate[D3DRENDERSTATE_FILLMODE]);
|
2360 | | - This->util->SetShadeMode((D3DSHADEMODE)This->renderstate[D3DRENDERSTATE_SHADEMODE]);
|
| 2359 | + glUtil_SetPolyMode(This->util, (D3DFILLMODE)This->renderstate[D3DRENDERSTATE_FILLMODE]);
|
| 2360 | + glUtil_SetShadeMode(This->util, (D3DSHADEMODE)This->renderstate[D3DRENDERSTATE_SHADEMODE]);
|
2361 | 2361 | if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
|
2362 | 2362 | else glDrawArrays(mode,0,count);
|
2363 | 2363 | if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
|
— | — | @@ -2369,7 +2369,7 @@ |
2370 | 2370 |
|
2371 | 2371 | void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo)
|
2372 | 2372 | {
|
2373 | | - This->util->DeleteFBO(fbo);
|
| 2373 | + glUtil_DeleteFBO(This->util, fbo);
|
2374 | 2374 | SetEvent(This->busy);
|
2375 | 2375 | }
|
2376 | 2376 |
|
— | — | @@ -2394,22 +2394,22 @@ |
2395 | 2395 | (surface->ddsd.dwHeight != surface->stencil->height))
|
2396 | 2396 | TextureManager__UploadTexture(This->texman, surface->stencil, 0, NULL,
|
2397 | 2397 | surface->ddsd.dwWidth, surface->ddsd.dwHeight, FALSE, TRUE);
|
2398 | | - This->util->SetFBO(&surface->stencilfbo, surface->stencil, 0, false);
|
| 2398 | + glUtil_SetFBOTextures(This->util, &surface->stencilfbo, surface->stencil, 0, FALSE);
|
2399 | 2399 | view[0] = view[2] = 0;
|
2400 | 2400 | view[1] = (GLfloat)surface->ddsd.dwWidth;
|
2401 | 2401 | view[3] = (GLfloat)surface->ddsd.dwHeight;
|
2402 | | - This->util->SetViewport(0,0,surface->ddsd.dwWidth,surface->ddsd.dwHeight);
|
| 2402 | + glUtil_SetViewport(This->util, 0, 0, surface->ddsd.dwWidth, surface->ddsd.dwHeight);
|
2403 | 2403 | glClear(GL_COLOR_BUFFER_BIT);
|
2404 | 2404 | ShaderManager_SetShader(This->shaders,PROG_CLIPSTENCIL,NULL,0);
|
2405 | 2405 | This->ext->glUniform4f(This->shaders->shaders[PROG_CLIPSTENCIL].view,view[0],view[1],view[2],view[3]);
|
2406 | | - This->util->EnableArray(This->shaders->shaders[PROG_CLIPSTENCIL].pos,true);
|
| 2406 | + glUtil_EnableArray(This->util, This->shaders->shaders[PROG_CLIPSTENCIL].pos, TRUE);
|
2407 | 2407 | This->ext->glVertexAttribPointer(This->shaders->shaders[PROG_CLIPSTENCIL].pos,
|
2408 | 2408 | 2,GL_FLOAT,false,sizeof(BltVertex),&surface->clipper->vertices[0].x);
|
2409 | | - This->util->SetCull(D3DCULL_NONE);
|
2410 | | - This->util->SetPolyMode(D3DFILL_SOLID);
|
| 2409 | + glUtil_SetCull(This->util, D3DCULL_NONE);
|
| 2410 | + glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
|
2411 | 2411 | This->ext->glDrawRangeElements(GL_TRIANGLES, 0, (6 * surface->clipper->clipsize) - 1,
|
2412 | 2412 | 6 * surface->clipper->clipsize, GL_UNSIGNED_SHORT, surface->clipper->indices);
|
2413 | | - This->util->SetFBO((FBO*)NULL);
|
| 2413 | + glUtil_SetFBO(This->util, NULL);
|
2414 | 2414 | SetEvent(This->busy);
|
2415 | 2415 | }
|
2416 | 2416 |
|
— | — | @@ -2431,12 +2431,12 @@ |
2432 | 2432 | {
|
2433 | 2433 | do
|
2434 | 2434 | {
|
2435 | | - if (This->util->SetFBO(dest->attachparent) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 2435 | + if (glUtil_SetFBOSurface(This->util, dest->attachparent) == GL_FRAMEBUFFER_COMPLETE) break;
|
2436 | 2436 | if (!dest->attachparent->texture->internalformats[1]) break;
|
2437 | 2437 | TextureManager_FixTexture(This->texman, dest->attachparent->texture,
|
2438 | 2438 | (dest->attachparent->bigbuffer ? dest->attachparent->bigbuffer : dest->attachparent->buffer),
|
2439 | 2439 | &dest->attachparent->dirty, dest->attachparent->miplevel);
|
2440 | | - This->util->SetFBO((FBO*)NULL);
|
| 2440 | + glUtil_SetFBO(This->util, NULL);
|
2441 | 2441 | dest->attachparent->fbo.fbcolor = NULL;
|
2442 | 2442 | dest->attachparent->fbo.fbz = NULL;
|
2443 | 2443 | } while (1);
|
— | — | @@ -2461,15 +2461,15 @@ |
2462 | 2462 | (dest->ddsd.dwHeight != dest->dummycolor->height))
|
2463 | 2463 | TextureManager__UploadTexture(This->texman, dest->dummycolor, 0, NULL,
|
2464 | 2464 | dest->ddsd.dwWidth, dest->ddsd.dwHeight, FALSE, TRUE);
|
2465 | | - This->util->SetFBO(&dest->zfbo, dest->dummycolor, dest->texture, false);
|
| 2465 | + glUtil_SetFBOTextures(This->util, &dest->zfbo, dest->dummycolor, dest->texture, FALSE);
|
2466 | 2466 | }
|
2467 | | - This->util->SetViewport(0, 0, dest->ddsd.dwWidth, dest->ddsd.dwHeight);
|
2468 | | - if (lpDestRect) This->util->SetScissor(true, lpDestRect->left, lpDestRect->top,
|
| 2467 | + glUtil_SetViewport(This->util, 0, 0, dest->ddsd.dwWidth, dest->ddsd.dwHeight);
|
| 2468 | + if (lpDestRect) glUtil_SetScissor(This->util, TRUE, lpDestRect->left, lpDestRect->top,
|
2469 | 2469 | lpDestRect->right, lpDestRect->bottom);
|
2470 | | - This->util->DepthWrite(true);
|
2471 | | - This->util->ClearDepth(lpDDBltFx->dwFillDepth / (double)0xFFFF);
|
| 2470 | + glUtil_DepthWrite(This->util, TRUE);
|
| 2471 | + glUtil_ClearDepth(This->util, lpDDBltFx->dwFillDepth / (double)0xFFFF); // FIXME: SOTE depth workaround
|
2472 | 2472 | glClear(GL_DEPTH_BUFFER_BIT);
|
2473 | | - if (lpDestRect)This->util->SetScissor(false, 0, 0, 0, 0);
|
| 2473 | + if (lpDestRect)glUtil_SetScissor(This->util, false, 0, 0, 0, 0);
|
2474 | 2474 | This->outputs[0] = DD_OK;
|
2475 | 2475 | SetEvent(This->busy);
|
2476 | 2476 | }
|
— | — | @@ -2877,29 +2877,29 @@ |
2878 | 2878 | switch (This->renderstate[D3DRENDERSTATE_ZFUNC])
|
2879 | 2879 | {
|
2880 | 2880 | case D3DCMP_NEVER:
|
2881 | | - This->util->SetDepthComp(GL_NEVER);
|
| 2881 | + glUtil_SetDepthComp(This->util, GL_NEVER);
|
2882 | 2882 | break;
|
2883 | 2883 | case D3DCMP_LESS:
|
2884 | | - This->util->SetDepthComp(GL_LESS);
|
| 2884 | + glUtil_SetDepthComp(This->util, GL_LESS);
|
2885 | 2885 | break;
|
2886 | 2886 | case D3DCMP_EQUAL:
|
2887 | | - This->util->SetDepthComp(GL_EQUAL);
|
| 2887 | + glUtil_SetDepthComp(This->util, GL_EQUAL);
|
2888 | 2888 | break;
|
2889 | 2889 | case D3DCMP_LESSEQUAL:
|
2890 | | - This->util->SetDepthComp(GL_LEQUAL);
|
| 2890 | + glUtil_SetDepthComp(This->util, GL_LEQUAL);
|
2891 | 2891 | break;
|
2892 | 2892 | case D3DCMP_GREATER:
|
2893 | | - This->util->SetDepthComp(GL_GREATER);
|
| 2893 | + glUtil_SetDepthComp(This->util, GL_GREATER);
|
2894 | 2894 | break;
|
2895 | 2895 | case D3DCMP_NOTEQUAL:
|
2896 | | - This->util->SetDepthComp(GL_NOTEQUAL);
|
| 2896 | + glUtil_SetDepthComp(This->util, GL_NOTEQUAL);
|
2897 | 2897 | break;
|
2898 | 2898 | case D3DCMP_GREATEREQUAL:
|
2899 | | - This->util->SetDepthComp(GL_GEQUAL);
|
| 2899 | + glUtil_SetDepthComp(This->util, GL_GEQUAL);
|
2900 | 2900 | break;
|
2901 | 2901 | case D3DCMP_ALWAYS:
|
2902 | 2902 | default:
|
2903 | | - This->util->SetDepthComp(GL_ALWAYS);
|
| 2903 | + glUtil_SetDepthComp(This->util, GL_ALWAYS);
|
2904 | 2904 | break;
|
2905 | 2905 | }
|
2906 | 2906 | }
|
Index: ddraw/glRenderer.h |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | } GLCAPS;
|
28 | 28 | typedef struct
|
29 | 29 | {
|
30 | | - bool enabled;
|
| 30 | + BOOL enabled;
|
31 | 31 | int width;
|
32 | 32 | int height;
|
33 | 33 | int pitch;
|
Index: ddraw/glUtil.cpp |
— | — | @@ -21,145 +21,165 @@ |
22 | 22 | #include "BufferObject.h"
|
23 | 23 | #include "glDirectDrawSurface.h"
|
24 | 24 |
|
25 | | -glUtil::glUtil(glExtensions *glext)
|
| 25 | +extern "C" {
|
| 26 | +
|
| 27 | +void glUtil_Create(glExtensions *glext, glUtil **out)
|
26 | 28 | {
|
27 | | - ext = glext;
|
28 | | - depthwrite = true;
|
29 | | - depthtest = false;
|
30 | | - depthcomp = 0;
|
31 | | - alphacomp = 0;
|
32 | | - currentfbo = NULL;
|
33 | | - scissorx = 0;
|
34 | | - scissory = 0;
|
35 | | - scissorwidth = 0;
|
36 | | - scissorheight = 0;
|
37 | | - viewportx = 0;
|
38 | | - viewporty = 0;
|
39 | | - viewportwidth = 0;
|
40 | | - viewportheight = 0;
|
41 | | - depthnear = 0.0;
|
42 | | - depthfar = 1.0;
|
43 | | - matrixmode = GL_MODELVIEW;
|
44 | | - ZeroMemory(materialambient, 4 * sizeof(GLfloat));
|
45 | | - ZeroMemory(materialdiffuse, 4 * sizeof(GLfloat));
|
46 | | - ZeroMemory(materialspecular, 4 * sizeof(GLfloat));
|
47 | | - ZeroMemory(materialemission, 4 * sizeof(GLfloat));
|
48 | | - materialshininess = 0;
|
49 | | - scissorenabled = false;
|
50 | | - texwrap[16];
|
51 | | - clearr = 0.0;
|
52 | | - clearg = 0.0;
|
53 | | - clearb = 0.0;
|
54 | | - cleara = 0.0;
|
55 | | - cleardepth = 1.0;
|
56 | | - clearstencil = 0;
|
57 | | - blendsrc = GL_ONE;
|
58 | | - blenddest = GL_ZERO;
|
59 | | - blendenabled = false;
|
60 | | - arrays[42];
|
61 | | - cullmode = D3DCULL_NONE;
|
62 | | - cullenabled = false;
|
63 | | - polymode = D3DFILL_SOLID;
|
64 | | - shademode = D3DSHADE_GOURAUD;
|
65 | | - pboPackBinding = pboUnpackBinding = vboArrayBinding =
|
66 | | - vboElementArrayBinding = uboUniformBufferBinding = LastBoundBuffer = NULL;
|
| 29 | + glUtil *util;
|
| 30 | + util = (glUtil *)malloc(sizeof(glUtil));
|
| 31 | + if (!util) return;
|
| 32 | + ZeroMemory(util, sizeof(glUtil));
|
| 33 | + util->ext = glext;
|
| 34 | + util->depthwrite = TRUE;
|
| 35 | + util->depthtest = FALSE;
|
| 36 | + util->depthcomp = 0;
|
| 37 | + util->alphacomp = 0;
|
| 38 | + util->currentfbo = NULL;
|
| 39 | + util->scissorx = 0;
|
| 40 | + util->scissory = 0;
|
| 41 | + util->scissorwidth = 0;
|
| 42 | + util->scissorheight = 0;
|
| 43 | + util->viewportx = 0;
|
| 44 | + util->viewporty = 0;
|
| 45 | + util->viewportwidth = 0;
|
| 46 | + util->viewportheight = 0;
|
| 47 | + util->depthnear = 0.0;
|
| 48 | + util->depthfar = 1.0;
|
| 49 | + util->matrixmode = GL_MODELVIEW;
|
| 50 | + ZeroMemory(util->materialambient, 4 * sizeof(GLfloat));
|
| 51 | + ZeroMemory(util->materialdiffuse, 4 * sizeof(GLfloat));
|
| 52 | + ZeroMemory(util->materialspecular, 4 * sizeof(GLfloat));
|
| 53 | + ZeroMemory(util->materialemission, 4 * sizeof(GLfloat));
|
| 54 | + util->materialshininess = 0;
|
| 55 | + util->scissorenabled = FALSE;
|
| 56 | + util->texwrap[16];
|
| 57 | + util->clearr = 0.0;
|
| 58 | + util->clearg = 0.0;
|
| 59 | + util->clearb = 0.0;
|
| 60 | + util->cleara = 0.0;
|
| 61 | + util->cleardepth = 1.0;
|
| 62 | + util->clearstencil = 0;
|
| 63 | + util->blendsrc = GL_ONE;
|
| 64 | + util->blenddest = GL_ZERO;
|
| 65 | + util->blendenabled = FALSE;
|
| 66 | + util->arrays[42];
|
| 67 | + util->cullmode = D3DCULL_NONE;
|
| 68 | + util->cullenabled = FALSE;
|
| 69 | + util->polymode = D3DFILL_SOLID;
|
| 70 | + util->shademode = D3DSHADE_GOURAUD;
|
| 71 | + util->pboPackBinding = util->pboUnpackBinding = util->vboArrayBinding =
|
| 72 | + util->vboElementArrayBinding = util->uboUniformBufferBinding = util->LastBoundBuffer = NULL;
|
| 73 | + util->refcount = 1;
|
| 74 | + *out = util;
|
67 | 75 | }
|
68 | | -void glUtil::InitFBO(FBO *fbo)
|
| 76 | +
|
| 77 | +void glUtil_AddRef(glUtil *This)
|
69 | 78 | {
|
| 79 | + InterlockedIncrement(&This->refcount);
|
| 80 | +}
|
| 81 | +
|
| 82 | +void glUtil_Release(glUtil *This)
|
| 83 | +{
|
| 84 | + InterlockedDecrement(&This->refcount);
|
| 85 | + if (!This->refcount) free(This);
|
| 86 | +}
|
| 87 | +
|
| 88 | +void glUtil_InitFBO(glUtil *This, FBO *fbo)
|
| 89 | +{
|
70 | 90 | if(!fbo->fbo)
|
71 | 91 | {
|
72 | 92 | ZeroMemory(fbo,sizeof(FBO));
|
73 | | - if(ext->GLEXT_ARB_framebuffer_object) ext->glGenFramebuffers(1,&fbo->fbo);
|
74 | | - else if(ext->GLEXT_EXT_framebuffer_object) ext->glGenFramebuffersEXT(1,&fbo->fbo);
|
| 93 | + if(This->ext->GLEXT_ARB_framebuffer_object) This->ext->glGenFramebuffers(1,&fbo->fbo);
|
| 94 | + else if(This->ext->GLEXT_EXT_framebuffer_object) This->ext->glGenFramebuffersEXT(1,&fbo->fbo);
|
75 | 95 | }
|
76 | 96 | }
|
77 | 97 |
|
78 | | -void glUtil::DeleteFBO(FBO *fbo)
|
| 98 | +void glUtil_DeleteFBO(glUtil *This, FBO *fbo)
|
79 | 99 | {
|
80 | 100 | if(fbo->fbo)
|
81 | 101 | {
|
82 | | - if(ext->GLEXT_ARB_framebuffer_object)
|
| 102 | + if(This->ext->GLEXT_ARB_framebuffer_object)
|
83 | 103 | {
|
84 | | - if(currentfbo == fbo) ext->glBindFramebuffer(GL_FRAMEBUFFER,0);
|
85 | | - ext->glDeleteFramebuffers(1,&fbo->fbo);
|
| 104 | + if(This->currentfbo == fbo) This->ext->glBindFramebuffer(GL_FRAMEBUFFER,0);
|
| 105 | + This->ext->glDeleteFramebuffers(1,&fbo->fbo);
|
86 | 106 | ZeroMemory(fbo,sizeof(FBO));
|
87 | 107 | }
|
88 | | - else if(ext->GLEXT_EXT_framebuffer_object)
|
| 108 | + else if(This->ext->GLEXT_EXT_framebuffer_object)
|
89 | 109 | {
|
90 | | - if(currentfbo == fbo) ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
|
91 | | - ext->glDeleteFramebuffersEXT(1,&fbo->fbo);
|
| 110 | + if(This->currentfbo == fbo) This->ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
|
| 111 | + This->ext->glDeleteFramebuffersEXT(1,&fbo->fbo);
|
92 | 112 | ZeroMemory(fbo,sizeof(FBO));
|
93 | 113 | }
|
94 | 114 | }
|
95 | 115 | }
|
96 | 116 |
|
97 | | -void glUtil::SetFBOTexture(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil)
|
| 117 | +void glUtil_SetFBOTexture(glUtil *This, FBO *fbo, TEXTURE *color, TEXTURE *z, BOOL stencil)
|
98 | 118 | {
|
99 | 119 | if(!color) return;
|
100 | 120 | if(!fbo->fbo) return;
|
101 | | - if(ext->GLEXT_ARB_framebuffer_object)
|
| 121 | + if(This->ext->GLEXT_ARB_framebuffer_object)
|
102 | 122 | {
|
103 | | - if(currentfbo != fbo) ext->glBindFramebuffer(GL_FRAMEBUFFER,fbo->fbo);
|
104 | | - currentfbo = fbo;
|
105 | | - ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,color->id,0);
|
| 123 | + if(This->currentfbo != fbo) This->ext->glBindFramebuffer(GL_FRAMEBUFFER,fbo->fbo);
|
| 124 | + This->currentfbo = fbo;
|
| 125 | + This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,color->id,0);
|
106 | 126 | fbo->fbcolor = color;
|
107 | 127 | if(stencil)
|
108 | 128 | {
|
109 | | - if(!fbo->stencil) ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
110 | | - if(z)ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,z->id,0);
|
111 | | - else ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
| 129 | + if(!fbo->stencil) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
| 130 | + if(z)This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,z->id,0);
|
| 131 | + else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
112 | 132 | }
|
113 | 133 | else
|
114 | 134 | {
|
115 | | - if(fbo->stencil) ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
116 | | - if(z) ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,z->id,0);
|
117 | | - else ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
| 135 | + if(fbo->stencil) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
| 136 | + if(z) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,z->id,0);
|
| 137 | + else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
118 | 138 | }
|
119 | 139 | fbo->stencil = stencil;
|
120 | 140 | fbo->fbz = z;
|
121 | | - fbo->status = ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
| 141 | + fbo->status = This->ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
122 | 142 | }
|
123 | | - else if(ext->GLEXT_EXT_framebuffer_object)
|
| 143 | + else if(This->ext->GLEXT_EXT_framebuffer_object)
|
124 | 144 | {
|
125 | | - if(currentfbo != fbo) ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo->fbo);
|
126 | | - currentfbo = fbo;
|
127 | | - ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,color->id,0);
|
| 145 | + if (This->currentfbo != fbo) This->ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->fbo);
|
| 146 | + This->currentfbo = fbo;
|
| 147 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color->id, 0);
|
128 | 148 | fbo->fbcolor = color;
|
129 | 149 | if(stencil)
|
130 | 150 | {
|
131 | 151 | if(z)
|
132 | 152 | {
|
133 | | - ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,z->id,0);
|
134 | | - ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_STENCIL_ATTACHMENT_EXT,GL_TEXTURE_2D,z->id,0);
|
| 153 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, 0);
|
| 154 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, 0);
|
135 | 155 | }
|
136 | 156 | else
|
137 | 157 | {
|
138 | | - ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,0,0);
|
139 | | - ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_STENCIL_ATTACHMENT_EXT,GL_TEXTURE_2D,0,0);
|
| 158 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
| 159 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
140 | 160 | }
|
141 | 161 | }
|
142 | 162 | else
|
143 | 163 | {
|
144 | | - ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_STENCIL_ATTACHMENT_EXT,GL_TEXTURE_2D,0,0);
|
145 | | - if(z)ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,z->id,0);
|
146 | | - else ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,0,0);
|
| 164 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
| 165 | + if (z)This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, 0);
|
| 166 | + else This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
147 | 167 | }
|
148 | 168 | fbo->stencil = stencil;
|
149 | 169 | fbo->fbz = z;
|
150 | | - fbo->status = ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
| 170 | + fbo->status = This->ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
151 | 171 | }
|
152 | 172 | }
|
153 | 173 |
|
154 | | -GLenum glUtil::SetFBO(glDirectDrawSurface7 *surface)
|
| 174 | +GLenum glUtil_SetFBOSurface(glUtil *This, glDirectDrawSurface7 *surface)
|
155 | 175 | {
|
156 | | - if(!surface) return SetFBO((FBO*)NULL);
|
157 | | - if(surface->zbuffer) return SetFBO(&surface->fbo,surface->texture,surface->zbuffer->texture,surface->zbuffer->hasstencil);
|
158 | | - else return SetFBO(&surface->fbo,surface->texture,NULL,false);
|
| 176 | + if (!surface) return glUtil_SetFBO(This, (FBO*)NULL);
|
| 177 | + if (surface->zbuffer) return glUtil_SetFBOTextures(This, &surface->fbo, surface->texture, surface->zbuffer->texture, surface->zbuffer->hasstencil);
|
| 178 | + else return glUtil_SetFBOTextures(This, &surface->fbo, surface->texture, NULL, FALSE);
|
159 | 179 | }
|
160 | 180 |
|
161 | | -GLenum glUtil::SetFBO(FBO *fbo)
|
| 181 | +GLenum glUtil_SetFBO(glUtil *This, FBO *fbo)
|
162 | 182 | {
|
163 | | - if (fbo == currentfbo)
|
| 183 | + if (fbo == This->currentfbo)
|
164 | 184 | {
|
165 | 185 | if (fbo) return fbo->status;
|
166 | 186 | else return GL_FRAMEBUFFER_COMPLETE;
|
— | — | @@ -166,52 +186,52 @@ |
167 | 187 | }
|
168 | 188 | if(!fbo)
|
169 | 189 | {
|
170 | | - if (ext->GLEXT_ARB_framebuffer_object) ext->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
171 | | - else if(ext->GLEXT_EXT_framebuffer_object) ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
|
| 190 | + if (This->ext->GLEXT_ARB_framebuffer_object) This->ext->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
| 191 | + else if (This->ext->GLEXT_EXT_framebuffer_object) This->ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
172 | 192 | }
|
173 | 193 | else
|
174 | 194 | {
|
175 | | - if (ext->GLEXT_ARB_framebuffer_object)
|
| 195 | + if (This->ext->GLEXT_ARB_framebuffer_object)
|
176 | 196 | {
|
177 | | - ext->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fbo);
|
178 | | - fbo->status = ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
| 197 | + This->ext->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fbo);
|
| 198 | + fbo->status = This->ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
179 | 199 | }
|
180 | | - else if (ext->GLEXT_EXT_framebuffer_object)
|
| 200 | + else if (This->ext->GLEXT_EXT_framebuffer_object)
|
181 | 201 | {
|
182 | | - ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->fbo);
|
183 | | - fbo->status = ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
| 202 | + This->ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->fbo);
|
| 203 | + fbo->status = This->ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
184 | 204 | }
|
185 | 205 | }
|
186 | | - currentfbo = fbo;
|
| 206 | + This->currentfbo = fbo;
|
187 | 207 | if (fbo) return fbo->status;
|
188 | 208 | else
|
189 | 209 | {
|
190 | | - if (ext->GLEXT_ARB_framebuffer_object) return ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
191 | | - else if (ext->GLEXT_EXT_framebuffer_object) return ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
| 210 | + if (This->ext->GLEXT_ARB_framebuffer_object) return This->ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
| 211 | + else if (This->ext->GLEXT_EXT_framebuffer_object) return This->ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
192 | 212 | else return 0;
|
193 | 213 | }
|
194 | 214 | }
|
195 | 215 |
|
196 | | -GLenum glUtil::SetFBO(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil)
|
| 216 | +GLenum glUtil_SetFBOTextures(glUtil *This, FBO *fbo, TEXTURE *color, TEXTURE *z, BOOL stencil)
|
197 | 217 | {
|
198 | 218 | if(!fbo)
|
199 | 219 | {
|
200 | | - return SetFBO((FBO*)NULL);
|
| 220 | + return glUtil_SetFBO(This, (FBO*)NULL);
|
201 | 221 | }
|
202 | | - if(!fbo->fbo) InitFBO(fbo);
|
| 222 | + if(!fbo->fbo) glUtil_InitFBO(This, fbo);
|
203 | 223 | if (!color) return GL_INVALID_ENUM;
|
204 | 224 | if((color != fbo->fbcolor) || (z != fbo->fbz) || (stencil != fbo->stencil))
|
205 | | - SetFBOTexture(fbo,color,z,stencil);
|
206 | | - if(fbo != currentfbo) return SetFBO(fbo);
|
| 225 | + glUtil_SetFBOTexture(This, fbo,color,z,stencil);
|
| 226 | + if(fbo != This->currentfbo) return glUtil_SetFBO(This, fbo);
|
207 | 227 | else return fbo->status;
|
208 | 228 | }
|
209 | 229 |
|
210 | | -void glUtil::SetWrap(int level, DWORD coord, DWORD address, TextureManager *texman)
|
| 230 | +void glUtil_SetWrap(glUtil *This, int level, DWORD coord, DWORD address, TextureManager *texman)
|
211 | 231 | {
|
212 | 232 | if(level == -1)
|
213 | 233 | {
|
214 | 234 | for(int i = 0; i < 16; i++)
|
215 | | - texwrap[i] = GL_REPEAT;
|
| 235 | + This->texwrap[i] = GL_REPEAT;
|
216 | 236 | }
|
217 | 237 | if(coord > 1) return;
|
218 | 238 | if(level > 7) return;
|
— | — | @@ -237,15 +257,15 @@ |
238 | 258 | //if(texwrap[level*2+coord] == wrapmode) return;
|
239 | 259 | //else
|
240 | 260 | {
|
241 | | - texwrap[level*2+coord] = wrapmode;
|
| 261 | + This->texwrap[level * 2 + coord] = wrapmode;
|
242 | 262 | //int currtexture = texlevel;
|
243 | | - if(ext->GLEXT_ARB_sampler_objects)
|
| 263 | + if (This->ext->GLEXT_ARB_sampler_objects)
|
244 | 264 | {
|
245 | 265 | if(coord)
|
246 | 266 | {
|
247 | 267 | if(texman->samplers[level].wrapt != wrapmode)
|
248 | 268 | {
|
249 | | - ext->glSamplerParameteri(texman->samplers[level].id,GL_TEXTURE_WRAP_T,wrapmode);
|
| 269 | + This->ext->glSamplerParameteri(texman->samplers[level].id, GL_TEXTURE_WRAP_T, wrapmode);
|
250 | 270 | texman->samplers[level].wrapt = wrapmode;
|
251 | 271 | }
|
252 | 272 | }
|
— | — | @@ -253,7 +273,7 @@ |
254 | 274 | {
|
255 | 275 | if(texman->samplers[level].wraps != wrapmode)
|
256 | 276 | {
|
257 | | - ext->glSamplerParameteri(texman->samplers[level].id,GL_TEXTURE_WRAP_S,wrapmode);
|
| 277 | + This->ext->glSamplerParameteri(texman->samplers[level].id, GL_TEXTURE_WRAP_S, wrapmode);
|
258 | 278 | texman->samplers[level].wraps = wrapmode;
|
259 | 279 | }
|
260 | 280 | }
|
— | — | @@ -264,233 +284,236 @@ |
265 | 285 | if(coord) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,wrapmode);
|
266 | 286 | else glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,wrapmode);
|
267 | 287 | }
|
268 | | - //SetActiveTexture(currtexture);
|
| 288 | + //TextureManager_SetActiveTexture(texman,currtexture);
|
269 | 289 | }
|
270 | 290 | }
|
271 | 291 |
|
272 | | -void glUtil::DepthWrite(bool enabled)
|
| 292 | +void glUtil_DepthWrite(glUtil *This, BOOL enabled)
|
273 | 293 | {
|
274 | | - if(enabled != depthwrite)
|
| 294 | + if (enabled != This->depthwrite)
|
275 | 295 | {
|
276 | | - depthwrite = enabled;
|
277 | | - if(depthwrite) glDepthMask(GL_TRUE);
|
| 296 | + This->depthwrite = enabled;
|
| 297 | + if (This->depthwrite) glDepthMask(GL_TRUE);
|
278 | 298 | else glDepthMask(GL_FALSE);
|
279 | 299 | }
|
280 | 300 | }
|
281 | | -void glUtil::DepthTest(bool enabled)
|
| 301 | +void glUtil_DepthTest(glUtil *This, BOOL enabled)
|
282 | 302 | {
|
283 | | - if(enabled != depthtest)
|
| 303 | + if (enabled != This->depthtest)
|
284 | 304 | {
|
285 | | - depthtest = enabled;
|
286 | | - if(depthtest) glEnable(GL_DEPTH_TEST);
|
| 305 | + This->depthtest = enabled;
|
| 306 | + if (This->depthtest) glEnable(GL_DEPTH_TEST);
|
287 | 307 | else glDisable(GL_DEPTH_TEST);
|
288 | 308 | }
|
289 | 309 | }
|
290 | | -void glUtil::SetDepthComp(GLenum comp)
|
| 310 | +void glUtil_SetDepthComp(glUtil *This, GLenum comp)
|
291 | 311 | {
|
292 | | - if(comp != depthcomp)
|
| 312 | + if (comp != This->depthcomp)
|
293 | 313 | {
|
294 | | - depthcomp = comp;
|
| 314 | + This->depthcomp = comp;
|
295 | 315 | glDepthFunc(comp);
|
296 | 316 | }
|
297 | 317 | }
|
298 | 318 |
|
299 | | -void glUtil::SetScissor(bool enabled, GLint x, GLint y, GLsizei width, GLsizei height)
|
| 319 | +void glUtil_SetScissor(glUtil *This, BOOL enabled, GLint x, GLint y, GLsizei width, GLsizei height)
|
300 | 320 | {
|
301 | | - if(enabled != scissorenabled)
|
| 321 | + if (enabled != This->scissorenabled)
|
302 | 322 | {
|
303 | | - scissorenabled = enabled;
|
| 323 | + This->scissorenabled = enabled;
|
304 | 324 | if(enabled) glEnable(GL_SCISSOR_TEST);
|
305 | 325 | else glDisable(GL_SCISSOR_TEST);
|
306 | 326 | }
|
307 | | - if((x != scissorx) || (y != scissory) || (width != scissorwidth) || (height != scissorheight))
|
| 327 | + if ((x != This->scissorx) || (y != This->scissory) ||
|
| 328 | + (width != This->scissorwidth) || (height != This->scissorheight))
|
308 | 329 | {
|
309 | | - scissorx = x;
|
310 | | - scissory = y;
|
311 | | - scissorwidth = width;
|
312 | | - scissorheight = height;
|
| 330 | + This->scissorx = x;
|
| 331 | + This->scissory = y;
|
| 332 | + This->scissorwidth = width;
|
| 333 | + This->scissorheight = height;
|
313 | 334 | glScissor(x,y,width,height);
|
314 | 335 | }
|
315 | 336 | }
|
316 | 337 |
|
317 | | -void glUtil::MatrixMode(GLenum mode)
|
| 338 | +void glUtil_MatrixMode(glUtil *This, GLenum mode)
|
318 | 339 | {
|
319 | | - if(mode != matrixmode)
|
| 340 | + if (mode != This->matrixmode)
|
320 | 341 | {
|
321 | | - matrixmode = mode;
|
| 342 | + This->matrixmode = mode;
|
322 | 343 | glMatrixMode(mode);
|
323 | 344 | }
|
324 | 345 | }
|
325 | 346 |
|
326 | | -void glUtil::SetMatrix(GLenum mode, GLfloat *mat1, GLfloat *mat2, bool *dirty)
|
| 347 | +void glUtil_SetMatrix(glUtil *This, GLenum mode, GLfloat *mat1, GLfloat *mat2, BOOL *dirty)
|
327 | 348 | {
|
328 | | - if(ext->GLEXT_EXT_direct_state_access)
|
| 349 | + if(This->ext->GLEXT_EXT_direct_state_access)
|
329 | 350 | {
|
330 | | - ext->glMatrixLoadfEXT(mode,mat1);
|
331 | | - if(mode == GL_MODELVIEW) ext->glMatrixMultfEXT(mode,mat2);
|
| 351 | + This->ext->glMatrixLoadfEXT(mode, mat1);
|
| 352 | + if (mode == GL_MODELVIEW) This->ext->glMatrixMultfEXT(mode, mat2);
|
332 | 353 | }
|
333 | 354 | else
|
334 | 355 | {
|
335 | | - MatrixMode(mode);
|
| 356 | + glUtil_MatrixMode(This, mode);
|
336 | 357 | glLoadMatrixf(mat1);
|
337 | 358 | if(mode == GL_MODELVIEW) glMultMatrixf(mat2);
|
338 | 359 | }
|
339 | | - if(dirty) *dirty = false;
|
| 360 | + if(dirty) *dirty = FALSE;
|
340 | 361 | }
|
341 | 362 |
|
342 | | -void glUtil::SetMaterial(GLfloat ambient[4],GLfloat diffuse[4],GLfloat specular[4],GLfloat emission[4],GLfloat shininess)
|
| 363 | +void glUtil_SetMaterial(glUtil *This, GLfloat ambient[4],GLfloat diffuse[4],GLfloat specular[4],GLfloat emission[4],GLfloat shininess)
|
343 | 364 | {
|
344 | | - if(memcmp(ambient,materialambient,4*sizeof(GLfloat)))
|
| 365 | + if(memcmp(ambient,This->materialambient,4*sizeof(GLfloat)))
|
345 | 366 | {
|
346 | | - memcpy(materialambient,ambient,4*sizeof(GLfloat));
|
| 367 | + memcpy(This->materialambient, ambient, 4 * sizeof(GLfloat));
|
347 | 368 | glMaterialfv(GL_FRONT,GL_AMBIENT,ambient);
|
348 | 369 | }
|
349 | | - if(memcmp(diffuse,materialdiffuse,4*sizeof(GLfloat)))
|
| 370 | + if (memcmp(diffuse, This->materialdiffuse, 4 * sizeof(GLfloat)))
|
350 | 371 | {
|
351 | | - memcpy(materialdiffuse,diffuse,4*sizeof(GLfloat));
|
| 372 | + memcpy(This->materialdiffuse, diffuse, 4 * sizeof(GLfloat));
|
352 | 373 | glMaterialfv(GL_FRONT,GL_DIFFUSE,diffuse);
|
353 | 374 | }
|
354 | | - if(memcmp(specular,materialspecular,4*sizeof(GLfloat)))
|
| 375 | + if (memcmp(specular, This->materialspecular, 4 * sizeof(GLfloat)))
|
355 | 376 | {
|
356 | | - memcpy(materialspecular,specular,4*sizeof(GLfloat));
|
| 377 | + memcpy(This->materialspecular, specular, 4 * sizeof(GLfloat));
|
357 | 378 | glMaterialfv(GL_FRONT,GL_SPECULAR,specular);
|
358 | 379 | }
|
359 | | - if(memcmp(emission,materialemission,4*sizeof(GLfloat)))
|
| 380 | + if (memcmp(emission, This->materialemission, 4 * sizeof(GLfloat)))
|
360 | 381 | {
|
361 | | - memcpy(materialemission,emission,4*sizeof(GLfloat));
|
| 382 | + memcpy(This->materialemission, emission, 4 * sizeof(GLfloat));
|
362 | 383 | glMaterialfv(GL_FRONT,GL_EMISSION,emission);
|
363 | 384 | }
|
364 | | - if(shininess != materialshininess)
|
| 385 | + if (shininess != This->materialshininess)
|
365 | 386 | {
|
366 | | - materialshininess = shininess;
|
| 387 | + This->materialshininess = shininess;
|
367 | 388 | glMaterialf(GL_FRONT,GL_SHININESS,shininess);
|
368 | 389 | }
|
369 | 390 | }
|
370 | 391 |
|
371 | | -void glUtil::SetViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
| 392 | +void glUtil_SetViewport(glUtil *This, GLint x, GLint y, GLsizei width, GLsizei height)
|
372 | 393 | {
|
373 | | - if((x != viewportx) || (y != viewporty) || (width != viewportwidth) || (height != viewportheight))
|
| 394 | + if ((x != This->viewportx) || (y != This->viewporty) ||
|
| 395 | + (width != This->viewportwidth) || (height != This->viewportheight))
|
374 | 396 | {
|
375 | | - viewportx = x;
|
376 | | - viewporty = y;
|
377 | | - viewportwidth = width;
|
378 | | - viewportheight = height;
|
| 397 | + This->viewportx = x;
|
| 398 | + This->viewporty = y;
|
| 399 | + This->viewportwidth = width;
|
| 400 | + This->viewportheight = height;
|
379 | 401 | glViewport(x,y,width,height);
|
380 | 402 | }
|
381 | 403 | }
|
382 | 404 |
|
383 | | -void glUtil::SetDepthRange(GLclampd rangenear, GLclampd rangefar)
|
| 405 | +void glUtil_SetDepthRange(glUtil *This, GLclampd rangenear, GLclampd rangefar)
|
384 | 406 | {
|
385 | | - if((rangenear != depthnear) || (rangefar != depthfar))
|
| 407 | + if ((rangenear != This->depthnear) || (rangefar != This->depthfar))
|
386 | 408 | {
|
387 | | - depthnear = rangenear;
|
388 | | - depthfar = rangefar;
|
| 409 | + This->depthnear = rangenear;
|
| 410 | + This->depthfar = rangefar;
|
389 | 411 | glDepthRange(rangenear,rangefar);
|
390 | 412 | }
|
391 | 413 | }
|
392 | 414 |
|
393 | | -void glUtil::ClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a)
|
| 415 | +void glUtil_ClearColor(glUtil *This, GLclampf r, GLclampf g, GLclampf b, GLclampf a)
|
394 | 416 | {
|
395 | | - if((clearr != r) || (clearg != g) || (clearb != b) || (cleara != a))
|
| 417 | + if ((This->clearr != r) || (This->clearg != g) ||
|
| 418 | + (This->clearb != b) || (This->cleara != a))
|
396 | 419 | {
|
397 | | - clearr = r;
|
398 | | - clearg = g;
|
399 | | - clearb = b;
|
400 | | - cleara = a;
|
| 420 | + This->clearr = r;
|
| 421 | + This->clearg = g;
|
| 422 | + This->clearb = b;
|
| 423 | + This->cleara = a;
|
401 | 424 | glClearColor(r,g,b,a);
|
402 | 425 | }
|
403 | 426 | }
|
404 | 427 |
|
405 | | -void glUtil::ClearDepth(GLclampd depth)
|
| 428 | +void glUtil_ClearDepth(glUtil *This, GLclampd depth)
|
406 | 429 | {
|
407 | | - if(cleardepth != depth)
|
| 430 | + if (This->cleardepth != depth)
|
408 | 431 | {
|
409 | | - cleardepth = depth;
|
| 432 | + This->cleardepth = depth;
|
410 | 433 | glClearDepth(depth);
|
411 | 434 | }
|
412 | 435 | }
|
413 | 436 |
|
414 | | -void glUtil::ClearStencil(GLint stencil)
|
| 437 | +void glUtil_ClearStencil(glUtil *This, GLint stencil)
|
415 | 438 | {
|
416 | | - if(clearstencil != stencil)
|
| 439 | + if (This->clearstencil != stencil)
|
417 | 440 | {
|
418 | | - clearstencil = stencil;
|
| 441 | + This->clearstencil = stencil;
|
419 | 442 | glClearStencil(stencil);
|
420 | 443 | }
|
421 | 444 | }
|
422 | 445 |
|
423 | | -void glUtil::EnableArray(int index, bool enabled)
|
| 446 | +void glUtil_EnableArray(glUtil *This, int index, BOOL enabled)
|
424 | 447 | {
|
425 | 448 | if(index == -1)
|
426 | 449 | {
|
427 | 450 | for(int i = 0; i < 42; i++)
|
428 | | - arrays[i] = false;
|
| 451 | + This->arrays[i] = FALSE;
|
429 | 452 | return;
|
430 | 453 | }
|
431 | 454 | if(index >= 42) return;
|
432 | | - if(arrays[index] != enabled)
|
| 455 | + if (This->arrays[index] != enabled)
|
433 | 456 | {
|
434 | | - arrays[index] = enabled;
|
435 | | - if(enabled) ext->glEnableVertexAttribArray(index);
|
436 | | - else ext->glDisableVertexAttribArray(index);
|
| 457 | + This->arrays[index] = enabled;
|
| 458 | + if (enabled) This->ext->glEnableVertexAttribArray(index);
|
| 459 | + else This->ext->glDisableVertexAttribArray(index);
|
437 | 460 | }
|
438 | 461 | }
|
439 | 462 |
|
440 | | -void glUtil::BlendFunc(GLenum src, GLenum dest)
|
| 463 | +void glUtil_BlendFunc(glUtil *This, GLenum src, GLenum dest)
|
441 | 464 | {
|
442 | | - if((blendsrc != src) || (blenddest != dest))
|
| 465 | + if ((This->blendsrc != src) || (This->blenddest != dest))
|
443 | 466 | {
|
444 | | - blendsrc = src;
|
445 | | - blenddest = dest;
|
| 467 | + This->blendsrc = src;
|
| 468 | + This->blenddest = dest;
|
446 | 469 | glBlendFunc(src,dest);
|
447 | 470 | }
|
448 | 471 | }
|
449 | 472 |
|
450 | | -void glUtil::BlendEnable(bool enabled)
|
| 473 | +void glUtil_BlendEnable(glUtil *This, BOOL enabled)
|
451 | 474 | {
|
452 | | - if(enabled != blendenabled)
|
| 475 | + if(enabled != This->blendenabled)
|
453 | 476 | {
|
454 | | - blendenabled = enabled;
|
| 477 | + This->blendenabled = enabled;
|
455 | 478 | if(enabled) glEnable(GL_BLEND);
|
456 | 479 | else glDisable(GL_BLEND);
|
457 | 480 | }
|
458 | 481 | }
|
459 | 482 |
|
460 | | -void glUtil::EnableCull(bool enabled)
|
| 483 | +void glUtil_EnableCull(glUtil *This, BOOL enabled)
|
461 | 484 | {
|
462 | | - if(cullenabled != enabled)
|
| 485 | + if (This->cullenabled != enabled)
|
463 | 486 | {
|
464 | | - cullenabled = enabled;
|
| 487 | + This->cullenabled = enabled;
|
465 | 488 | if(enabled) glEnable(GL_CULL_FACE);
|
466 | 489 | else glDisable(GL_CULL_FACE);
|
467 | 490 | }
|
468 | 491 | }
|
469 | | -void glUtil::SetCull(D3DCULL mode)
|
| 492 | +void glUtil_SetCull(glUtil *This, D3DCULL mode)
|
470 | 493 | {
|
471 | | - if(cullmode != mode)
|
| 494 | + if (This->cullmode != mode)
|
472 | 495 | {
|
473 | | - cullmode = mode;
|
| 496 | + This->cullmode = mode;
|
474 | 497 | switch(mode)
|
475 | 498 | {
|
476 | 499 | case D3DCULL_CCW:
|
477 | | - EnableCull(true);
|
| 500 | + glUtil_EnableCull(This, TRUE);
|
478 | 501 | glFrontFace(GL_CCW);
|
479 | 502 | break;
|
480 | 503 | case D3DCULL_CW:
|
481 | | - EnableCull(true);
|
| 504 | + glUtil_EnableCull(This, TRUE);
|
482 | 505 | glFrontFace(GL_CW);
|
483 | 506 | break;
|
484 | 507 | case D3DCULL_NONE:
|
485 | | - EnableCull(false);
|
| 508 | + glUtil_EnableCull(This, FALSE);
|
486 | 509 | break;
|
487 | 510 | }
|
488 | 511 | }
|
489 | 512 | }
|
490 | | -void glUtil::SetPolyMode(D3DFILLMODE mode)
|
| 513 | +void glUtil_SetPolyMode(glUtil *This, D3DFILLMODE mode)
|
491 | 514 | {
|
492 | | - if(polymode != mode)
|
| 515 | + if (This->polymode != mode)
|
493 | 516 | {
|
494 | | - polymode = mode;
|
| 517 | + This->polymode = mode;
|
495 | 518 | switch(mode)
|
496 | 519 | {
|
497 | 520 | case D3DFILL_POINT:
|
— | — | @@ -507,11 +530,11 @@ |
508 | 531 | }
|
509 | 532 | }
|
510 | 533 |
|
511 | | -void glUtil::SetShadeMode(D3DSHADEMODE mode)
|
| 534 | +void glUtil_SetShadeMode(glUtil *This, D3DSHADEMODE mode)
|
512 | 535 | {
|
513 | | - if(shademode != mode)
|
| 536 | + if (This->shademode != mode)
|
514 | 537 | {
|
515 | | - shademode = mode;
|
| 538 | + This->shademode = mode;
|
516 | 539 | switch(mode)
|
517 | 540 | {
|
518 | 541 | case D3DSHADE_FLAT:
|
— | — | @@ -527,40 +550,42 @@ |
528 | 551 | }
|
529 | 552 | }
|
530 | 553 |
|
531 | | -void glUtil::BindBuffer(BufferObject *buffer, GLenum target)
|
| 554 | +void glUtil_BindBuffer(glUtil *This, BufferObject *buffer, GLenum target)
|
532 | 555 | {
|
533 | 556 | switch (target)
|
534 | 557 | {
|
535 | 558 | case GL_PIXEL_PACK_BUFFER:
|
536 | | - LastBoundBuffer = pboPackBinding;
|
537 | | - pboPackBinding = buffer;
|
| 559 | + This->LastBoundBuffer = This->pboPackBinding;
|
| 560 | + This->pboPackBinding = buffer;
|
538 | 561 | break;
|
539 | 562 | case GL_PIXEL_UNPACK_BUFFER:
|
540 | | - LastBoundBuffer = pboUnpackBinding;
|
541 | | - pboUnpackBinding = buffer;
|
| 563 | + This->LastBoundBuffer = This->pboUnpackBinding;
|
| 564 | + This->pboUnpackBinding = buffer;
|
542 | 565 | break;
|
543 | 566 | case GL_ARRAY_BUFFER:
|
544 | | - LastBoundBuffer = vboArrayBinding;
|
545 | | - vboArrayBinding = buffer;
|
| 567 | + This->LastBoundBuffer = This->vboArrayBinding;
|
| 568 | + This->vboArrayBinding = buffer;
|
546 | 569 | break;
|
547 | 570 | case GL_ELEMENT_ARRAY_BUFFER:
|
548 | | - LastBoundBuffer = vboElementArrayBinding;
|
549 | | - vboElementArrayBinding = buffer;
|
| 571 | + This->LastBoundBuffer = This->vboElementArrayBinding;
|
| 572 | + This->vboElementArrayBinding = buffer;
|
550 | 573 | break;
|
551 | 574 | case GL_UNIFORM_BUFFER:
|
552 | | - LastBoundBuffer = uboUniformBufferBinding;
|
553 | | - uboUniformBufferBinding = buffer;
|
| 575 | + This->LastBoundBuffer = This->uboUniformBufferBinding;
|
| 576 | + This->uboUniformBufferBinding = buffer;
|
554 | 577 | break;
|
555 | 578 | default:
|
556 | | - LastBoundBuffer = NULL;
|
| 579 | + This->LastBoundBuffer = NULL;
|
557 | 580 | }
|
558 | | - if(buffer) ext->glBindBuffer(target, buffer->buffer);
|
559 | | - else ext->glBindBuffer(target, 0);
|
| 581 | + if (buffer) This->ext->glBindBuffer(target, buffer->buffer);
|
| 582 | + else This->ext->glBindBuffer(target, 0);
|
560 | 583 | }
|
561 | 584 |
|
562 | | -void glUtil::UndoBindBuffer(GLenum target)
|
| 585 | +void glUtil_UndoBindBuffer(glUtil *This, GLenum target)
|
563 | 586 | {
|
564 | | - if (LastBoundBuffer) ext->glBindBuffer(target, LastBoundBuffer->buffer);
|
565 | | - else ext->glBindBuffer(target, 0);
|
566 | | - LastBoundBuffer = NULL;
|
567 | | -} |
\ No newline at end of file |
| 587 | + if (This->LastBoundBuffer) This->ext->glBindBuffer(target, This->LastBoundBuffer->buffer);
|
| 588 | + else This->ext->glBindBuffer(target, 0);
|
| 589 | + This->LastBoundBuffer = NULL;
|
| 590 | +}
|
| 591 | +
|
| 592 | +}; |
\ No newline at end of file |
Index: ddraw/glUtil.h |
— | — | @@ -19,6 +19,13 @@ |
20 | 20 | #ifndef _GLUTIL_H
|
21 | 21 | #define _GLUTIL_H
|
22 | 22 |
|
| 23 | +#ifdef __cplusplus
|
| 24 | +class glDirectDrawSurface7;
|
| 25 | +extern "C" {
|
| 26 | +#else
|
| 27 | +typedef int glDirectDrawSurface7;
|
| 28 | +#endif
|
| 29 | +
|
23 | 30 | struct TEXTURE;
|
24 | 31 | struct BufferObject;
|
25 | 32 | struct TextureManager;
|
— | — | @@ -28,7 +35,7 @@ |
29 | 36 | GLuint fbo;
|
30 | 37 | TEXTURE *fbcolor;
|
31 | 38 | TEXTURE *fbz;
|
32 | | - bool stencil;
|
| 39 | + BOOL stencil;
|
33 | 40 | GLenum status;
|
34 | 41 | } FBO;
|
35 | 42 |
|
— | — | @@ -40,40 +47,9 @@ |
41 | 48 | GLfloat stencils, stencilt;
|
42 | 49 | } BltVertex;
|
43 | 50 |
|
44 | | -class glDirectDrawSurface7;
|
45 | | -
|
46 | | -class glUtil
|
| 51 | +typedef struct glUtil
|
47 | 52 | {
|
48 | | -public:
|
49 | | - glUtil(glExtensions *glext);
|
50 | | - void InitFBO(FBO *fbo);
|
51 | | - void DeleteFBO(FBO *fbo);
|
52 | | - void SetFBOTexture(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil);
|
53 | | - void SetWrap(int level, DWORD coord, DWORD address, TextureManager *texman);
|
54 | | - GLenum SetFBO(glDirectDrawSurface7 *surface);
|
55 | | - GLenum SetFBO(FBO *fbo);
|
56 | | - GLenum SetFBO(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil);
|
57 | | - void SetDepthComp(GLenum comp);
|
58 | | - void DepthWrite(bool enabled);
|
59 | | - void DepthTest(bool enabled);
|
60 | | - void SetScissor(bool enabled, GLint x, GLint y, GLsizei width, GLsizei height);
|
61 | | - void SetMatrix(GLenum mode, GLfloat *mat1, GLfloat *mat2, bool *dirty);
|
62 | | - void MatrixMode(GLenum mode);
|
63 | | - void SetMaterial(GLfloat ambient[4], GLfloat diffuse[4], GLfloat specular[4], GLfloat emission[4], GLfloat shininess);
|
64 | | - void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
65 | | - void SetDepthRange(GLclampd rangenear, GLclampd rangefar);
|
66 | | - void ClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a);
|
67 | | - void ClearDepth(GLclampd depth);
|
68 | | - void ClearStencil(GLint stencil);
|
69 | | - void EnableArray(int index, bool enabled);
|
70 | | - void BlendFunc(GLenum src, GLenum dest);
|
71 | | - void BlendEnable(bool enabled);
|
72 | | - void EnableCull(bool enabled);
|
73 | | - void SetCull(D3DCULL mode);
|
74 | | - void SetPolyMode(D3DFILLMODE mode);
|
75 | | - void SetShadeMode(D3DSHADEMODE mode);
|
76 | | - void BindBuffer(BufferObject *buffer, GLenum target);
|
77 | | - void UndoBindBuffer(GLenum target);
|
| 53 | + ULONG refcount;
|
78 | 54 | FBO *currentfbo;
|
79 | 55 | BufferObject *pboPackBinding;
|
80 | 56 | BufferObject *pboUnpackBinding;
|
— | — | @@ -80,10 +56,9 @@ |
81 | 57 | BufferObject *vboArrayBinding;
|
82 | 58 | BufferObject *vboElementArrayBinding;
|
83 | 59 | BufferObject *uboUniformBufferBinding;
|
84 | | -private:
|
85 | 60 | glExtensions *ext;
|
86 | | - bool depthwrite;
|
87 | | - bool depthtest;
|
| 61 | + BOOL depthwrite;
|
| 62 | + BOOL depthtest;
|
88 | 63 | GLuint depthcomp;
|
89 | 64 | GLuint alphacomp;
|
90 | 65 | GLint scissorx;
|
— | — | @@ -102,7 +77,7 @@ |
103 | 78 | GLfloat materialspecular[4];
|
104 | 79 | GLfloat materialemission[4];
|
105 | 80 | GLfloat materialshininess;
|
106 | | - bool scissorenabled;
|
| 81 | + BOOL scissorenabled;
|
107 | 82 | GLint texwrap[16];
|
108 | 83 | GLclampf clearr;
|
109 | 84 | GLclampf clearg;
|
— | — | @@ -112,13 +87,49 @@ |
113 | 88 | GLint clearstencil;
|
114 | 89 | GLenum blendsrc;
|
115 | 90 | GLenum blenddest;
|
116 | | - bool blendenabled;
|
117 | | - bool arrays[42];
|
| 91 | + BOOL blendenabled;
|
| 92 | + BOOL arrays[42];
|
118 | 93 | D3DCULL cullmode;
|
119 | | - bool cullenabled;
|
| 94 | + BOOL cullenabled;
|
120 | 95 | D3DFILLMODE polymode;
|
121 | 96 | D3DSHADEMODE shademode;
|
122 | 97 | BufferObject *LastBoundBuffer;
|
123 | | -};
|
| 98 | +} glUtil;
|
124 | 99 |
|
| 100 | +void glUtil_Create(glExtensions *glext, glUtil **out);
|
| 101 | +void glUtil_AddRef(glUtil *This);
|
| 102 | +void glUtil_Release(glUtil *This);
|
| 103 | +void glUtil_InitFBO(glUtil *This, FBO *fbo);
|
| 104 | +void glUtil_DeleteFBO(glUtil *This, FBO *fbo);
|
| 105 | +void glUtil_SetFBOTexture(glUtil *This, FBO *fbo, TEXTURE *color, TEXTURE *z, BOOL stencil);
|
| 106 | +void glUtil_SetWrap(glUtil *This, int level, DWORD coord, DWORD address, TextureManager *texman);
|
| 107 | +GLenum glUtil_SetFBOSurface(glUtil *This, glDirectDrawSurface7 *surface);
|
| 108 | +GLenum glUtil_SetFBO(glUtil *This, FBO *fbo);
|
| 109 | +GLenum glUtil_SetFBOTextures(glUtil *This, FBO *fbo, TEXTURE *color, TEXTURE *z, BOOL stencil);
|
| 110 | +void glUtil_SetDepthComp(glUtil *This, GLenum comp);
|
| 111 | +void glUtil_DepthWrite(glUtil *This, BOOL enabled);
|
| 112 | +void glUtil_DepthTest(glUtil *This, BOOL enabled);
|
| 113 | +void glUtil_SetScissor(glUtil *This, BOOL enabled, GLint x, GLint y, GLsizei width, GLsizei height);
|
| 114 | +void glUtil_SetMatrix(glUtil *This, GLenum mode, GLfloat *mat1, GLfloat *mat2, BOOL *dirty);
|
| 115 | +void glUtil_MatrixMode(glUtil *This, GLenum mode);
|
| 116 | +void glUtil_SetMaterial(glUtil *This, GLfloat ambient[4], GLfloat diffuse[4], GLfloat specular[4], GLfloat emission[4], GLfloat shininess);
|
| 117 | +void glUtil_SetViewport(glUtil *This, GLint x, GLint y, GLsizei width, GLsizei height);
|
| 118 | +void glUtil_SetDepthRange(glUtil *This, GLclampd rangenear, GLclampd rangefar);
|
| 119 | +void glUtil_ClearColor(glUtil *This, GLclampf r, GLclampf g, GLclampf b, GLclampf a);
|
| 120 | +void glUtil_ClearDepth(glUtil *This, GLclampd depth);
|
| 121 | +void glUtil_ClearStencil(glUtil *This, GLint stencil);
|
| 122 | +void glUtil_EnableArray(glUtil *This, int index, BOOL enabled);
|
| 123 | +void glUtil_BlendFunc(glUtil *This, GLenum src, GLenum dest);
|
| 124 | +void glUtil_BlendEnable(glUtil *This, BOOL enabled);
|
| 125 | +void glUtil_EnableCull(glUtil *This, BOOL enabled);
|
| 126 | +void glUtil_SetCull(glUtil *This, D3DCULL mode);
|
| 127 | +void glUtil_SetPolyMode(glUtil *This, D3DFILLMODE mode);
|
| 128 | +void glUtil_SetShadeMode(glUtil *This, D3DSHADEMODE mode);
|
| 129 | +void glUtil_BindBuffer(glUtil *This, BufferObject *buffer, GLenum target);
|
| 130 | +void glUtil_UndoBindBuffer(glUtil *This, GLenum target);
|
| 131 | +
|
| 132 | +#ifdef __cplusplus
|
| 133 | +}
|
| 134 | +#endif
|
| 135 | +
|
125 | 136 | #endif //_GLUTIL_H
|