DXGL r82 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r81‎ | r82 | r83 >
Date:20:07, 22 January 2012
Author:admin
Status:new
Tags:
Comment:
Fix shader states
Implement IDirectDrawSurface::IsLost
More shader generator work
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glExtensions.cpp (modified) (history)
  • /ddraw/glExtensions.h (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)
  • /ddraw/shadergen.h (modified) (history)
  • /ddraw/shaders.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -520,11 +520,6 @@
521521 {
522522 if(!lpMaterial) return DDERR_INVALIDPARAMS;
523523 memcpy(&material,lpMaterial,sizeof(D3DMATERIAL7));
524 - glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,(GLfloat*)&material.ambient);
525 - glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,(GLfloat*)&material.diffuse);
526 - glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,(GLfloat*)&material.specular);
527 - glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,(GLfloat*)&material.emissive);
528 - glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,material.power);
529524 return D3D_OK;
530525 }
531526
Index: ddraw/glDirect3DDevice.h
@@ -106,6 +106,7 @@
107107 GLfloat *normals;
108108 GLubyte *diffuse;
109109 GLubyte *specular;
 110+ GLubyte *ambient;
110111 GLfloat *texcoords[8];
111112 };
112113
Index: ddraw/glDirectDraw.cpp
@@ -851,6 +851,9 @@
852852 if(initialized) return DDERR_ALREADYINITIALIZED;
853853 hDC = NULL;
854854 hRC = NULL;
 855+ PBO = 0;
 856+ hasHWnd = false;
 857+ dib.enabled = false;
855858 glD3D7 = NULL;
856859 hRenderWnd = NULL;
857860 primary = NULL;
@@ -1266,6 +1269,11 @@
12671270 {
12681271 DeleteShaders();
12691272 DeleteFBO();
 1273+ if(PBO)
 1274+ {
 1275+ glDeleteBuffers(1,&PBO);
 1276+ PBO = 0;
 1277+ }
12701278 wglMakeCurrent(NULL,NULL);
12711279 wglDeleteContext(hRC);
12721280 };
@@ -1322,16 +1330,34 @@
13231331 SetWindowPos(hWnd,NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
13241332 RECT rectRender;
13251333 GetClientRect(hWnd,&rectRender);
1326 - hRenderWnd = CreateWindowA("DXGLRenderWindow","Renderer",WS_CHILD|WS_VISIBLE,0,0,rectRender.right - rectRender.left,
1327 - rectRender.bottom - rectRender.top,hWnd,NULL,NULL,this);
 1334+ if(hWnd)
 1335+ {
 1336+ hRenderWnd = CreateWindowA("DXGLRenderWindow","Renderer",WS_CHILD|WS_VISIBLE,0,0,rectRender.right - rectRender.left,
 1337+ rectRender.bottom - rectRender.top,hWnd,NULL,NULL,this);
 1338+ hasHWnd = true;
 1339+ }
 1340+ else
 1341+ {
 1342+ width = GetSystemMetrics(SM_CXSCREEN);
 1343+ height = GetSystemMetrics(SM_CYSCREEN);
 1344+ hRenderWnd = CreateWindowExA(WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST,"DXGLRenderWindow","Renderer",
 1345+ WS_POPUP,0,0,width,height,0,0,NULL,this);
 1346+ hasHWnd = false;
 1347+ }
13281348 SetWindowPos(hRenderWnd,HWND_TOP,0,0,rectRender.right,rectRender.bottom,SWP_SHOWWINDOW);
13291349 PIXELFORMATDESCRIPTOR pfd;
13301350 ZeroMemory(&pfd,sizeof(PIXELFORMATDESCRIPTOR));
13311351 pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
13321352 pfd.nVersion = 1;
1333 - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
 1353+ if(hasHWnd) pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
 1354+ else pfd.dwFlags = pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
13341355 pfd.iPixelType = PFD_TYPE_RGBA;
1335 - pfd.cColorBits = bpp;
 1356+ if(hasHWnd) pfd.cColorBits = bpp;
 1357+ else
 1358+ {
 1359+ pfd.cColorBits = 24;
 1360+ pfd.cAlphaBits = 8;
 1361+ }
13361362 pfd.iLayerType = PFD_MAIN_PLANE;
13371363 hDC = GetDC(hRenderWnd);
13381364 if(!hDC)
@@ -1385,6 +1411,27 @@
13861412 glClear(GL_COLOR_BUFFER_BIT);
13871413 glFlush();
13881414 SwapBuffers(hDC);
 1415+ if(!hasHWnd)
 1416+ {
 1417+ dib.enabled = true;
 1418+ dib.width = width;
 1419+ dib.height = height;
 1420+ dib.pitch = (((width<<3)+31)&~31) >>3;
 1421+ dib.pixels = NULL;
 1422+ dib.hdc = CreateCompatibleDC(NULL);
 1423+ ZeroMemory(&dib.info,sizeof(BITMAPINFO));
 1424+ dib.info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 1425+ dib.info.bmiHeader.biBitCount = 32;
 1426+ dib.info.bmiHeader.biWidth = width;
 1427+ dib.info.bmiHeader.biHeight = height;
 1428+ dib.info.bmiHeader.biCompression = BI_RGB;
 1429+ dib.info.bmiHeader.biPlanes = 1;
 1430+ dib.hbitmap = CreateDIBSection(dib.hdc,&dib.info,DIB_RGB_COLORS,(void**)&dib.pixels,NULL,0);
 1431+ glGenBuffers(1,&PBO);
 1432+ glBindBuffer(GL_PIXEL_PACK_BUFFER,PBO);
 1433+ glBufferData(GL_PIXEL_PACK_BUFFER,width*height*4,NULL,GL_STREAM_READ);
 1434+ glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
 1435+ }
13891436 return TRUE;
13901437 }
13911438 void glDirectDraw7::GetSizes(LONG *sizes) // allocate 6 dwords
Index: ddraw/glDirectDraw.h
@@ -36,6 +36,17 @@
3737 int MultiTextureExt;
3838 int PalettedTextures;
3939 } GLCAPS;
 40+typedef struct
 41+{
 42+ bool enabled;
 43+ int width;
 44+ int height;
 45+ int pitch;
 46+ HDC hdc;
 47+ HBITMAP hbitmap;
 48+ BITMAPINFO info;
 49+ BYTE *pixels;
 50+} DIB;
