Index: ddraw/TextureManager.c |
— | — | @@ -366,3 +366,44 @@ |
367 | 367 | glBindTexture(GL_TEXTURE_2D,texname);
|
368 | 368 | }
|
369 | 369 | }
|
 | 370 | +
|
 | 371 | +BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty)
|
 | 372 | +{
|
 | 373 | + // data should be null to create uninitialized texture or be pointer to top-level
|
 | 374 | + // buffer to retain texture data
|
 | 375 | + TEXTURE newtexture;
|
 | 376 | + GLenum error;
|
 | 377 | + memcpy(&newtexture, texture, sizeof(TEXTURE));
|
 | 378 | + if (texture->miplevel > 0) return FALSE;
|
 | 379 | + if (texture->internalformats[1] == 0) return FALSE;
|
 | 380 | + glGenTextures(1, &newtexture.id);
|
 | 381 | + TextureManager_SetActiveTexture(This, 0);
|
 | 382 | + if (data)
|
 | 383 | + {
|
 | 384 | + TextureManager_SetTexture(This, 0, texture);
|
 | 385 | + glGetTexImage(GL_TEXTURE_2D, 0, texture->format, texture->type, data);
|
 | 386 | + if (dirty) *dirty |= 2;
|
 | 387 | + }
|
 | 388 | + TextureManager_SetTexture(This, 0, &newtexture);
|
 | 389 | + do
|
 | 390 | + {
|
 | 391 | + memmove(&newtexture.internalformats[0], &newtexture.internalformats[1], 7 * sizeof(GLint));
|
 | 392 | + newtexture.internalformats[7] = 0;
|
 | 393 | + ClearError();
|
 | 394 | + glTexImage2D(GL_TEXTURE_2D, 0, newtexture.internalformats[0], newtexture.width, newtexture.height,
|
 | 395 | + 0, newtexture.format, newtexture.type, NULL);
|
 | 396 | + error = glGetError();
|
 | 397 | + if (error != GL_NO_ERROR)
|
 | 398 | + {
|
 | 399 | + if (newtexture.internalformats[1] == 0)
|
 | 400 | + {
|
 | 401 | + FIXME("Failed to repair texture, cannot find internal format");
|
 | 402 | + break;
|
 | 403 | + }
|
 | 404 | + }
|
 | 405 | + else break;
|
 | 406 | + } while (1);
|
 | 407 | + TextureManager__DeleteTexture(This, texture);
|
 | 408 | + memcpy(texture, &newtexture, sizeof(TEXTURE));
|
 | 409 | + return TRUE;
|
 | 410 | +} |
\ No newline at end of file |
Index: ddraw/TextureManager.h |
— | — | @@ -74,6 +74,7 @@ |
75 | 75 | void TextureManager_DeleteTexture(TextureManager *This, TEXTURE *texture);
|
76 | 76 | void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
|
77 | 77 | void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data);
|
 | 78 | +BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty);
|
78 | 79 |
|
79 | 80 | #ifdef __cplusplus
|
80 | 81 | }
|
Index: ddraw/ddraw.rc |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | VALUE "FileDescription", "DXGL DDraw Library"
|
66 | 66 | VALUE "FileVersion", DXGLVERSTRING
|
67 | 67 | VALUE "InternalName", "DXGL"
|
68 | Â | - VALUE "LegalCopyright", "Copyright (C) 2011-2012 William Feely"
|
 | 68 | + VALUE "LegalCopyright", "Copyright (C) 2011-2014 William Feely"
|
69 | 69 | VALUE "OriginalFilename", "DDraw.dll"
|
70 | 70 | VALUE "ProductName", "DXGL"
|
71 | 71 | VALUE "ProductVersion", DXGLVERSTRING
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -982,7 +982,12 @@ |
983 | 983 | This->shaders->SetShader(shaderid, NULL, NULL, 1);
|
984 | 984 | GenShader2D *shader = &This->shaders->gen2d->genshaders2D[This->shaders->gen3d->current_genshader];
|
985 | 985 | This->util->BlendEnable(false);
|
986 | Â | - This->util->SetFBO(dest);
|
 | 986 | + do
|
 | 987 | + {
|
 | 988 | + if (This->util->SetFBO(dest) == GL_FRAMEBUFFER_COMPLETE) break;
|
 | 989 | + if (!dest->texture->internalformats[1]) break;
|
 | 990 | + TextureManager_FixTexture(This->texman, dest->texture, (dest->bigbuffer ? dest->bigbuffer : dest->buffer), &dest->dirty);
|
 | 991 | + } while (1);
