| 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 |