4051
4152 class glDirectDraw7 : public IDirectDraw7
4253 {
@@ -95,6 +106,10 @@
96107 bool GetFullscreen(){return fullscreen;};
97108 void GetHandles(HWND *hwnd, HWND *hrender);
98109 glDirectDrawSurface7 *primary;
 110+ bool hasHWnd;
 111+ DIB dib;
 112+ GLuint PBO;
 113+ HWND hRenderWnd;
99114 private:
100115 void DeleteGL();
101116 BOOL InitGL(int width, int height, int bpp, bool fullscreen, HWND hWnd);
@@ -101,7 +116,6 @@
102117 HRESULT error;
103118 ULONG refcount;
104119 HWND hWnd;
105 - HWND hRenderWnd;
106120 bool fullscreen;
107121 bool fpupreserve;
108122 bool fpusetup;
Index: ddraw/glDirectDrawSurface.cpp
@@ -993,8 +993,8 @@
994994 }
995995 HRESULT WINAPI glDirectDrawSurface7::IsLost()
996996 {
997 - FIXME("glDirectDrawSurface7::IsLost: stub\n");
998 - ERR(DDERR_GENERIC);
 997+ if(hrc == ddInterface->hRC) return DD_OK;
 998+ else return DDERR_SURFACELOST;
999999 }
10001000
10011001 HRESULT WINAPI glDirectDrawSurface7::Lock(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
@@ -1219,7 +1219,37 @@
12201220 glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
12211221 glDisable(GL_TEXTURE_2D);
12221222 glFlush();
1223 - SwapBuffers(ddInterface->hDC);
 1223+ if(ddInterface->hasHWnd) SwapBuffers(ddInterface->hDC);
 1224+ else
 1225+ {
 1226+ glReadBuffer(GL_FRONT);
 1227+ glBindBuffer(GL_PIXEL_PACK_BUFFER,ddInterface->PBO);
 1228+ GLint packalign;
 1229+ glGetIntegerv(GL_PACK_ALIGNMENT,&packalign);
 1230+ glPixelStorei(GL_PACK_ALIGNMENT,1);
 1231+ glReadPixels(0,0,sizes[4],sizes[5],GL_BGRA,GL_UNSIGNED_BYTE,0);
 1232+ GLubyte *pixels = (GLubyte*)glMapBuffer(GL_PIXEL_PACK_BUFFER,GL_READ_ONLY);
 1233+ for(int i = 0; i < sizes[5];i++)
 1234+ {
 1235+ memcpy(&ddInterface->dib.pixels[ddInterface->dib.pitch*i],
 1236+ &pixels[((sizes[5]-1)-i)*(sizes[4]*4)],sizes[4]*4);
 1237+ }
 1238+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
 1239+ glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
 1240+ glPixelStorei(GL_PACK_ALIGNMENT,packalign);
 1241+ HDC hRenderDC = (HDC)::GetDC(ddInterface->hRenderWnd);
 1242+ HGDIOBJ hPrevObj = 0;
 1243+ POINT dest = {0,0};
 1244+ POINT src = {0,0};
 1245+ SIZE wnd = {ddInterface->dib.width,ddInterface->dib.height};
 1246+ BLENDFUNCTION func = {AC_SRC_OVER,0,255,AC_SRC_ALPHA};
 1247+ hPrevObj = SelectObject(ddInterface->dib.hdc,ddInterface->dib.hbitmap);
 1248+ ClientToScreen(ddInterface->hRenderWnd,&dest);
 1249+ UpdateLayeredWindow(ddInterface->hRenderWnd,hRenderDC,&dest,&wnd,
 1250+ ddInterface->dib.hdc,&src,0,&func,ULW_ALPHA);
 1251+ SelectObject(ddInterface->dib.hdc,hPrevObj);
 1252+ ::ReleaseDC(ddInterface->hRenderWnd,hRenderDC);
 1253+ }
12241254 }
12251255 // ddraw 2+ api
12261256 HRESULT WINAPI glDirectDrawSurface7::GetDDInterface(LPVOID FAR *lplpDD)
Index: ddraw/glExtensions.cpp
@@ -66,6 +66,13 @@
6767 void (APIENTRY *glActiveTexture)(GLenum texture) = NULL;
6868 void (APIENTRY *glClientActiveTexture) (GLenum texture) = NULL;
6969
 70+void (APIENTRY *glGenBuffers)(GLsizei n, GLuint* buffers) = NULL;
 71+void (APIENTRY *glDeleteBuffers)(GLsizei n, const GLuint* buffers) = NULL;
 72+void (APIENTRY *glBindBuffer)(GLenum target, GLuint buffer) = NULL;
 73+void (APIENTRY *glBufferData)(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) = NULL;
 74+void* (APIENTRY *glMapBuffer)(GLenum target, GLenum access) = NULL;
 75+GLboolean (APIENTRY *glUnmapBuffer)(GLenum target) = NULL;
 76+
