DXGL r251 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r250‎ | r251 | r252 >
Date:22:30, 1 September 2012
Author:admin
Status:new
Tags:
Comment:
Use texture manager list for EnumTextureFormats
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/texture.cpp (modified) (history)
  • /ddraw/texture.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -653,29 +653,15 @@
654654 ERR(DDERR_GENERIC);
655655 }
656656
657 -// Use EXACTLY one line per entry. Don't change layout of the list.
658 -const int TEXFMT_START = __LINE__;
659 -const DDPIXELFORMAT texpixelformats[] =
660 -{
661 - {sizeof(DDPIXELFORMAT),DDPF_RGB|DDPF_ALPHAPIXELS,0,16,0xF00,0xF0,0xF,0xF000},
662 - {sizeof(DDPIXELFORMAT),DDPF_RGB|DDPF_ALPHAPIXELS,0,16,0x7C00,0x3E0,0x1F,0x8000},
663 - {sizeof(DDPIXELFORMAT),DDPF_RGB,0,16,0x7C00,0x3E0,0x1F,0},
664 - {sizeof(DDPIXELFORMAT),DDPF_RGB,0,16,0xF800,0x7E0,0x1F,0},
665 - {sizeof(DDPIXELFORMAT),DDPF_RGB|DDPF_ALPHAPIXELS,0,32,0xFF0000,0xFF00,0xFF,0xFF000000},
666 - {sizeof(DDPIXELFORMAT),DDPF_RGB,0,32,0xFF0000,0xFF00,0xFF,0},
667 - {sizeof(DDPIXELFORMAT),DDPF_RGB,0,24,0xFF0000,0xFF00,0xFF,0}
668 -};
669 -const int TEXFMT_END = __LINE__ - 4;
670 -const int numtexfmt = TEXFMT_END-TEXFMT_START;
671 -
672657 HRESULT WINAPI glDirect3DDevice7::EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg)
673658 {
674659 if(!this) return DDERR_INVALIDOBJECT;
675660 HRESULT result;
676661 DDPIXELFORMAT fmt;
677 - for(int i = 0; i < numtexfmt; i++)
 662+ for(int i = 0; i < numtexformats; i++)
678663 {
679 - memcpy(&fmt,&texpixelformats[i],sizeof(DDPIXELFORMAT));
 664+ if(::texformats[i].dwFlags & DDPF_ZBUFFER) continue;
 665+ memcpy(&fmt,&::texformats[i],sizeof(DDPIXELFORMAT));
680666 result = lpd3dEnumPixelProc(&fmt,lpArg);
681667 if(result != D3DENUMRET_OK) return D3D_OK;
682668 }
Index: ddraw/texture.cpp
@@ -19,6 +19,7 @@
2020 #include "texture.h"
2121 #include "glRenderer.h"
2222
 23+// Use EXACTLY one line per entry. Don't change layout of the list.
2324 const int START_TEXFORMATS = __LINE__;
2425 const DDPIXELFORMAT texformats[] =
2526 { // Size Flags FOURCC bits R/Ymask G/U/Zmask B/V/STmask A/Zmask
Index: ddraw/texture.h
@@ -45,6 +45,7 @@
4646 extern void (*_DeleteTexture)(TEXTURE *texture);
4747 extern void (*_UploadTexture)(TEXTURE *texture, int level, const void *data, int width, int height);
4848 extern void (*_DownloadTexture)(TEXTURE *texture, int level, void *data);
 49+extern const DDPIXELFORMAT texformats[];
 50+extern const int numtexformats;
4951
50 -
5152 #endif //_TEXTURE_H
\ No newline at end of file