Index: common/version.h |
— | — | @@ -4,12 +4,12 @@ |
5 | 5 |
|
6 | 6 | #define DXGLMAJOR 0
|
7 | 7 | #define DXGLMINOR 1
|
8 | | -#define DXGLPOINT 3
|
| 8 | +#define DXGLPOINT 4
|
9 | 9 | #define DXGLBUILD 0
|
10 | 10 |
|
11 | 11 | #define DXGLVERNUMBER DXGLMAJOR,DXGLMINOR,DXGLPOINT,DXGLBUILD
|
12 | 12 | #define DXGLVERQWORD (((unsigned __int64)DXGLMAJOR<<48)+((unsigned __int64)DXGLMINOR<<32)+((unsigned __int64)DXGLPOINT<<16)+(unsigned __int64)DXGLBUILD)
|
13 | | -#define DXGLVERSTRING "0.1.3.0"
|
| 13 | +#define DXGLVERSTRING "0.1.4.0"
|
14 | 14 |
|
15 | 15 |
|
16 | 16 | #endif //__VERSION_H
|
Index: common/version.nsh |
— | — | @@ -1 +1 @@ |
2 | | -!define PRODUCT_VERSION "0.1.3" |
\ No newline at end of file |
| 2 | +!define PRODUCT_VERSION "0.1.4" |
\ No newline at end of file |
Index: ddraw/common.h |
— | — | @@ -60,7 +60,8 @@ |
61 | 61 | OutputDebugStringA("DEBUG: ");\
|
62 | 62 | OutputDebugStringA(x);\
|
63 | 63 | }
|
64 | | -#define STR(x) #x
|
| 64 | +#define STR2(x) #x
|
| 65 | +#define STR(x) STR2(x)
|
65 | 66 | #ifdef _DEBUG
|
66 | 67 | #define ERR(error) \
|
67 | 68 | {\
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -709,16 +709,25 @@ |
710 | 710 | GLint texloc = glGetUniformLocation(shaders[PROG_TEXTURE].prog,"Texture");
|
711 | 711 | glUniform1i(texloc,0);
|
712 | 712 | }
|
713 | | - GLint viewloc = glGetUniformLocation(GetProgram()&0xffffffff,"view");
|
| 713 | + GLuint prog = GetProgram()&0xffffffff;
|
| 714 | + GLint viewloc = glGetUniformLocation(prog,"view");
|
714 | 715 | glUniform4f(viewloc,0,(GLfloat)fakex,0,(GLfloat)fakey);
|
715 | 716 | this->dirty |= 2;
|
716 | | - glEnableClientState(GL_VERTEX_ARRAY);
|
717 | | - glVertexPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].x);
|
718 | | - glEnableClientState(GL_COLOR_ARRAY);
|
719 | | - glColorPointer(3,GL_UNSIGNED_BYTE,sizeof(BltVertex),&bltvertices[0].r);
|
720 | | - glClientActiveTexture(GL_TEXTURE0);
|
721 | | - glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
722 | | - glTexCoordPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].s);
|
| 717 | + GLint xyloc = glGetAttribLocation(prog,"xy");
|
| 718 | + glEnableVertexAttribArray(xyloc);
|
| 719 | + glVertexAttribPointer(xyloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
|
| 720 | + if(dwFlags & DDBLT_COLORFILL)
|
| 721 | + {
|
| 722 | + GLint rgbloc = glGetAttribLocation(prog,"rgb");
|
| 723 | + glEnableVertexAttribArray(rgbloc);
|
| 724 | + glVertexAttribPointer(rgbloc,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
|
| 725 | + }
|
| 726 | + else
|
| 727 | + {
|
| 728 | + GLint stloc = glGetAttribLocation(prog,"st");
|
| 729 | + glEnableVertexAttribArray(stloc);
|
| 730 | + glVertexAttribPointer(stloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
|
| 731 | + }
|
723 | 732 | glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
|
724 | 733 | glDisable(GL_TEXTURE_2D);
|
725 | 734 | SetFBO(0,0,false);
|
— | — | @@ -1201,11 +1210,12 @@ |
1202 | 1211 | }
|
1203 | 1212 | bltvertices[0].s = bltvertices[0].t = bltvertices[1].t = bltvertices[2].s = 1.;
|
1204 | 1213 | bltvertices[1].s = bltvertices[2].t = bltvertices[3].s = bltvertices[3].t = 0.;
|
1205 | | - glEnableClientState(GL_VERTEX_ARRAY);
|
1206 | | - glVertexPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].x);
|
1207 | | - glClientActiveTexture(GL_TEXTURE0);
|
1208 | | - glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
1209 | | - glTexCoordPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].s);
|
| 1214 | + GLint xyloc = glGetAttribLocation(prog,"xy");
|
| 1215 | + glEnableVertexAttribArray(xyloc);
|
| 1216 | + glVertexAttribPointer(xyloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
|
| 1217 | + GLint stloc = glGetAttribLocation(prog,"st");
|
| 1218 | + glEnableVertexAttribArray(stloc);
|
| 1219 | + glVertexAttribPointer(stloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
|
1210 | 1220 | glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
|
1211 | 1221 | glDisable(GL_TEXTURE_2D);
|
1212 | 1222 | glFlush();
|
Index: ddraw/glExtensions.cpp |
— | — | @@ -30,6 +30,10 @@ |
31 | 31 | void (APIENTRY *glLinkProgram) (GLuint program) = NULL;
|
32 | 32 | void (APIENTRY *glUseProgram) (GLuint program) = NULL;
|
33 | 33 |
|
| 34 | +GLint (APIENTRY *glGetAttribLocation) (GLuint program, const GLchar* name) = NULL;
|
| 35 | +void (APIENTRY *glVertexAttribPointer) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer) = NULL;
|
| 36 | +void (APIENTRY *glEnableVertexAttribArray) (GLuint index) = NULL;
|
| 37 | +
|
34 | 38 | void (APIENTRY *glGenFramebuffers) (GLsizei n, GLuint* ids) = NULL;
|
35 | 39 | void (APIENTRY *glBindFramebuffer) (GLenum target, GLuint framebuffer) = NULL;
|
36 | 40 | void (APIENTRY *glGenRenderbuffers) (GLsizei n, GLuint* renderbuffers) = NULL;
|
— | — | @@ -107,6 +111,9 @@ |
108 | 112 | glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
|
109 | 113 | glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
|
110 | 114 | glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
|
| 115 | + glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
|
| 116 | + glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
|
| 117 | + glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
|
111 | 118 | }
|
112 | 119 | const GLubyte *glextensions = glGetString(GL_EXTENSIONS);
|
113 | 120 | if(strstr((char*)glextensions,"GL_ARB_framebuffer_object")) GLEXT_ARB_framebuffer_object = 1;
|
Index: ddraw/glExtensions.h |
— | — | @@ -50,6 +50,10 @@ |
51 | 51 | GLAPI void (APIENTRY *glLinkProgram) (GLuint program);
|
52 | 52 | GLAPI void (APIENTRY *glUseProgram) (GLuint program);
|
53 | 53 |
|
| 54 | +GLAPI GLint (APIENTRY *glGetAttribLocation) (GLuint program, const GLchar* name);
|
| 55 | +GLAPI void (APIENTRY *glVertexAttribPointer) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
|
| 56 | +GLAPI void (APIENTRY *glEnableVertexAttribArray) (GLuint index);
|
| 57 | +
|
54 | 58 | GLAPI void (APIENTRY *glGenFramebuffers) (GLsizei n, GLuint* ids);
|
55 | 59 | GLAPI void (APIENTRY *glBindFramebuffer) (GLenum target, GLuint framebuffer);
|
56 | 60 | GLAPI void (APIENTRY *glGenRenderbuffers) (GLsizei n, GLuint* renderbuffers);
|
Index: ddraw/shadergen.cpp |
— | — | @@ -19,7 +19,12 @@ |
20 | 20 | #include "shadergen.h"
|
21 | 21 | #include "shaders.h"
|
22 | 22 |
|
23 | | -SHADER genshaders[256];
|
| 23 | +struct GenShader
|
| 24 | +{
|
| 25 | + SHADER shader;
|
| 26 | + __int64 id;
|
| 27 | +};
|
| 28 | +GenShader genshaders[256];
|
24 | 29 | static __int64 current_shader = 0;
|
25 | 30 | static int shadercount = 0;
|
26 | 31 | static bool initialized = false;
|
— | — | @@ -28,10 +33,13 @@ |
29 | 34 | void SetShader(__int64 id, bool builtin)
|
30 | 35 | {
|
31 | 36 | if(builtin)
|
32 | | - {
|
33 | | - glUseProgram(shaders[id].prog);
|
34 | | - current_shader = shaders[id].prog;
|
35 | | - }
|
| 37 | + {
|
| 38 | + glUseProgram(shaders[id].prog);
|
| 39 | + current_shader = shaders[id].prog;
|
| 40 | + }
|
| 41 | + else
|
| 42 | + {
|
| 43 | + }
|
36 | 44 | }
|
37 | 45 |
|
38 | 46 | GLuint GetProgram()
|
— | — | @@ -42,3 +50,29 @@ |
43 | 51 | return 0;
|
44 | 52 | }
|
45 | 53 | }
|
| 54 | +
|
| 55 | +#define REVISION 1
|
| 56 | +static const char header[] =
|
| 57 | + "//REV" STR(REVISION) "\n\
|
| 58 | +#version 110\n";
|
| 59 | +static const char vertexshader[] = "//Vertex Shader\n";
|
| 60 | +static const char fragshader[] = "//Fragment Shader\n";
|
| 61 | +static const char idheader[] = "//ID: 0x";
|
| 62 | +static const char linefeed[] = "\n";
|
| 63 | +static const char mainstart[] = "void main()\n{\n";
|
| 64 | +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";
|
| 67 | +static const char attr_xyz[] = "attribute vec3 xyz;\n";
|
| 68 | +static const char conv_xyz[] = "vec4 xyzw = vec4(xyz[0],xyz[1],xyz[2],1);\n";
|
| 69 | +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";
|
| 74 | +static const char conv_s[] = "vec4 strqX = vec4(sX,0,0,1);\n";
|
| 75 | +static const char attr_st[] = "attrib vec2 stX;\n";
|
| 76 | +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";
|
| 78 | +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 |
Index: ddraw/shaders.cpp |
— | — | @@ -90,8 +90,14 @@ |
91 | 91 | const char vert_ortho[] = "\
|
92 | 92 | #version 110\n\
|
93 | 93 | uniform vec4 view;\n\
|
| 94 | +attribute vec2 xy;\n\
|
| 95 | +attribute vec3 rgb;\n\
|
| 96 | +attribute vec2 st;\n\
|
94 | 97 | void main()\n\
|
95 | 98 | {\n\
|
| 99 | + vec4 xyzw = vec4(xy[0],xy[1],0,1);\n\
|
| 100 | + vec4 rgba = vec4(rgb[0],rgb[1],rgb[2],1);\n\
|
| 101 | + vec4 strq = vec4(st[0],st[1],0,1);\n\
|
96 | 102 | mat4 proj = mat4(\n\
|
97 | 103 | vec4(2.0 / (view[1] - view[0]), 0, 0, 0),\n\
|
98 | 104 | vec4(0, 2.0 / (view[2] - view[3]), 0, 0),\n\
|
— | — | @@ -98,9 +104,9 @@ |
99 | 105 | vec4(0, 0, -2.0, 0),\n\
|
100 | 106 | vec4(-(view[1] + view[0]) / (view[1] - view[0]),\n\
|
101 | 107 | -(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\
|
| 108 | + gl_Position = proj * xyzw;\n\
|
| 109 | + gl_FrontColor = rgba;\n\
|
| 110 | + gl_TexCoord[0] = strq;\n\
|
105 | 111 | } ";
|
106 | 112 |
|
107 | 113 |
|