7077 BOOL (APIENTRY *wglSwapIntervalEXT)(int interval) = NULL;
7178 int (APIENTRY *wglGetSwapIntervalEXT)() = NULL;
7279
@@ -88,6 +95,15 @@
8996 glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture");
9097 glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)wglGetProcAddress("glClientActiveTexture");
9198 }
 99+ if((glver_major >= 2) || ((glver_major >= 1) && (glver_minor >= 5)))
 100+ {
 101+ glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
 102+ glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers");
 103+ glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
 104+ glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
 105+ glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer");
 106+ glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer");
 107+ }
92108 if(glver_major >= 2)
93109 {
94110 glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
Index: ddraw/glExtensions.h
@@ -86,6 +86,13 @@
8787 GLAPI void (APIENTRY *glActiveTexture)(GLenum texture);
8888 GLAPI void (APIENTRY *glClientActiveTexture) (GLenum texture);
8989
 90+GLAPI void (APIENTRY *glGenBuffers)(GLsizei n, GLuint* buffers);
 91+GLAPI void (APIENTRY *glDeleteBuffers)(GLsizei n, const GLuint* buffers);
 92+GLAPI void (APIENTRY *glBindBuffer)(GLenum target, GLuint buffer);
 93+GLAPI void (APIENTRY *glBufferData)(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
 94+GLAPI void* (APIENTRY *glMapBuffer)(GLenum target, GLenum access);
 95+GLAPI GLboolean (APIENTRY *glUnmapBuffer)(GLenum target);
 96+
9097 GLAPI BOOL (APIENTRY *wglSwapIntervalEXT)(int interval);
9198 GLAPI int (APIENTRY *wglGetSwapIntervalEXT)();
9299
Index: ddraw/shadergen.cpp
@@ -18,27 +18,108 @@
1919 #include "common.h"
2020 #include "shadergen.h"
2121 #include "shaders.h"
 22+#include <string>
 23+using namespace std;
2224
 25+typedef struct
 26+{
 27+ GLint vs;
 28+ GLint fs;
 29+ string *vsrc;
 30+ string *fsrc;
 31+ GLint prog;
 32+} _GENSHADER;
 33+
2334 struct GenShader
2435 {
25 - SHADER shader;
 36+ _GENSHADER shader;
2637 __int64 id;
2738 };
2839 GenShader genshaders[256];
2940 static __int64 current_shader = 0;
3041 static int shadercount = 0;
 42+static int genindex = 0;
3143 static bool initialized = false;
3244 static bool isbuiltin = true;
3345
 46+/* Bits in Shader ID:
 47+Bits 0-1 - Shading mode: 00=flat 01=gouraud 11=phong 10=flat per-pixel
 48+Bit 2 - Alpha test enable
 49+Bits 3-5 - Alpha test function:
 50+000=never 001=less 010=equal 011=lessequal
 51+100=greater 101=notequal 110=lessequal 111=always
 52+Bits 6-7 - Table fog:
 53+00 = none 01=exp 10=exp2 11=linear
 54+Bits 8-9 - Vertex fog: same as table
 55+Bit 10 - Range based fog
 56+Bit 11 - Specular highlights
 57+Bit 12 - Stippled alpha
 58+Bit 13 - Color key transparency
 59+Bit 14 - Enable Z bias
 60+Bits 15-17 - Number of lights
 61+Bit 18 - Camera relative specular highlights
 62+Bit 19 - Alpha blended color key
 63+Bits 20-21 - Diffuse material source
 64+Bits 22-23 - Specular material source
 65+Bits 24-25 - Ambient material source
 66+Bits 26-27 - Emissive material source
 67+Bits 28-30 - Number of textures
 68+Bit 31 - RGB or RGBA color
 69+Bits 32-33 - Vertex format
 70+Bits 34-49 - Texture coordinate format
 71+Bit 50 - Enable normals
 72+Bits 51-58 - Light types
 73+*/
 74+void ZeroShaderArray()
 75+{
 76+ ZeroMemory(genshaders,256*sizeof(GenShader));
 77+ current_shader = 0;
 78+ isbuiltin = true;
 79+}
 80+
3481 void SetShader(__int64 id, bool builtin)
3582 {
 83+ int shaderindex = -1;
3684 if(builtin)
3785 {
 86+ if(isbuiltin && (shaders[id].prog == current_shader)) return;
3887 glUseProgram(shaders[id].prog);
3988 current_shader = shaders[id].prog;
 89+ isbuiltin=true;
4090 }
4191 else
4292 {
 93+ if(!isbuiltin && (id == current_shader)) return;
 94+ current_shader = id;
 95+ isbuiltin=false;
 96+ for(int i = 0; i < shadercount; i++)
 97+ {
 98+ if(genshaders[i].id == id)
 99+ {
 100+ shaderindex = i;
 101+ break;
 102+ }
 103+ }
 104+ if(shaderindex == -1)
 105+ {
 106+ shadercount++;
 107+ if(shadercount > 256) shadercount = 256;
 108+ if(genshaders[genindex].shader.prog)
 109+ {
 110+ glUseProgram(0);
 111+ glDeleteProgram(genshaders[shaderindex].shader.prog);
 112+ glDeleteShader(genshaders[shaderindex].shader.vs);
 113+ glDeleteShader(genshaders[shaderindex].shader.fs);
 114+ delete genshaders[shaderindex].shader.vsrc;
 115+ delete genshaders[shaderindex].shader.fsrc;
 116+ ZeroMemory(&genshaders[shaderindex],sizeof(GenShader));
 117+ }
 118+ CreateShader(genindex,id);
 119+ shaderindex = genindex;
 120+ genindex++;
 121+ if(genindex == 256) genindex = 0;
 122+ }
 123+ glUseProgram(shaderindex);
43124 }
44125 }
45126
@@ -51,6 +132,7 @@
52133 }
53134 }
54135
 136+