|
987 | 992 | This->util->SetViewport(0,0,dest->fakex,dest->fakey);
|
988 | 993 | This->util->DepthTest(false);
|
989 | 994 | DDSURFACEDESC2 ddsdSrc;
|
— | — | @@ -1444,7 +1449,12 @@ |
1445 | 1450 | This->outputs[0] = (void*)D3D_OK;
|
1446 | 1451 | GLfloat color[4];
|
1447 | 1452 | dwordto4float(dwColor,color);
|
1448 | Â | - This->util->SetFBO(target);
|
 | 1453 | + do
|
 | 1454 | + {
|
 | 1455 | + if (This->util->SetFBO(target) == GL_FRAMEBUFFER_COMPLETE) break;
|
 | 1456 | + if (!target->texture->internalformats[1]) break;
|
 | 1457 | + TextureManager_FixTexture(This->texman, target->texture, (target->bigbuffer ? target->bigbuffer : target->buffer), &target->dirty);
|
 | 1458 | + } while (1);
|
1449 | 1459 | int clearbits = 0;
|
1450 | 1460 | if(dwFlags & D3DCLEAR_TARGET)
|
1451 | 1461 | {
|
— | — | @@ -1815,8 +1825,14 @@ |
1816 | 1826 | if(prog.uniforms[139]!= -1) This->ext->glUniform1f(prog.uniforms[139],device->viewport.dwX);
|
1817 | 1827 | if(prog.uniforms[140]!= -1) This->ext->glUniform1f(prog.uniforms[140],device->viewport.dwY);
|
1818 | 1828 | if(prog.uniforms[141]!= -1) This->ext->glUniform1i(prog.uniforms[141],device->renderstate[D3DRENDERSTATE_ALPHAREF]);
|
1819 | Â | - This->util->SetFBO(device->glDDS7);
|
1820 | Â | - This->util->SetViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
|
 | 1829 | + do
|
 | 1830 | + {
|
 | 1831 | + if (This->util->SetFBO(device->glDDS7) == GL_FRAMEBUFFER_COMPLETE) break;
|
 | 1832 | + if (!device->glDDS7->texture->internalformats[1]) break;
|
 | 1833 | + TextureManager_FixTexture(This->texman, device->glDDS7->texture,
|
 | 1834 | + (device->glDDS7->bigbuffer ? device->glDDS7->bigbuffer : device->glDDS7->buffer), &device->glDDS7->dirty);
|
 | 1835 | + } while (1);
|
 | 1836 | + This->util->SetViewport(device->viewport.dwX, device->viewport.dwY, device->viewport.dwWidth, device->viewport.dwHeight);
|
1821 | 1837 | This->util->SetDepthRange(device->viewport.dvMinZ,device->viewport.dvMaxZ);
|
1822 | 1838 | if(device->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) This->util->BlendEnable(true);
|
1823 | 1839 | else This->util->BlendEnable(false);
|
Index: ddraw/glUtil.cpp |
— | — | @@ -147,41 +147,60 @@ |
148 | 148 | }
|
149 | 149 | }
|
150 | 150 |
|
151 | Â | -void glUtil::SetFBO(glDirectDrawSurface7 *surface)
|
 | 151 | +GLenum glUtil::SetFBO(glDirectDrawSurface7 *surface)
|
152 | 152 | {
|
153 | Â | - if(!surface) SetFBO((FBO*)NULL);
|
154 | Â | - if(surface->zbuffer) SetFBO(&surface->fbo,surface->texture,surface->zbuffer->texture,surface->zbuffer->hasstencil);
|
155 | Â | - else SetFBO(&surface->fbo,surface->texture,NULL,false);
|
 | 153 | + if(!surface) return SetFBO((FBO*)NULL);
|
 | 154 | + if(surface->zbuffer) return SetFBO(&surface->fbo,surface->texture,surface->zbuffer->texture,surface->zbuffer->hasstencil);
|
 | 155 | + else return SetFBO(&surface->fbo,surface->texture,NULL,false);
|
156 | 156 | }
|
157 | 157 |
|
158 | Â | -void glUtil::SetFBO(FBO *fbo)
|
 | 158 | +GLenum glUtil::SetFBO(FBO *fbo)
