DXGL r245 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r244‎ | r245 | r246 >
Date:17:53, 26 August 2012
Author:admin
Status:new
Tags:
Comment:
Add missing texture source
Fix surfaces created with pixelformat
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/texture.cpp (added) (history)
  • /ddraw/texture.h (added) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -258,6 +258,7 @@
259259 return;
260260 }
261261 }
 262+ else ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*(ddsd.ddpfPixelFormat.dwRGBBitCount / 8));
262263 texture->pixelformat = ddsd.ddpfPixelFormat;
263264 if((ddsd.dwFlags & DDSD_CAPS) && (ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
264265 texture->minfilter = texture->magfilter = GL_NEAREST;
Index: ddraw/texture.cpp
@@ -0,0 +1,448 @@
 2+// DXGL
 3+// Copyright (C) 2012 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#include "common.h"
 20+#include "texture.h"
 21+#include "glRenderer.h"
 22+
 23+const int START_TEXFORMATS = __LINE__;
 24+const DDPIXELFORMAT texformats[] =
 25+{ // Size Flags FOURCC bits R/Ymask G/U/Zmask B/V/STmask A/Zmask
 26+ {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0},
 27+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 8, 0xE0, 0x1C, 0x3, 0},
 28+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x3E0, 0x1F, 0},
 29+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x7E0, 0x1F, 0},
 30+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 24, 0xFF0000, 0xFF00, 0xFF, 0},
 31+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF0000, 0xFF00, 0xFF, 0},
 32+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF, 0xFF00, 0xFF0000, 0},
 33+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0xE0, 0x1C, 0x3, 0xFF00},
 34+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0xF00, 0xF0, 0xF, 0xF000},
 35+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0x7c00, 0x3E0, 0x1F, 0x8000},
 36+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000},
 37+ {sizeof(DDPIXELFORMAT), DDPF_LUMINANCE, 0, 8, 0xFF, 0, 0, 0},
 38+ {sizeof(DDPIXELFORMAT), DDPF_ALPHA, 0, 8, 0, 0, 0, 0},
 39+ {sizeof(DDPIXELFORMAT), DDPF_LUMINANCE|DDPF_ALPHAPIXELS,0, 16, 0xFF, 0, 0, 0xFF00},
 40+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 16, 0, 0xFFFF, 0, 0},
 41+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 24, 0, 0xFFFFFF00, 0, 0},
 42+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0},
 43+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFFFF, 0, 0},
 44+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFFFFFF00, 0xFF, 0},
 45+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0}
 46+};
 47+const int END_TEXFORMATS = __LINE__ - 4;
 48+const int numtexformats = END_TEXFORMATS - START_TEXFORMATS;
 49+
 50+GLint texlevel = 0;
 51+GLuint textures[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 52+
 53+void CreateTextureClassic(TEXTURE *texture, int width, int height)
 54+{
 55+ int texformat = -1;
 56+ texture->pixelformat.dwSize = sizeof(DDPIXELFORMAT);
 57+ for(int i = 0; i < numtexformats; i++)
 58+ {
 59+ if(!memcmp(&texformats[i],&texture->pixelformat,sizeof(DDPIXELFORMAT)))
 60+ {
 61+ texformat = i;
 62+ break;
 63+ }
 64+ }
 65+ switch(texformat)
 66+ {
 67+ case -1:
 68+ case 0: // 8-bit palette
 69+ if(glver_major >= 3)
 70+ {
 71+ texture->internalformat = GL_LUMINANCE8;
 72+ texture->format = GL_LUMINANCE;
 73+ }
 74+ else
 75+ {
 76+ texture->internalformat = GL_RGBA8;
 77+ texture->format = GL_LUMINANCE;
 78+ }
 79+ texture->type = GL_UNSIGNED_BYTE;
 80+ break;
 81+ case 1: // 8-bit RGB332
 82+ texture->internalformat = GL_R3_G3_B2;
 83+ texture->format = GL_RGB;
 84+ texture->type = GL_UNSIGNED_BYTE_3_3_2;
 85+ FIXME("Untested texture format RGB332\n");
 86+ break;
 87+ case 2: // 16-bit RGB555
 88+ texture->internalformat = GL_RGB5;
 89+ texture->format = GL_BGRA;
 90+ texture->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 91+ break;
 92+ case 3: // 16-bit RGB565
 93+ /*if(GLEXT_ARB_ES2_compatibility) texture->internalformat = GL_RGB565;
 94+ else */texture->internalformat = GL_RGBA8;
 95+ texture->format = GL_RGB;
 96+ texture->type = GL_UNSIGNED_SHORT_5_6_5;
 97+ break;
 98+ case 4: // 24-bit RGB888
 99+ texture->internalformat = GL_RGB8;
 100+ texture->format = GL_BGR;
 101+ texture->type = GL_UNSIGNED_BYTE;
 102+ break;
 103+ case 5: // 32-bit RGB888
 104+ texture->internalformat = GL_RGBA8;
 105+ texture->format = GL_BGRA;
 106+ texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
 107+ break;
 108+ case 6: // 32-bit BGR888
 109+ texture->internalformat = GL_RGBA8;
 110+ texture->format = GL_RGBA;
 111+ texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
 112+ break;
 113+ case 7: // 16-bit RGBA3328
 114+ FIXME("Unusual texture format RGBA3328 not supported");
 115+ break;
 116+ case 8: // 16-bit RGBA4444
 117+ texture->internalformat = GL_RGBA4;
 118+ texture->format = GL_BGRA;
 119+ texture->type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
 120+ break;
 121+ case 9: // 16-bit RGBA5551
 122+ texture->internalformat = GL_RGB5_A1;
 123+ texture->format = GL_BGRA;
 124+ texture->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 125+ break;
 126+ case 10: // 32-bit RGBA8888
 127+ texture->internalformat = GL_RGBA8;
 128+ texture->format = GL_BGRA;
 129+ texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
 130+ break;
 131+ case 11: // 8-bit Luminance
 132+ texture->internalformat = GL_LUMINANCE8;
 133+ texture->format = GL_LUMINANCE;
 134+ texture->type = GL_UNSIGNED_BYTE;
 135+ break;
 136+ case 12: // 8-bit Alpha
 137+ texture->internalformat = GL_ALPHA8;
 138+ texture->format = GL_ALPHA;
 139+ texture->type = GL_UNSIGNED_BYTE;
 140+ break;
 141+ case 13: // 16-bit Luminance Alpha
 142+ texture->internalformat = GL_LUMINANCE8_ALPHA8;
 143+ texture->format = GL_LUMINANCE_ALPHA;
 144+ texture->type = GL_UNSIGNED_BYTE;
 145+ break;
 146+ case 14: // 16-bit Z buffer
 147+ texture->internalformat = GL_DEPTH_COMPONENT16;
 148+ texture->format = GL_DEPTH_COMPONENT;
 149+ texture->type = GL_UNSIGNED_SHORT;
 150+ break;
 151+ case 15: // 24-bit Z buffer
 152+ texture->internalformat = GL_DEPTH_COMPONENT24;
 153+ texture->format = GL_DEPTH_COMPONENT;
 154+ texture->type = GL_UNSIGNED_INT;
 155+ break;
 156+ case 16: // 32/24 bit Z buffer
 157+ texture->internalformat = GL_DEPTH_COMPONENT24;
 158+ texture->format = GL_DEPTH_COMPONENT;
 159+ texture->type = GL_UNSIGNED_INT;
 160+ break;
 161+ case 17: // 32-bit Z buffer
 162+ texture->internalformat = GL_DEPTH_COMPONENT32;
 163+ texture->format = GL_DEPTH_COMPONENT;
 164+ texture->type = GL_UNSIGNED_INT;
 165+ break;
 166+ case 18: // 32-bit Z/Stencil buffer, depth LSB
 167+ texture->internalformat = GL_DEPTH24_STENCIL8;
 168+ texture->format = GL_DEPTH_STENCIL;
 169+ texture->type = GL_UNSIGNED_INT_24_8;
 170+ break;
 171+ case 19: // 32-bit Z/Stencil buffer, depth MSB
 172+ texture->internalformat = GL_DEPTH24_STENCIL8;
 173+ texture->format = GL_DEPTH_STENCIL;
 174+ texture->type = GL_UNSIGNED_INT_24_8;
 175+ break;
 176+ }
 177+ texture->width = width;
 178+ texture->height = height;
 179+ glGenTextures(1,&texture->id);
 180+ SetTexture(0,texture);
 181+ glTexImage2D(GL_TEXTURE_2D,0,texture->internalformat,texture->width,texture->height,0,texture->format,texture->type,NULL);
 182+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,texture->minfilter);
 183+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,texture->magfilter);
 184+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,texture->wraps);
 185+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,texture->wrapt);
 186+}
 187+
 188+void DeleteTexture(TEXTURE *texture)
 189+{
 190+ glDeleteTextures(1,&texture->id);
 191+ texture->bordercolor = texture->format = texture->internalformat =
 192+ texture->type = texture->width = texture->height = texture->magfilter =
 193+ texture->minfilter = texture->miplevel = texture->wraps = texture->wrapt =
 194+ texture->pbo = texture->id = 0;
 195+}
 196+
 197+void UploadTextureClassic(TEXTURE *texture, int level, const void *data, int width, int height)
 198+{
 199+ SetActiveTexture(0);
 200+ SetTexture(0,texture);
 201+ if((width != texture->width) || (height != texture->height))
 202+ {
 203+ texture->width = width;
 204+ texture->height = height;
 205+ glTexImage2D(GL_TEXTURE_2D,level,texture->internalformat,width,height,0,texture->format,texture->type,data);
 206+ }
 207+ else glTexSubImage2D(GL_TEXTURE_2D,level,0,0,width,height,texture->format,texture->type,data);
 208+}
 209+
 210+void DownloadTextureClassic(TEXTURE *texture, int level, void *data)
 211+{
 212+ SetActiveTexture(0);
 213+ SetTexture(0,texture);
 214+ glGetTexImage(GL_TEXTURE_2D,level,texture->format,texture->type,data);
 215+}
 216+
 217+void (*_CreateTexture)(TEXTURE *texture, int width, int height) = CreateTextureClassic;
 218+void (*_DeleteTexture)(TEXTURE *texture) = DeleteTexture;
 219+void (*_UploadTexture)(TEXTURE *texture, int level, const void *data, int width, int height) = UploadTextureClassic;
 220+void (*_DownloadTexture)(TEXTURE *texture, int level, void *data) = DownloadTextureClassic;
 221+
 222+void InitTexture(DXGLCFG *cfg)
 223+{
 224+ ZeroMemory(textures,16*sizeof(GLuint));
 225+ _CreateTexture = CreateTextureClassic;
 226+ _DeleteTexture = DeleteTexture;
 227+ _UploadTexture = UploadTextureClassic;
 228+ _DownloadTexture = DownloadTextureClassic;
 229+}
 230+
 231+void SetActiveTexture(int level)
 232+{
 233+ if(level != texlevel)
 234+ {
 235+ texlevel = level;
 236+ glActiveTexture(GL_TEXTURE0+level);
 237+ }
 238+}
 239+
 240+
 241+void SetTexture(unsigned int level, TEXTURE *texture)
 242+{
 243+ if(level >= 16) return;
 244+ GLuint texname;
 245+ if(!texture) texname = 0;
 246+ else texname=texture->id;
 247+ if(texname != textures[level])
 248+ {
 249+ SetActiveTexture(level);
 250+ glBindTexture(GL_TEXTURE_2D,texname);
 251+ }
 252+}
 253+
 254+
 255+
 256+/*
 257+ if(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)
 258+ {
 259+ switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
 260+ {
 261+ case 8:
 262+ if(ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
 263+ {
 264+ texformat = GL_LUMINANCE;
 265+ texformat2 = GL_UNSIGNED_BYTE;
 266+ if(dxglcfg.texformat) texformat3 = GL_LUMINANCE8;
 267+ else texformat3 = GL_RGBA8;
 268+ if(!palettein) palette = new glDirectDrawPalette(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,NULL);
 269+ bitmapinfo->bmiHeader.biBitCount = 8;
 270+ }
 271+ else
 272+ {
 273+ texformat = GL_RGB;
 274+ texformat2 = GL_UNSIGNED_BYTE_3_3_2;
 275+ if(dxglcfg.texformat) texformat3 = GL_R3_G3_B2;
 276+ else texformat3 = GL_RGBA8;
 277+ }
 278+ ddsd.ddpfPixelFormat.dwRBitMask = 0;
 279+ ddsd.ddpfPixelFormat.dwGBitMask = 0;
 280+ ddsd.ddpfPixelFormat.dwBBitMask = 0;
 281+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
 282+ break;
 283+ case 16:
 284+ if((ddsd.ddpfPixelFormat.dwRBitMask == 0x7C00) && (ddsd.ddpfPixelFormat.dwGBitMask == 0x3E0)
 285+ && (ddsd.ddpfPixelFormat.dwBBitMask == 0x1F))
 286+ {
 287+ texformat = GL_BGRA;
 288+ texformat2 = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 289+ if(dxglcfg.texformat) texformat3 = GL_RGB5_A1;
 290+ else texformat3 = GL_RGBA8;
 291+ }
 292+ else // fixme: support more formats
 293+ {
 294+ texformat = GL_RGB;
 295+ texformat2 = GL_UNSIGNED_SHORT_5_6_5;
 296+ if(dxglcfg.texformat) texformat3 = GL_RGB;
 297+ else texformat3 = GL_RGBA8;
 298+ }
 299+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
 300+ break;
 301+ case 24:
 302+ if((ddsd.ddpfPixelFormat.dwRBitMask == 0xFF0000) && (ddsd.ddpfPixelFormat.dwGBitMask == 0xFF00)
 303+ && (ddsd.ddpfPixelFormat.dwBBitMask == 0xFF))
 304+ {
 305+ texformat = GL_BGR;
 306+ texformat2 = GL_UNSIGNED_BYTE;
 307+ if(dxglcfg.texformat) texformat3 = GL_RGB8;
 308+ else texformat3 = GL_RGBA8;
 309+ }
 310+ else // fixme: support more formats
 311+ {
 312+ texformat = GL_RGB;
 313+ texformat2 = GL_UNSIGNED_BYTE;
 314+ if(dxglcfg.texformat) texformat3 = GL_RGB8;
 315+ else texformat3 = GL_RGBA8;
 316+ }
 317+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*3);
 318+ break;
 319+ case 32:
 320+ default:
 321+ if((ddsd.ddpfPixelFormat.dwRBitMask == 0xFF0000) && (ddsd.ddpfPixelFormat.dwGBitMask == 0xFF00)
 322+ && (ddsd.ddpfPixelFormat.dwBBitMask == 0xFF))
 323+ {
 324+ texformat = GL_BGRA;
 325+ texformat2 = GL_UNSIGNED_INT_8_8_8_8_REV;
 326+ texformat3 = GL_RGBA8;
 327+ }
 328+ else // fixme: support more formats
 329+ {
 330+ texformat = GL_RGBA;
 331+ texformat2 = GL_UNSIGNED_BYTE;
 332+ texformat3 = GL_RGBA8;
 333+ }
 334+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*4);
 335+ }
 336+ }
 337+ else if(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)
 338+ {
 339+ switch(ddsd.ddpfPixelFormat.dwZBufferBitDepth)
 340+ {
 341+ case 16:
 342+ default:
 343+ texformat = GL_DEPTH_COMPONENT;
 344+ texformat2 = GL_UNSIGNED_BYTE;
 345+ texformat3 = GL_DEPTH_COMPONENT16;
 346+ break;
 347+ case 24:
 348+ texformat = GL_DEPTH_COMPONENT;
 349+ texformat2 = GL_UNSIGNED_BYTE;
 350+ texformat3 = GL_DEPTH_COMPONENT24;
 351+ break;
 352+ case 32:
 353+ if((ddsd.ddpfPixelFormat.dwRGBZBitMask == 0x00ffffff) &&
 354+ !(ddsd.ddpfPixelFormat.dwFlags & DDPF_STENCILBUFFER))
 355+ {
 356+ texformat = GL_DEPTH_COMPONENT;
 357+ texformat2 = GL_UNSIGNED_INT;
 358+ texformat3 = GL_DEPTH_COMPONENT24;
 359+ break;
 360+ }
 361+ else if(ddsd.ddpfPixelFormat.dwFlags & DDPF_STENCILBUFFER)
 362+ {
 363+ texformat = GL_DEPTH_STENCIL;
 364+ texformat2 = GL_UNSIGNED_INT_24_8;
 365+ texformat3 = GL_DEPTH24_STENCIL8;
 366+ hasstencil = true;
 367+ break;
 368+ }
 369+ else
 370+ {
 371+ texformat = GL_DEPTH_COMPONENT;
 372+ texformat2 = GL_UNSIGNED_INT;
 373+ texformat3 = GL_DEPTH_COMPONENT32;
 374+ break;
 375+ }
 376+ }
 377+ }
 378+ }
 379+
 380+*/
 381+
 382+/*
 383+ if(!(ddsd.dwFlags & DDSD_PIXELFORMAT))
 384+ {
 385+ ddsd.ddpfPixelFormat.dwRGBBitCount = ddInterface->GetBPP();
 386+ switch(ddInterface->GetBPP())
 387+ {
 388+ case 8:
 389+ texformat = GL_LUMINANCE;
 390+ texformat2 = GL_UNSIGNED_BYTE;
 391+ if(dxglcfg.texformat) texformat3 = GL_LUMINANCE8;
 392+ else texformat3 = GL_RGBA8;
 393+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
 394+ ddsd.ddpfPixelFormat.dwRBitMask = 0;
 395+ ddsd.ddpfPixelFormat.dwGBitMask = 0;
 396+ ddsd.ddpfPixelFormat.dwBBitMask = 0;
 397+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
 398+ break;
 399+ case 15:
 400+ texformat = GL_BGRA;
 401+ texformat2 = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 402+ if(dxglcfg.texformat) texformat3 = GL_RGB5_A1;
 403+ else texformat3 = GL_RGBA8;
 404+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
 405+ ddsd.ddpfPixelFormat.dwRBitMask = 0x7C00;
 406+ ddsd.ddpfPixelFormat.dwGBitMask = 0x3E0;
 407+ ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
 408+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
 409+ ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
 410+ break;
 411+ case 16:
 412+ texformat = GL_RGB;
 413+ texformat2 = GL_UNSIGNED_SHORT_5_6_5;
 414+ if(dxglcfg.texformat) texformat3 = GL_RGB;
 415+ else texformat3 = GL_RGBA8;
 416+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
 417+ ddsd.ddpfPixelFormat.dwRBitMask = 0xF800;
 418+ ddsd.ddpfPixelFormat.dwGBitMask = 0x7E0;
 419+ ddsd.ddpfPixelFormat.dwBBitMask = 0x1F;
 420+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
 421+ break;
 422+ case 24:
 423+ texformat = GL_BGR;
 424+ texformat2 = GL_UNSIGNED_BYTE;
 425+ if(dxglcfg.texformat) texformat3 = GL_RGB8;
 426+ else texformat3 = GL_RGBA8;
 427+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
 428+ ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
 429+ ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
 430+ ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
 431+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*3);
 432+ break;
 433+ case 32:
 434+ texformat = GL_BGRA;
 435+ texformat2 = GL_UNSIGNED_BYTE;
 436+ texformat3 = GL_RGBA8;
 437+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
 438+ ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000;
 439+ ddsd.ddpfPixelFormat.dwGBitMask = 0xFF00;
 440+ ddsd.ddpfPixelFormat.dwBBitMask = 0xFF;
 441+ ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*4);
 442+ break;
 443+ default:
 444+ *error = DDERR_INVALIDPIXELFORMAT;
 445+ return;
 446+ }
 447+ }
 448+
 449+*/