55137 #define REVISION 1
56138 static const char header[] =
57139 "//REV" STR(REVISION) "\n\
@@ -61,18 +143,89 @@
62144 static const char linefeed[] = "\n";
63145 static const char mainstart[] = "void main()\n{\n";
64146 static const char mainend[] = "} ";
65 -static const char attr_xy[] = "attribute vec2 xy;\n";
66 -static const char conv_xy[] = "vec4 xyzw = vec4(xy[0],xy[1],0,1);\n";
 147+// Attributes
67148 static const char attr_xyz[] = "attribute vec3 xyz;\n";
68149 static const char conv_xyz[] = "vec4 xyzw = vec4(xyz[0],xyz[1],xyz[2],1);\n";
69150 static const char attr_xyzw[] = "attribute vec4 xyzw;\n";
70 -static const char attr_rgb[] = "attrib vec3 rgb;\n";
71 -static const char conv_rgb[] = "vec4 rgba = vec4(rgb[0],rgb[1],rgb[2],1);\n";
72 -static const char attr_rgba[] = "attrib vec4 rgba;\n";
73 -static const char attr_s[] = "attrib float sX;\n";
 151+static const char attr_nxyz[] = "attribute vec3 nxyz;\n";
 152+static const char attr_blend[] = "attribute float blendX;\n";
 153+static const char attr_rgb[] = "attribute vec3 rgbX;\n";
 154+static const char conv_rgb[] = "vec4 rgbaX = vec4(rgbX[0],rgbX[1],rgbX[2],1);\n";
 155+static const char attr_rgba[] = "attribute vec4 rgbaX;\n";
 156+static const char attr_s[] = "attribute float sX;\n";