|
159 | 159 | {
|
160 | Â | - if(fbo == currentfbo) return;
|
 | 160 | + if (fbo == currentfbo)
|
 | 161 | + {
|
 | 162 | + if (fbo) return fbo->status;
|
 | 163 | + else return GL_FRAMEBUFFER_COMPLETE;
|
 | 164 | + }
|
161 | 165 | if(!fbo)
|
162 | 166 | {
|
163 | Â | - if(ext->GLEXT_ARB_framebuffer_object) ext->glBindFramebuffer(GL_FRAMEBUFFER,0);
|
 | 167 | + if (ext->GLEXT_ARB_framebuffer_object) ext->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
164 | 168 | else if(ext->GLEXT_EXT_framebuffer_object) ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
|
165 | 169 | }
|
166 | 170 | else
|
167 | 171 | {
|
168 | Â | - if(ext->GLEXT_ARB_framebuffer_object) ext->glBindFramebuffer(GL_FRAMEBUFFER,fbo->fbo);
|
169 | Â | - else if(ext->GLEXT_EXT_framebuffer_object) ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo->fbo);
|
 | 172 | + if (ext->GLEXT_ARB_framebuffer_object)
|
 | 173 | + {
|
 | 174 | + ext->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fbo);
|
 | 175 | + fbo->status = ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
 | 176 | + }
|
 | 177 | + else if (ext->GLEXT_EXT_framebuffer_object)
|
 | 178 | + {
|
 | 179 | + ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->fbo);
|
 | 180 | + fbo->status = ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
 | 181 | + }
|
170 | 182 | }
|
171 | 183 | currentfbo = fbo;
|
 | 184 | + if (fbo) return fbo->status;
|
 | 185 | + else
|
 | 186 | + {
|
 | 187 | + if (ext->GLEXT_ARB_framebuffer_object) return ext->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
 | 188 | + else if (ext->GLEXT_EXT_framebuffer_object) return ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
 | 189 | + else return 0;
|
 | 190 | + }
|
172 | 191 | }
|
173 | 192 |
|
174 | Â | -void glUtil::SetFBO(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil)
|
 | 193 | +GLenum glUtil::SetFBO(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil)
|
175 | 194 | {
|
176 | 195 | if(!fbo)
|
177 | 196 | {
|
178 | Â | - SetFBO((FBO*)NULL);
|
179 | Â | - return;
|
 | 197 | + return SetFBO((FBO*)NULL);
|
180 | 198 | }
|
181 | 199 | if(!fbo->fbo) InitFBO(fbo);
|
182 | Â | - if(!color) return;
|
 | 200 | + if (!color) return GL_INVALID_ENUM;
|
183 | 201 | if((color != fbo->fbcolor) || (z != fbo->fbz) || (stencil != fbo->stencil))
|
184 | 202 | SetFBOTexture(fbo,color,z,stencil);
|
185 | Â | - if(fbo != currentfbo) SetFBO(fbo);
|
 | 203 | + if(fbo != currentfbo) return SetFBO(fbo);
|
 | 204 | + else return fbo->status;
|
186 | 205 | }
|
187 | 206 |
|
188 | 207 | void glUtil::SetWrap(int level, DWORD coord, DWORD address, TextureManager *texman)
|
Index: ddraw/glUtil.h |
— | — | @@ -52,9 +52,9 @@ |
53 | 53 | void DeleteFBO(FBO *fbo);
|
54 | 54 | void SetFBOTexture(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil);
|
55 | 55 | void SetWrap(int level, DWORD coord, DWORD address, TextureManager *texman);
|
56 | Â | - void SetFBO(glDirectDrawSurface7 *surface);
|
57 | Â | - void SetFBO(FBO *fbo);
|
58 | Â | - void SetFBO(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil);
|
 | 56 | + GLenum SetFBO(glDirectDrawSurface7 *surface);
|
 | 57 | + GLenum SetFBO(FBO *fbo);
|
 | 58 | + GLenum SetFBO(FBO *fbo, TEXTURE *color, TEXTURE *z, bool stencil);
|
59 | 59 | void SetDepthComp(GLenum comp);
|
60 | 60 | void DepthWrite(bool enabled);
|
61 | 61 | void DepthTest(bool enabled);
|
Index: dxglcfg/dxglcfg.rc |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | VALUE "FileDescription", "DXGL Configuration Program"
|
115 | 115 | VALUE "FileVersion", DXGLVERSTRING
|
116 | 116 | VALUE "InternalName", "DXGL"
|
117 | Â | - VALUE "LegalCopyright", "Copyright © 2011-2012 William Feely"
|
 | 117 | + VALUE "LegalCopyright", "Copyright © 2011-2014 William Feely"
|
118 | 118 | VALUE "OriginalFilename", "dxglcfg.exe"
|
119 | 119 | VALUE "ProductName", "DXGL"
|
120 | 120 | VALUE "ProductVersion", DXGLVERSTRING
|
Index: dxgltest/dxgltest.rc |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |