| Index: common/version.h |
| — | — | @@ -8,6 +8,7 @@ |
| 9 | 9 | #define DXGLBUILD 0
|
| 10 | 10 |
|
| 11 | 11 | #define DXGLVERNUMBER DXGLMAJOR,DXGLMINOR,DXGLPOINT,DXGLBUILD
|
| | 12 | +#define DXGLVERQWORD (((unsigned __int64)DXGLMAJOR<<48)+((unsigned __int64)DXGLMINOR<<32)+((unsigned __int64)DXGLPOINT<<16)+(unsigned __int64)DXGLBUILD)
|
| 12 | 13 | #define DXGLVERSTRING "0.1.3.0"
|
| 13 | 14 |
|
| 14 | 15 |
|
| Index: ddraw/ddraw.vcxproj |
| — | — | @@ -179,6 +179,7 @@ |
| 180 | 180 | <ClInclude Include="include\GL\wglext.h" />
|
| 181 | 181 | <ClInclude Include="include\winedef.h" />
|
| 182 | 182 | <ClInclude Include="scalers.h" />
|
| | 183 | + <ClInclude Include="shadergen.h" />
|
| 183 | 184 | <ClInclude Include="shaders.h" />
|
| 184 | 185 | </ItemGroup>
|
| 185 | 186 | <ItemGroup>
|
| — | — | @@ -220,6 +221,7 @@ |
| 221 | 222 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
| 222 | 223 | </ClCompile>
|
| 223 | 224 | <ClCompile Include="scalers.cpp" />
|
| | 225 | + <ClCompile Include="shadergen.cpp" />
|
| 224 | 226 | <ClCompile Include="shaders.cpp" />
|
| 225 | 227 | </ItemGroup>
|
| 226 | 228 | <ItemGroup>
|
| Index: ddraw/ddraw.vcxproj.filters |
| — | — | @@ -89,6 +89,9 @@ |
| 90 | 90 | <ClInclude Include="glutil.h">
|
| 91 | 91 | <Filter>Header Files</Filter>
|
| 92 | 92 | </ClInclude>
|
| | 93 | + <ClInclude Include="shadergen.h">
|
| | 94 | + <Filter>Header Files</Filter>
|
| | 95 | + </ClInclude>
|
| 93 | 96 | </ItemGroup>
|
| 94 | 97 | <ItemGroup>
|
| 95 | 98 | <ClCompile Include="ddraw.cpp">
|
| — | — | @@ -139,6 +142,9 @@ |
| 140 | 143 | <ClCompile Include="glutil.cpp">
|
| 141 | 144 | <Filter>Source Files</Filter>
|
| 142 | 145 | </ClCompile>
|
| | 146 | + <ClCompile Include="shadergen.cpp">
|
| | 147 | + <Filter>Source Files</Filter>
|
| | 148 | + </ClCompile>
|
| 143 | 149 | </ItemGroup>
|
| 144 | 150 | <ItemGroup>
|
| 145 | 151 | <ResourceCompile Include="ddraw.rc">
|
| Index: ddraw/glDirectDraw.cpp |
| — | — | @@ -24,6 +24,7 @@ |
| 25 | 25 | #include "glDirectDrawSurface.h"
|
| 26 | 26 | #include "glDirectDrawPalette.h"
|
| 27 | 27 | #include "glutil.h"
|
| | 28 | +#include "../common/version.h"
|
| 28 | 29 |
|
| 29 | 30 | bool directdraw_created = false; // emulate only one ddraw device
|
| 30 | 31 | bool wndclasscreated = false;
|
| — | — | @@ -31,7 +32,7 @@ |
| 32 | 33 | DDDEVICEIDENTIFIER2 devid = {
|
| 33 | 34 | "ddraw.dll",
|
| 34 | 35 | "DXGL DDraw Wrapper",
|
| 35 | | - 0x0000000000070000,
|
| | 36 | + 0,
|
| 36 | 37 | 0,0,0,0,
|
| 37 | 38 | 0,0};
|
| 38 | 39 |
|
| — | — | @@ -548,6 +549,7 @@ |
| 549 | 550 | glDirectDraw7::glDirectDraw7()
|
| 550 | 551 | {
|
| 551 | 552 | initialized = false;
|
| | 553 | + devid.liDriverVersion.QuadPart = DXGLVERQWORD;
|
| 552 | 554 | refcount = 1;
|
| 553 | 555 | }
|
| 554 | 556 |
|
| — | — | @@ -559,6 +561,7 @@ |
| 560 | 562 | error = DDERR_INVALIDPARAMS ;
|
| 561 | 563 | return;
|
| 562 | 564 | }
|
| | 565 | + devid.liDriverVersion.QuadPart = DXGLVERQWORD;
|
| 563 | 566 | error = glDirectDraw7::Initialize(lpGUID);
|
| 564 | 567 | refcount = 1;
|
| 565 | 568 | }
|
| — | — | @@ -1365,10 +1368,6 @@ |
| 1366 | 1369 | SetSwap(1);
|
| 1367 | 1370 | SetSwap(0);
|
| 1368 | 1371 | glViewport(0,0,width,height);
|
| 1369 | | - glMatrixMode(GL_PROJECTION);
|
| 1370 | | - glLoadIdentity();
|
| 1371 | | - glOrtho(0,width,height,0,0,1);
|
| 1372 | | - glMatrixMode(GL_MODELVIEW);
|
| 1373 | 1372 | glDisable(GL_DEPTH_TEST);
|
| 1374 | 1373 | const GLubyte *glver = glGetString(GL_VERSION);
|
| 1375 | 1374 | gl_caps.Version = (GLfloat)atof((char*)glver);
|
| Index: ddraw/glDirectDrawSurface.cpp |
| — | — | @@ -18,6 +18,7 @@ |
| 19 | 19 | #include "common.h"
|
| 20 | 20 | #include "scalers.h"
|
| 21 | 21 | #include "shaders.h"
|
| | 22 | +#include "shadergen.h"
|
| 22 | 23 | #include "ddraw.h"
|
| 23 | 24 | #include "glDirectDraw.h"
|
| 24 | 25 | #include "glDirectDrawSurface.h"
|
| — | — | @@ -620,13 +621,10 @@ |
| 621 | 622 | coords[5] = (GLfloat)srcrect.right / (GLfloat)ddsdSrc.dwWidth;
|
| 622 | 623 | coords[6] = (GLfloat)srcrect.top / (GLfloat)ddsdSrc.dwHeight;
|
| 623 | 624 | coords[7] = (GLfloat)srcrect.bottom / (GLfloat)ddsdSrc.dwHeight;
|
| 624 | | - glMatrixMode(GL_PROJECTION);
|
| 625 | 625 | glClear(GL_DEPTH_BUFFER_BIT);
|
| 626 | | - glLoadIdentity();
|
| 627 | | - glOrtho(0,fakex,fakey,0,0,1);
|
| 628 | | - glMatrixMode(GL_MODELVIEW);
|
| 629 | 626 | if(dwFlags & DDBLT_COLORFILL)
|
| 630 | 627 | {
|
| | 628 | + SetShader(PROG_FILL,1);
|
| 631 | 629 | glDisable(GL_TEXTURE_2D);
|
| 632 | 630 | glDisable(GL_ALPHA_TEST);
|
| 633 | 631 | switch(ddInterface->GetBPP())
|
| — | — | @@ -661,7 +659,7 @@ |
| 662 | 660 | if(lpDDSrcSurface) glBindTexture(GL_TEXTURE_2D,((glDirectDrawSurface7*)lpDDSrcSurface)->GetTexture());
|
| 663 | 661 | if((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
|
| 664 | 662 | {
|
| 665 | | - glUseProgram(shaders[PROG_CKEY].prog);
|
| | 663 | + SetShader(PROG_CKEY,1);
|
| 666 | 664 | GLint keyloc = glGetUniformLocation(shaders[PROG_CKEY].prog,"keyIn");
|
| 667 | 665 | switch(ddInterface->GetBPP())
|
| 668 | 666 | {
|
| — | — | @@ -690,7 +688,14 @@ |
| 691 | 689 | GLint texloc = glGetUniformLocation(shaders[PROG_CKEY].prog,"myTexture");
|
| 692 | 690 | glUniform1i(texloc,0);
|
| 693 | 691 | }
|
| 694 | | - else glUseProgram(0);
|
| | 692 | + else if(!(dwFlags & DDBLT_COLORFILL))
|
| | 693 | + {
|
| | 694 | + SetShader(PROG_TEXTURE,1);
|
| | 695 | + GLint texloc = glGetUniformLocation(shaders[PROG_TEXTURE].prog,"Texture");
|
| | 696 | + glUniform1i(texloc,0);
|
| | 697 | + }
|
| | 698 | + GLint viewloc = glGetUniformLocation(GetProgram()&0xffffffff,"view");
|
| | 699 | + glUniform4f(viewloc,0,(GLfloat)fakex,0,(GLfloat)fakey);
|
| 695 | 700 | this->dirty |= 2;
|
| 696 | 701 | glBegin(GL_QUADS);
|
| 697 | 702 | glTexCoord2f(coords[4], coords[6]);
|
| — | — | @@ -703,7 +708,6 @@ |
| 704 | 709 | glVertex2f(coords[0], coords[3]);
|
| 705 | 710 | glEnd();
|
| 706 | 711 | glColor3f(1.0,1.0,1.0);
|
| 707 | | - glUseProgram(0);
|
| 708 | 712 | glDisable(GL_TEXTURE_2D);
|
| 709 | 713 | SetFBO(0,0,false);
|
| 710 | 714 | glPopAttrib();
|
| — | — | @@ -1099,8 +1103,7 @@ |
| 1100 | 1104 | void glDirectDrawSurface7::RenderScreen(GLuint texture, glDirectDrawSurface7 *surface)
|
| 1101 | 1105 | {
|
| 1102 | 1106 | LONG sizes[6];
|
| 1103 | | - glMatrixMode(GL_PROJECTION);
|
| 1104 | | - glLoadIdentity();
|
| | 1107 | + GLfloat view[4];
|
| 1105 | 1108 | RECT r,r2;
|
| 1106 | 1109 | if(surface->dirty & 1)
|
| 1107 | 1110 | {
|
| — | — | @@ -1115,8 +1118,10 @@ |
| 1116 | 1119 | if(ddInterface->GetFullscreen())
|
| 1117 | 1120 | {
|
| 1118 | 1121 | ddInterface->GetSizes(sizes);
|
| 1119 | | - glOrtho((signed)-(sizes[4]-sizes[0])/2,(sizes[4]-sizes[0])/2+sizes[0],
|
| 1120 | | - (signed)-(sizes[5]-sizes[1])/2,(sizes[5]-sizes[1])/2+sizes[1],0,1);
|
| | 1122 | + view[0] = (signed)-(sizes[4]-sizes[0])/2;
|
| | 1123 | + view[1] = (signed)(sizes[4]-sizes[0])/2+sizes[0];
|
| | 1124 | + view[2] = (signed)(sizes[5]-sizes[1])/2+sizes[1];
|
| | 1125 | + view[3] = (signed)-(sizes[5]-sizes[1])/2;
|
| 1121 | 1126 | }
|
| 1122 | 1127 | else
|
| 1123 | 1128 | {
|
| — | — | @@ -1130,15 +1135,23 @@ |
| 1131 | 1136 | ClientToScreen(hwnd,(LPPOINT)&r2.left);
|
| 1132 | 1137 | ClientToScreen(hwnd,(LPPOINT)&r2.right);
|
| 1133 | 1138 | glViewport(0,0,r.right,r.bottom);
|
| 1134 | | - glOrtho((signed)r2.left,(signed)r2.right,(signed)(fakey-r2.bottom),(signed)(fakey-r2.top),0,1);
|
| | 1139 | + view[0] = (signed)r2.left;
|
| | 1140 | + view[1] = (signed)r2.right;
|
| | 1141 | + view[2] = (signed)(fakey-r2.top);
|
| | 1142 | + view[3] = (signed)(fakey-r2.bottom);
|
| 1135 | 1143 | }
|
| 1136 | 1144 | }
|
| 1137 | | - else glOrtho(0,fakex,fakey,0,0,1);
|
| 1138 | | - glMatrixMode(GL_MODELVIEW);
|
| | 1145 | + else
|
| | 1146 | + {
|
| | 1147 | + view[0] = 0;
|
| | 1148 | + view[1] = fakex;
|
| | 1149 | + view[2] = 0;
|
| | 1150 | + view[3] = fakey;
|
| | 1151 | + }
|
| 1139 | 1152 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
| 1140 | 1153 | if(ddInterface->GetBPP() == 8)
|
| 1141 | 1154 | {
|
| 1142 | | - glUseProgram(shaders[PROG_PAL256].prog);
|
| | 1155 | + SetShader(PROG_PAL256,true);
|
| 1143 | 1156 | glBindTexture(GL_TEXTURE_2D,paltex);
|
| 1144 | 1157 | glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,256,1,0,GL_RGBA,GL_UNSIGNED_BYTE,palette->GetPalette(NULL));
|
| 1145 | 1158 | GLint palloc = glGetUniformLocation(shaders[PROG_PAL256].prog,"ColorTable");
|
| — | — | @@ -1153,9 +1166,15 @@ |
| 1154 | 1167 | }
|
| 1155 | 1168 | else
|
| 1156 | 1169 | {
|
| | 1170 | + SetShader(PROG_TEXTURE,true);
|
| 1157 | 1171 | glEnable(GL_TEXTURE_2D);
|
| 1158 | 1172 | glBindTexture(GL_TEXTURE_2D,texture);
|
| | 1173 | + int prog = GetProgram();
|
| | 1174 | + GLint texloc = glGetUniformLocation(prog,"Texture");
|
| 1159 | 1175 | }
|
| | 1176 | + int prog = GetProgram();
|
| | 1177 | + GLint viewloc = glGetUniformLocation(prog,"view");
|
| | 1178 | + glUniform4f(viewloc,view[0],view[1],view[2],view[3]);
|
| 1160 | 1179 | if(ddInterface->GetFullscreen())
|
| 1161 | 1180 | {
|
| 1162 | 1181 | glBegin(GL_QUADS);
|
| Index: ddraw/glExtensions.cpp |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011 William Feely
|
| | 3 | +// Copyright (C) 2011-2012 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -48,6 +48,11 @@ |
| 49 | 49 | void (APIENTRY *glUniform2i) (GLint location, GLint v0, GLint v1) = NULL;
|
| 50 | 50 | void (APIENTRY *glUniform3i) (GLint location, GLint v0, GLint v1, GLint v2) = NULL;
|
| 51 | 51 | void (APIENTRY *glUniform4i) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3) = NULL;
|
| | 52 | +void (APIENTRY *glUniform1f) (GLint location, GLfloat v0) = NULL;
|
| | 53 | +void (APIENTRY *glUniform2f) (GLint location, GLfloat v0, GLfloat v1) = NULL;
|
| | 54 | +void (APIENTRY *glUniform3f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2) = NULL;
|
| | 55 | +void (APIENTRY *glUniform4f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) = NULL;
|
| | 56 | +void (APIENTRY *glUniformMatrix4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
|
| 52 | 57 |
|
| 53 | 58 | void (APIENTRY *glActiveTexture)(GLenum texture) = NULL;
|
| 54 | 59 |
|
| — | — | @@ -85,6 +90,11 @@ |
| 86 | 91 | glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
|
| 87 | 92 | glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
|
| 88 | 93 | glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
|
| | 94 | + glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
|
| | 95 | + glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
|
| | 96 | + glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
|
| | 97 | + glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
|
| | 98 | + glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
|
| 89 | 99 | }
|
| 90 | 100 | const GLubyte *glextensions = glGetString(GL_EXTENSIONS);
|
| 91 | 101 | if(strstr((char*)glextensions,"GL_ARB_framebuffer_object")) GLEXT_ARB_framebuffer_object = 1;
|
| Index: ddraw/glExtensions.h |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011 William Feely
|
| | 3 | +// Copyright (C) 2011-2012 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -67,6 +67,11 @@ |
| 68 | 68 | GLAPI void (APIENTRY *glUniform2i) (GLint location, GLint v0, GLint v1);
|
| 69 | 69 | GLAPI void (APIENTRY *glUniform3i) (GLint location, GLint v0, GLint v1, GLint v2);
|
| 70 | 70 | GLAPI void (APIENTRY *glUniform4i) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
|
| | 71 | +GLAPI void (APIENTRY *glUniform1f) (GLint location, GLfloat v0);
|
| | 72 | +GLAPI void (APIENTRY *glUniform2f) (GLint location, GLfloat v0, GLfloat v1);
|
| | 73 | +GLAPI void (APIENTRY *glUniform3f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
|
| | 74 | +GLAPI void (APIENTRY *glUniform4f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
| | 75 | +GLAPI void (APIENTRY *glUniformMatrix4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
| 71 | 76 |
|
| 72 | 77 | GLAPI void (APIENTRY *glActiveTexture)(GLenum texture);
|
| 73 | 78 |
|
| Index: ddraw/shadergen.cpp |
| — | — | @@ -0,0 +1,39 @@ |
| | 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 "shadergen.h"
|
| | 21 | +#include "shaders.h"
|
| | 22 | +
|
| | 23 | +SHADER genshaders[256];
|
| | 24 | +static __int64 current_shader = 0;
|
| | 25 | +static int shadercount = 0;
|
| | 26 | +static bool initialized = false;
|
| | 27 | +
|
| | 28 | +void SetShader(__int64 id, bool builtin)
|
| | 29 | +{
|
| | 30 | + if(builtin)
|
| | 31 | + {
|
| | 32 | + glUseProgram(shaders[id].prog);
|
| | 33 | + current_shader = shaders[id].prog;
|
| | 34 | + }
|
| | 35 | +}
|
| | 36 | +
|
| | 37 | +__int64 GetProgram()
|
| | 38 | +{
|
| | 39 | + return current_shader;
|
| | 40 | +}
|
| Index: ddraw/shadergen.h |
| — | — | @@ -0,0 +1,26 @@ |
| | 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 | +#ifndef _SHADERGEN_H
|
| | 20 | +#define _SHADERGEN_H
|
| | 21 | +
|
| | 22 | +
|
| | 23 | +void SetShader(__int64 id, bool builtin);
|
| | 24 | +__int64 GetProgram();
|
| | 25 | +
|
| | 26 | +
|
| | 27 | +#endif |
| \ No newline at end of file |
| Index: ddraw/shaders.cpp |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011 William Feely
|
| | 3 | +// Copyright (C) 2011-2012 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -18,8 +18,23 @@ |
| 19 | 19 | #include "common.h"
|
| 20 | 20 | #include "shaders.h"
|
| 21 | 21 |
|
| 22 | | -char frag_Pal256[] = "\
|
| | 22 | +const char frag_Color[] = "\
|
| 23 | 23 | #version 110\n\
|
| | 24 | +void main() \n\
|
| | 25 | +{ \n\
|
| | 26 | + gl_FragColor = gl_Color; \n\
|
| | 27 | +} ";
|
| | 28 | +
|
| | 29 | +const char frag_Texture[] = "\
|
| | 30 | +#version 110\n\
|
| | 31 | +uniform sampler2D Texture;\n\
|
| | 32 | +void main() \n\
|
| | 33 | +{ \n\
|
| | 34 | + gl_FragColor = texture2D( Texture, gl_TexCoord[0].st ); \n\
|
| | 35 | +} ";
|
| | 36 | +
|
| | 37 | +const char frag_Pal256[] = "\
|
| | 38 | +#version 110\n\
|
| 24 | 39 | uniform sampler2D ColorTable; \n\
|
| 25 | 40 | uniform sampler2D IndexTexture; \n\
|
| 26 | 41 | void main() \n\
|
| — | — | @@ -29,7 +44,7 @@ |
| 30 | 45 | gl_FragColor = texel; \n\
|
| 31 | 46 | } ";
|
| 32 | 47 |
|
| 33 | | -char frag_ColorKey[] = "\
|
| | 48 | +const char frag_ColorKey[] = "\
|
| 34 | 49 | #version 110\n\
|
| 35 | 50 | uniform sampler2D myTexture;\n\
|
| 36 | 51 | uniform ivec3 keyIn;\n\
|
| — | — | @@ -42,7 +57,7 @@ |
| 43 | 58 | gl_FragColor = value;\n\
|
| 44 | 59 | } ";
|
| 45 | 60 |
|
| 46 | | -char frag_ColorKeyMask[] = "\
|
| | 61 | +const char frag_ColorKeyMask[] = "\
|
| 47 | 62 | #version 110\n\
|
| 48 | 63 | uniform sampler2D myTexture;\n\
|
| 49 | 64 | uniform ivec4 keyIn;\n\
|
| — | — | @@ -55,7 +70,7 @@ |
| 56 | 71 | else gl_FragColor[0] = 0.0;\n\
|
| 57 | 72 | } ";
|
| 58 | 73 |
|
| 59 | | -char frag_2ColorKey[] = "\
|
| | 74 | +const char frag_2ColorKey[] = "\
|
| 60 | 75 | #version 110\n\
|
| 61 | 76 | uniform sampler2D myTexture;\n\
|
| 62 | 77 | uniform sampler2D maskTexture;\n\
|
| — | — | @@ -72,19 +87,43 @@ |
| 73 | 88 | gl_FragColor = value;\n\
|
| 74 | 89 | } ";
|
| 75 | 90 |
|
| 76 | | -int NumberOfShaders = 4;
|
| | 91 | +const char vert_ortho[] = "\
|
| | 92 | +#version 110\n\
|
| | 93 | +uniform vec4 view;\n\
|
| | 94 | +void main()\n\
|
| | 95 | +{\n\
|
| | 96 | + mat4 proj = mat4(\n\
|
| | 97 | + vec4(2.0 / (view[1] - view[0]), 0, 0, 0),\n\
|
| | 98 | + vec4(0, 2.0 / (view[2] - view[3]), 0, 0),\n\
|
| | 99 | + vec4(0, 0, -2.0, 0),\n\
|
| | 100 | + vec4(-(view[1] + view[0]) / (view[1] - view[0]),\n\
|
| | 101 | + -(view[2] + view[3]) / (view[2] - view[3]), -1 , 1));\n\
|
| | 102 | + gl_Position = proj * gl_Vertex;\n\
|
| | 103 | + gl_FrontColor = gl_Color;\n\
|
| | 104 | + gl_TexCoord[0] = gl_MultiTexCoord0;\n\
|
| | 105 | +} ";
|
| 77 | 106 |
|
| 78 | | -SHADER shaders[] = {
|
| 79 | | - {0,0, NULL, frag_Pal256, 0},
|
| 80 | | - {0,0, NULL, frag_ColorKey, 0},
|
| 81 | | - {0,0, NULL, frag_ColorKeyMask, 0},
|
| 82 | | - {0,0, NULL, frag_2ColorKey, 0}
|
| | 107 | +
|
| | 108 | +
|
| | 109 | +// Use EXACTLY one line per entry. Don't change layout of the list.
|
| | 110 | +const int SHADER_START = __LINE__;
|
| | 111 | +SHADER shaders[] =
|
| | 112 | +{
|
| | 113 | + {0,0, vert_ortho, frag_Color, 0},
|
| | 114 | + {0,0, vert_ortho, frag_Texture, 0},
|
| | 115 | + {0,0, vert_ortho, frag_Pal256, 0},
|
| | 116 | + {0,0, vert_ortho, frag_ColorKey, 0},
|
| | 117 | + {0,0, vert_ortho, frag_ColorKeyMask, 0},
|
| | 118 | + {0,0, vert_ortho, frag_2ColorKey, 0}
|
| 83 | 119 | };
|
| | 120 | +const int SHADER_END = __LINE__ - 4;
|
| | 121 | +const int NumberOfShaders = SHADER_END - SHADER_START;
|
| 84 | 122 |
|
| 85 | 123 | void CompileShaders()
|
| 86 | 124 | {
|
| 87 | 125 | const GLchar *src;
|
| 88 | 126 | GLint srclen;
|
| | 127 | + GLenum error;
|
| 89 | 128 | for(int i = 0; i < NumberOfShaders; i++)
|
| 90 | 129 | {
|
| 91 | 130 | shaders[i].prog = glCreateProgram();
|
| Index: ddraw/shaders.h |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2011 William Feely
|
| | 3 | +// Copyright (C) 2011-2012 William Feely
|
| 4 | 4 |
|
| 5 | 5 | // This library is free software; you can redistribute it and/or
|
| 6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
| — | — | @@ -23,17 +23,19 @@ |
| 24 | 24 | {
|
| 25 | 25 | GLint vs;
|
| 26 | 26 | GLint fs;
|
| 27 | | - char *vsrc;
|
| 28 | | - char *fsrc;
|
| | 27 | + const char *vsrc;
|
| | 28 | + const char *fsrc;
|
| 29 | 29 | GLint prog;
|
| 30 | 30 | } SHADER;
|
| 31 | 31 |
|
| 32 | 32 | extern SHADER shaders[];
|
| 33 | 33 |
|
| 34 | | -#define PROG_PAL256 0
|
| 35 | | -#define PROG_CKEY 1
|
| 36 | | -#define PROG_CKEYMASK 2
|
| 37 | | -#define PROG_2CKEY 3
|
| | 34 | +#define PROG_FILL 0
|
| | 35 | +#define PROG_TEXTURE 1
|
| | 36 | +#define PROG_PAL256 2
|
| | 37 | +#define PROG_CKEY 3
|
| | 38 | +#define PROG_CKEYMASK 4
|
| | 39 | +#define PROG_2CKEY 5
|
| 38 | 40 |
|
| 39 | 41 | void CompileShaders();
|
| 40 | 42 |
|