DXGL r500 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r499‎ | r500 | r501 >
Date:23:17, 28 August 2014
Author:admin
Status:new
Tags:
Comment:
Fix regression in surface creation.
Make FixTexture work on mipmap textures.
Modified paths:
  • /ddraw/TextureManager.c (modified) (history)
  • /ddraw/TextureManager.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/TextureManager.c
@@ -144,6 +144,7 @@
145145 int i;
146146 int x, y;
147147 GLenum error;
 148+ if (!texture->miplevel) texture->miplevel = 1;
148149 texture->pixelformat.dwSize = sizeof(DDPIXELFORMAT);
149150 for(i = 0; i < numtexformats; i++)
150151 {
@@ -572,7 +573,7 @@
573574 }
574575 }
575576
576 -BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty)
 577+BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty, GLint level)
577578 {
578579 // data should be null to create uninitialized texture or be pointer to top-level
579580 // buffer to retain texture data
@@ -579,7 +580,6 @@
580581 TEXTURE newtexture;
581582 GLenum error;
582583 memcpy(&newtexture, texture, sizeof(TEXTURE));
583 - if (texture->miplevel > 0) return FALSE;
584584 if (texture->internalformats[1] == 0) return FALSE;
585585 glGenTextures(1, &newtexture.id);
586586 TextureManager_SetActiveTexture(This, 0);
@@ -586,7 +586,7 @@
587587 if (data)
588588 {
589589 TextureManager_SetTexture(This, 0, texture);
590 - glGetTexImage(GL_TEXTURE_2D, 0, texture->format, texture->type, data);
 590+ glGetTexImage(GL_TEXTURE_2D, level, texture->format, texture->type, data);
591591 if (dirty) *dirty |= 2;
592592 }
593593 TextureManager_SetTexture(This, 0, &newtexture);
@@ -595,7 +595,7 @@
596596 memmove(&newtexture.internalformats[0], &newtexture.internalformats[1], 7 * sizeof(GLint));
597597 newtexture.internalformats[7] = 0;
598598 ClearError();
599 - glTexImage2D(GL_TEXTURE_2D, 0, newtexture.internalformats[0], newtexture.width, newtexture.height,
 599+ glTexImage2D(GL_TEXTURE_2D, level, newtexture.internalformats[0], newtexture.width, newtexture.height,
600600 0, newtexture.format, newtexture.type, data);
601601 error = glGetError();
602602 if (error != GL_NO_ERROR)
Index: ddraw/TextureManager.h
@@ -89,7 +89,7 @@
9090 void TextureManager_DeleteTexture(TextureManager *This, TEXTURE *texture);
9191 void TextureManager_UploadTextureClassic(TextureManager *This, TEXTURE *texture, int level, const void *data, int width, int height, BOOL checkerror);
9292 void TextureManager_DownloadTextureClassic(TextureManager *This, TEXTURE *texture, int level, void *data);
93 -BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty);
 93+BOOL TextureManager_FixTexture(TextureManager *This, TEXTURE *texture, void *data, DWORD *dirty, GLint level);
9494
9595 #ifdef __cplusplus
9696 }
Index: ddraw/glRenderer.cpp
@@ -1198,7 +1198,7 @@
11991199 {
12001200 if (This->util->SetFBO(dest) == GL_FRAMEBUFFER_COMPLETE) break;
12011201 if (!dest->texture->internalformats[1]) break;
1202 - TextureManager_FixTexture(This->texman, dest->texture, (dest->bigbuffer ? dest->bigbuffer : dest->buffer), &dest->dirty);
 1202+ TextureManager_FixTexture(This->texman, dest->texture, (dest->bigbuffer ? dest->bigbuffer : dest->buffer), &dest->dirty, dest->miplevel);
12031203 This->util->SetFBO((FBO*)NULL);
12041204 dest->fbo.fbcolor = NULL;
12051205 dest->fbo.fbz = NULL;
@@ -1623,7 +1623,7 @@
16241624 {
16251625 if (This->util->SetFBO(target) == GL_FRAMEBUFFER_COMPLETE) break;
16261626 if (!target->texture->internalformats[1]) break;
1627 - TextureManager_FixTexture(This->texman, target->texture, (target->bigbuffer ? target->bigbuffer : target->buffer), &target->dirty);
 1627+ TextureManager_FixTexture(This->texman, target->texture, (target->bigbuffer ? target->bigbuffer : target->buffer), &target->dirty, target->miplevel);
16281628 This->util->SetFBO((FBO*)NULL);
16291629 target->fbo.fbcolor = NULL;
16301630 target->fbo.fbz = NULL;
@@ -2003,7 +2003,7 @@
20042004 if (This->util->SetFBO(device->glDDS7) == GL_FRAMEBUFFER_COMPLETE) break;
20052005 if (!device->glDDS7->texture->internalformats[1]) break;
20062006 TextureManager_FixTexture(This->texman, device->glDDS7->texture,
2007 - (device->glDDS7->bigbuffer ? device->glDDS7->bigbuffer : device->glDDS7->buffer), &device->glDDS7->dirty);
 2007+ (device->glDDS7->bigbuffer ? device->glDDS7->bigbuffer : device->glDDS7->buffer), &device->glDDS7->dirty, device->glDDS7->miplevel);
20082008 This->util->SetFBO((FBO*)NULL);
20092009 device->glDDS7->fbo.fbcolor = NULL;
20102010 device->glDDS7->fbo.fbz = NULL;