Skip to content

Commit

Permalink
Release 0.1.4
Browse files Browse the repository at this point in the history
Use generic attributes for vertex shaders
Fix debug messages

git-svn-id: https://www.williamfeely.info/svn/dxgl@81 8a90861a-4eca-46d5-b744-240ff16d0c4d
  • Loading branch information
dxgldotorg committed Jan 18, 2012
1 parent b961a0d commit f510201
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 25 deletions.
4 changes: 2 additions & 2 deletions common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#define DXGLMAJOR 0
#define DXGLMINOR 1
#define DXGLPOINT 3
#define DXGLPOINT 4
#define DXGLBUILD 0

#define DXGLVERNUMBER DXGLMAJOR,DXGLMINOR,DXGLPOINT,DXGLBUILD
#define DXGLVERQWORD (((unsigned __int64)DXGLMAJOR<<48)+((unsigned __int64)DXGLMINOR<<32)+((unsigned __int64)DXGLPOINT<<16)+(unsigned __int64)DXGLBUILD)
#define DXGLVERSTRING "0.1.3.0"
#define DXGLVERSTRING "0.1.4.0"


#endif //__VERSION_H
2 changes: 1 addition & 1 deletion common/version.nsh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!define PRODUCT_VERSION "0.1.3"
!define PRODUCT_VERSION "0.1.4"
3 changes: 2 additions & 1 deletion ddraw/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ extern const GUID device_template;
OutputDebugStringA("DEBUG: ");\
OutputDebugStringA(x);\
}
#define STR(x) #x
#define STR2(x) #x
#define STR(x) STR2(x)
#ifdef _DEBUG
#define ERR(error) \
{\
Expand Down
36 changes: 23 additions & 13 deletions ddraw/glDirectDrawSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,16 +709,25 @@ HRESULT WINAPI glDirectDrawSurface7::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE7
GLint texloc = glGetUniformLocation(shaders[PROG_TEXTURE].prog,"Texture");
glUniform1i(texloc,0);
}
GLint viewloc = glGetUniformLocation(GetProgram()&0xffffffff,"view");
GLuint prog = GetProgram()&0xffffffff;
GLint viewloc = glGetUniformLocation(prog,"view");
glUniform4f(viewloc,0,(GLfloat)fakex,0,(GLfloat)fakey);
this->dirty |= 2;
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].x);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3,GL_UNSIGNED_BYTE,sizeof(BltVertex),&bltvertices[0].r);
glClientActiveTexture(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].s);
GLint xyloc = glGetAttribLocation(prog,"xy");
glEnableVertexAttribArray(xyloc);
glVertexAttribPointer(xyloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
if(dwFlags & DDBLT_COLORFILL)
{
GLint rgbloc = glGetAttribLocation(prog,"rgb");
glEnableVertexAttribArray(rgbloc);
glVertexAttribPointer(rgbloc,3,GL_UNSIGNED_BYTE,true,sizeof(BltVertex),&bltvertices[0].r);
}
else
{
GLint stloc = glGetAttribLocation(prog,"st");
glEnableVertexAttribArray(stloc);
glVertexAttribPointer(stloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
}
glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
glDisable(GL_TEXTURE_2D);
SetFBO(0,0,false);
Expand Down Expand Up @@ -1201,11 +1210,12 @@ void glDirectDrawSurface7::RenderScreen(GLuint texture, glDirectDrawSurface7 *su
}
bltvertices[0].s = bltvertices[0].t = bltvertices[1].t = bltvertices[2].s = 1.;
bltvertices[1].s = bltvertices[2].t = bltvertices[3].s = bltvertices[3].t = 0.;
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].x);
glClientActiveTexture(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2,GL_FLOAT,sizeof(BltVertex),&bltvertices[0].s);
GLint xyloc = glGetAttribLocation(prog,"xy");
glEnableVertexAttribArray(xyloc);
glVertexAttribPointer(xyloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].x);
GLint stloc = glGetAttribLocation(prog,"st");
glEnableVertexAttribArray(stloc);
glVertexAttribPointer(stloc,2,GL_FLOAT,false,sizeof(BltVertex),&bltvertices[0].s);
glDrawRangeElements(GL_TRIANGLE_STRIP,0,3,4,GL_UNSIGNED_SHORT,bltindices);
glDisable(GL_TEXTURE_2D);
glFlush();
Expand Down
7 changes: 7 additions & 0 deletions ddraw/glExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ void (APIENTRY *glDetachShader) (GLuint program, GLuint shader) = NULL;
void (APIENTRY *glLinkProgram) (GLuint program) = NULL;
void (APIENTRY *glUseProgram) (GLuint program) = NULL;

GLint (APIENTRY *glGetAttribLocation) (GLuint program, const GLchar* name) = NULL;
void (APIENTRY *glVertexAttribPointer) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer) = NULL;
void (APIENTRY *glEnableVertexAttribArray) (GLuint index) = NULL;