74157 static const char conv_s[] = "vec4 strqX = vec4(sX,0,0,1);\n";
75 -static const char attr_st[] = "attrib vec2 stX;\n";
 158+static const char attr_st[] = "attribute vec2 stX;\n";
76159 static const char conv_st[] = "vec4 strqX = vec4(stX[0],stX[1],0,1);\n";
77 -static const char attr_str[] = "attrib vec3 strX;\n";
 160+static const char attr_str[] = "attribute vec3 strX;\n";
78161 static const char conv_str[] = "vec4 strqX = vec4(strX[0],strX[1],strX[2],1);\n";
79 -static const char attr_strq[] = "attrib vec4 strqX;\n";
\ No newline at end of file
 162+static const char attr_strq[] = "attribute vec4 strqX;\n";
 163+// Uniforms
 164+static const char unif_mats[] = "uniform mat4 world;\n\
 165+uniform mat4 view;\n\
 166+uniform mat4 projection;\n";
 167+static const char modelview[] = "mat4 modelview = world * view;\n";
 168+static const char unif_material[] = "struct Material\n\
 169+{\n\
 170+vec4 diffuse;\n\
 171+vec4 ambient;\n\
 172+vec4 specular;\n\
 173+vec4 emussive;\n\
 174+int power;\n\
 175+};\n\
 176+uniform Material material;\n";
 177+static const char lightstruct[] = "struct Light\n\
 178+{\n\
 179+vec4 diffuse;\n\
 180+vec4 specilar;\n\
 181+vec4 ambient;\n\
 182+vec3 position;\n\
 183+vec3 direction;\n\
 184+float range;\n\
 185+float falloff;\n\
 186+float constant;\n\
 187+float linear;\n\
 188+float quad;\n\
 189+float theta;\n\
 190+float phi;\n\
 191+};\n";
 192+static const char unif_light[] = "uniform Light lightX;\n";
 193+// Operations
 194+static const char normalize[] = "vec3 N = normalize(vec3(modelview*vec4(nxyz,0.0)));\n";
 195+
 196+void CreateShader(int index, __int64 id)
 197+{
 198+ string tmp;
 199+ int i;
 200+ char idstring[22];
 201+ _snprintf(idstring,21,"%0.16I64X\n",id);
 202+ idstring[21] = 0;
 203+ genshaders[index].shader.vsrc = new string;
 204+ genshaders[index].shader.fsrc = new string;
 205+ // Create vertex shader
 206+ //Header
 207+ string *vsrc = genshaders[index].shader.vsrc;
 208+ vsrc->append(header);
 209+ vsrc->append(vertexshader);
 210+ vsrc->append(idheader);
 211+ vsrc->append(idstring);
 212+ //Variables
 213+ vsrc->append(unif_mats);
 214+ vsrc->append(unif_material);
 215+ if((id>>15)&8) // Lighting
 216+ {
 217+ vsrc->append(lightstruct);
 218+ for(i = 0; i < ((id>>15)&8); i++)
 219+ {
 220+ tmp = unif_light;
 221+ tmp.replace(19,1,_itoa(i,idstring,10));
 222+ vsrc->append(tmp);
 223+ }
 224+ }
 225+
 226+ //Main
 227+ vsrc->append(mainstart);
 228+
 229+
 230+ vsrc->append(mainend);
 231+
 232+}
Index: ddraw/shadergen.h
@@ -21,6 +21,7 @@
2222
2323 void SetShader(__int64 id, bool builtin);
2424 GLuint GetProgram();
 25+void ZeroShaderArray();
 26+void CreateShader(int index, __int64 id);
2527
26 -
2728 #endif
\ No newline at end of file
Index: ddraw/shaders.cpp
@@ -17,6 +17,7 @@
1818
1919 #include "common.h"
2020 #include "shaders.h"
 21+#include "shadergen.h"
2122
2223 const char frag_Color[] = "\
2324 #version 110\n\
@@ -127,6 +128,7 @@
128129
129130 void CompileShaders()
130131 {
 132+ ZeroShaderArray();
131133 const GLchar *src;
132134 GLint srclen;
133135 for(int i = 0; i < NumberOfShaders; i++)