DXGL r383 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r382‎ | r383 | r384 >
Date:21:50, 9 June 2013
Author:admin
Status:new
Tags:
Comment:
Use EXT_direct_state_access for uploading and downloading textures.
Modified paths:
  • /ddraw/glExtensions.cpp (modified) (history)
  • /ddraw/glExtensions.h (modified) (history)
  • /ddraw/texture.cpp (modified) (history)

Diff [purge]

Index: ddraw/glExtensions.cpp
@@ -92,6 +92,7 @@
9393 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) = NULL;
9494 void (APIENTRY *glTextureSubImage2DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
9595 GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) = NULL;
 96+void (APIENTRY *glGetTextureImageEXT)(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels) = NULL;
9697 void (APIENTRY *glMatrixLoadfEXT)(GLenum mode, const GLfloat *m) = NULL;
9798 void (APIENTRY *glMatrixMultfEXT)(GLenum mode, const GLfloat *m) = NULL;
9899
@@ -239,6 +240,7 @@
240241 glTextureParameterivEXT = (PFNGLTEXTUREPARAMETERIVEXTPROC)wglGetProcAddress("glTextureParameterivEXT");
241242 glTextureImage2DEXT = (PFNGLTEXTUREIMAGE2DEXTPROC)wglGetProcAddress("glTextureImage2DEXT");
242243 glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)wglGetProcAddress("glTextureSubImage2DEXT");
 244+ glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)wglGetProcAddress("glGetTextureImageEXT");
243245 glMatrixLoadfEXT = (PFNGLMATRIXLOADFEXTPROC)wglGetProcAddress("glMatrixLoadfEXT");
244246 glMatrixMultfEXT = (PFNGLMATRIXMULTFEXTPROC)wglGetProcAddress("glMatrixMultfEXT");
245247 }
Index: ddraw/glExtensions.h
@@ -122,6 +122,7 @@
123123 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
124124 GLAPI void (APIENTRY *glTextureSubImage2DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
125125 GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
 126+GLAPI void (APIENTRY *glGetTextureImageEXT)(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
126127 GLAPI void (APIENTRY *glMatrixLoadfEXT)(GLenum mode, const GLfloat *m);
127128 GLAPI void (APIENTRY *glMatrixMultfEXT)(GLenum mode, const GLfloat *m);
128129
Index: ddraw/texture.cpp
@@ -196,18 +196,27 @@
197197
198198 void UploadTextureClassic(TEXTURE *texture, int level, const void *data, int width, int height)
199199 {
200 - SetActiveTexture(0);
201 - SetTexture(0,texture);
202200 texture->width = width;
203201 texture->height = height;
204 - glTexImage2D(GL_TEXTURE_2D,level,texture->internalformat,width,height,0,texture->format,texture->type,data);
 202+ if(GLEXT_EXT_direct_state_access) glTextureImage2DEXT(texture->id,GL_TEXTURE_2D,level,texture->internalformat,
 203+ width,height,0,texture->format,texture->type,data);
 204+ else
 205+ {
 206+ SetActiveTexture(0);
 207+ SetTexture(0,texture);
 208+ glTexImage2D(GL_TEXTURE_2D,level,texture->internalformat,width,height,0,texture->format,texture->type,data);
 209+ }
205210 }
206211
207212 void DownloadTextureClassic(TEXTURE *texture, int level, void *data)
208213 {
209 - SetActiveTexture(0);
210 - SetTexture(0,texture);
211 - glGetTexImage(GL_TEXTURE_2D,level,texture->format,texture->type,data);
 214+ if(GLEXT_EXT_direct_state_access) glGetTextureImageEXT(texture->id,GL_TEXTURE_2D,level,texture->format,texture->type,data);
 215+ else
 216+ {
 217+ SetActiveTexture(0);
 218+ SetTexture(0,texture);
 219+ glGetTexImage(GL_TEXTURE_2D,level,texture->format,texture->type,data);
 220+ }
212221 }
213222
214223 void (*_CreateTexture)(TEXTURE *texture, int width, int height) = CreateTextureClassic;