void (APIENTRY *glGenFramebuffers) (GLsizei n, GLuint* ids) = NULL;
void (APIENTRY *glBindFramebuffer) (GLenum target, GLuint framebuffer) = NULL;
void (APIENTRY *glGenRenderbuffers) (GLsizei n, GLuint* renderbuffers) = NULL;
Expand Down Expand Up @@ -107,6 +111,9 @@ void InitGLExt()
glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
}
const GLubyte *glextensions = glGetString(GL_EXTENSIONS);
if(strstr((char*)glextensions,"GL_ARB_framebuffer_object")) GLEXT_ARB_framebuffer_object = 1;
Expand Down
4 changes: 4 additions & 0 deletions ddraw/glExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ GLAPI void (APIENTRY *glDetachShader) (GLuint program, GLuint shader);
GLAPI void (APIENTRY *glLinkProgram) (GLuint program);
GLAPI void (APIENTRY *glUseProgram) (GLuint program);

GLAPI GLint (APIENTRY *glGetAttribLocation) (GLuint program, const GLchar* name);
GLAPI void (APIENTRY *glVertexAttribPointer) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
GLAPI void (APIENTRY *glEnableVertexAttribArray) (GLuint index);

GLAPI void (APIENTRY *glGenFramebuffers) (GLsizei n, GLuint* ids);
GLAPI void (APIENTRY *glBindFramebuffer) (GLenum target, GLuint framebuffer);
GLAPI void (APIENTRY *glGenRenderbuffers) (GLsizei n, GLuint* renderbuffers);
Expand Down
44 changes: 39 additions & 5 deletions ddraw/shadergen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
#include "shadergen.h"
#include "shaders.h"

SHADER genshaders[256];
struct GenShader
{
SHADER shader;
__int64 id;
};
GenShader genshaders[256];
static __int64 current_shader = 0;
static int shadercount = 0;
static bool initialized = false;
Expand All @@ -28,10 +33,13 @@ static bool isbuiltin = true;
void SetShader(__int64 id, bool builtin)
{
if(builtin)
{
glUseProgram(shaders[id].prog);
current_shader = shaders[id].prog;
}
{
glUseProgram(shaders[id].prog);
current_shader = shaders[id].prog;
}
else
{
}
}

GLuint GetProgram()
Expand All @@ -42,3 +50,29 @@ GLuint GetProgram()
return 0;
}
}

#define REVISION 1
static const char header[] =
"//REV" STR(REVISION) "\n\
#version 110\n";
static const char vertexshader[] = "//Vertex Shader\n";
static const char fragshader[] = "//Fragment Shader\n";
static const char idheader[] = "//ID: 0x";
static const char linefeed[] = "\n";
static const char mainstart[] = "void main()\n{\n";
static const char mainend[] = "} ";
static const char attr_xy[] = "attribute vec2 xy;\n";
static const char conv_xy[] = "vec4 xyzw = vec4(xy[0],xy[1],0,1);\n";
static const char attr_xyz[] = "attribute vec3 xyz;\n";
static const char conv_xyz[] = "vec4 xyzw = vec4(xyz[0],xyz[1],xyz[2],1);\n";
static const char attr_xyzw[] = "attribute vec4 xyzw;\n";
static const char attr_rgb[] = "attrib vec3 rgb;\n";
static const char conv_rgb[] = "vec4 rgba = vec4(rgb[0],rgb[1],rgb[2],1);\n";
static const char attr_rgba[] = "attrib vec4 rgba;\n";
static const char attr_s[] = "attrib float sX;\n";
static const char conv_s[] = "vec4 strqX = vec4(sX,0,0,1);\n";
static const char attr_st[] = "attrib vec2 stX;\n";
static const char conv_st[] = "vec4 strqX = vec4(stX[0],stX[1],0,1);\n";
static const char attr_str[] = "attrib vec3 strX;\n";
static const char conv_str[] = "vec4 strqX = vec4(strX[0],strX[1],strX[2],1);\n";
static const char attr_strq[] = "attrib vec4 strqX;\n";
12 changes: 9 additions & 3 deletions ddraw/shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,23 @@ void main (void)\n\
const char vert_ortho[] = "\
#version 110\n\
uniform vec4 view;\n\
attribute vec2 xy;\n\
attribute vec3 rgb;\n\
attribute vec2 st;\n\
void main()\n\
{\n\
vec4 xyzw = vec4(xy[0],xy[1],0,1);\n\
vec4 rgba = vec4(rgb[0],rgb[1],rgb[2],1);\n\
vec4 strq = vec4(st[0],st[1],0,1);\n\
mat4 proj = mat4(\n\
vec4(2.0 / (view[1] - view[0]), 0, 0, 0),\n\
vec4(0, 2.0 / (view[2] - view[3]), 0, 0),\n\
vec4(0, 0, -2.0, 0),\n\
vec4(-(view[1] + view[0]) / (view[1] - view[0]),\n\
-(view[2] + view[3]) / (view[2] - view[3]), -1 , 1));\n\
gl_Position = proj * gl_Vertex;\n\
gl_FrontColor = gl_Color;\n\
gl_TexCoord[0] = gl_MultiTexCoord0;\n\
gl_Position = proj * xyzw;\n\
gl_FrontColor = rgba;\n\
gl_TexCoord[0] = strq;\n\
} ";


Expand Down

0 comments on commit f510201

Please sign in to comment.