DXGL r129 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r128‎ | r129 | r130 >
Date:15:39, 17 March 2012
Author:admin
Status:new
Tags:
Comment:
Add texture coordinate format to shader ID.
Fix crash rendering without Z buffer.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -982,7 +982,8 @@
983983 wndbusy = false;
984984 GLfloat color[4];
985985 dwordto4float(dwColor,color);
986 - SetFBO(target->texture,target->GetZBuffer()->texture,target->GetZBuffer()->hasstencil);
 986+ if(target->zbuffer) SetFBO(target->texture,target->GetZBuffer()->texture,target->GetZBuffer()->hasstencil);
 987+ else SetFBO(target->texture,0,false);
987988 int clearbits = 0;
988989 if(D3DCLEAR_TARGET)
989990 {
@@ -1037,8 +1038,11 @@
10381039 if(transformed)
10391040 {
10401041 GLint xyzwloc = glGetAttribLocation(prog,"rhw");
1041 - glEnableVertexAttribArray(xyzwloc);
1042 - glVertexAttribPointer(xyzwloc,4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
 1042+ if(xyzwloc != -1)
 1043+ {
 1044+ glEnableVertexAttribArray(xyzwloc);
 1045+ glVertexAttribPointer(xyzwloc,4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
 1046+ }
10431047 }
10441048 for(i = 0; i < 5; i++)
10451049 {
@@ -1150,7 +1154,8 @@
11511155 }
11521156 }
11531157 }
1154 - SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
 1158+ if(device->glDDS7->zbuffer) SetFBO(device->glDDS7->texture,device->glDDS7->zbuffer->texture,device->glDDS7->zbuffer->hasstencil);
 1159+ else SetFBO(device->glDDS7->texture,0,false);
11551160 glViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
11561161 if(indices) glDrawRangeElements(mode,0,indexcount,count,GL_UNSIGNED_SHORT,indices);
11571162 else glDrawArrays(mode,0,count);
Index: ddraw/shadergen.cpp
@@ -37,6 +37,7 @@
3838 _GENSHADER shader;
3939 __int64 id;
4040 __int64 texids[8];
 41+ int texcoords[8];
4142 };
4243 GenShader genshaders[256];
4344 static __int64 current_shader = 0;
@@ -145,8 +146,11 @@
146147 {
147148 if(!memcmp(genshaders[i].texids,texstate,8*sizeof(__int64)))
148149 {
149 - shaderindex = i;
150 - break;
 150+ if(!memcmp(genshaders[i].texcoords,texcoords,8*sizeof(int)))
 151+ {
 152+ shaderindex = i;
 153+ break;
 154+ }
151155 }
152156 }
153157 }
@@ -171,6 +175,7 @@
172176 }
173177 genshaders[shaderindex].id = id;
174178 memcpy(genshaders[shaderindex].texids,texstate,8*sizeof(__int64));
 179+ memcpy(genshaders[shaderindex].texcoords,texcoords,8*sizeof(int));
175180 glUseProgram(genshaders[shaderindex].shader.prog);
176181 current_prog = genshaders[shaderindex].shader.prog;
177182 }