\ No newline at end of file
Index: ddraw/texture.h
@@ -0,0 +1,50 @@
 2+// DXGL
 3+// Copyright (C) 2012 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#pragma once
 20+#ifndef _TEXTURE_H
 21+#define _TEXTURE_H
 22+
 23+typedef struct
 24+{
 25+ GLuint id;
 26+ GLsizei width;
 27+ GLsizei height;
 28+ GLint minfilter;
 29+ GLint magfilter;
 30+ GLint wraps;
 31+ GLint wrapt;
 32+ GLint miplevel;
 33+ DWORD bordercolor;
 34+ GLint internalformat;
 35+ GLenum format;
 36+ GLenum type;
 37+ GLuint pbo;
 38+ DDPIXELFORMAT pixelformat;
 39+} TEXTURE;
 40+
 41+void InitTexture(DXGLCFG *cfg);
 42+void SetActiveTexture(int level);
 43+void SetTexture(unsigned int level, TEXTURE *texture);
 44+
 45+extern void (*_CreateTexture)(TEXTURE *texture, int width, int height);
 46+extern void (*_DeleteTexture)(TEXTURE *texture);
 47+extern void (*_UploadTexture)(TEXTURE *texture, int level, const void *data, int width, int height);
 48+extern void (*_DownloadTexture)(TEXTURE *texture, int level, void *data);
 49+
 50+
 51+#endif //_TEXTURE_H
\ No newline at end of file