]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix gl_mesh_testmanualfeeding
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 8 Jul 2011 19:33:54 +0000 (19:33 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 8 Jul 2011 19:29:55 +0000 (21:29 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11234 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=eb3110f1151a26dafff642d6214c562a4851de91

gl_backend.c

index 0c3e73915e2192045b8645231d7ff6746680b274..74938dc509636456b57232e62e22db1376b99bb6 100644 (file)
@@ -2717,121 +2717,201 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtri
                                unsigned int i, j, element;
                                const GLfloat *p;
                                qglBegin(GL_TRIANGLES);
-                               for (i = 0;i < (unsigned int) numtriangles * 3;i++)
+                               if(vid.renderpath == RENDERPATH_GL20)
                                {
-                                       if (element3i)
-                                               element = element3i[i];
-                                       else if (element3s)
-                                               element = element3s[i];
-                                       else
-                                               element = firstvertex + i;
-                                       for (j = 0;j < vid.texarrayunits;j++)
+                                       for (i = 0;i < (unsigned int) numtriangles * 3;i++)
                                        {
-                                               if (gl_state.units[j].pointer_texcoord_pointer && gl_state.units[j].arrayenabled)
+                                               if (element3i)
+                                                       element = element3i[i];
+                                               else if (element3s)
+                                                       element = element3s[i];
+                                               else
+                                                       element = firstvertex + i;
+                                               for (j = 0;j < vid.texarrayunits;j++)
                                                {
-                                                       if (gl_state.units[j].pointer_texcoord_gltype == GL_FLOAT)
+                                                       if (gl_state.units[j].pointer_texcoord_pointer && gl_state.units[j].arrayenabled)
                                                        {
-                                                               p = (const GLfloat *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
-                                                               if (vid.texarrayunits > 1)
-                                                               {
-                                                                       if (gl_state.units[j].pointer_texcoord_components == 4)
-                                                                               qglMultiTexCoord4f(GL_TEXTURE0_ARB + j, p[0], p[1], p[2], p[3]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 3)
-                                                                               qglMultiTexCoord3f(GL_TEXTURE0_ARB + j, p[0], p[1], p[2]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 2)
-                                                                               qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, p[0], p[1]);
-                                                                       else
-                                                                               qglMultiTexCoord1f(GL_TEXTURE0_ARB + j, p[0]);
-                                                               }
-                                                               else
+                                                               if (gl_state.units[j].pointer_texcoord_gltype == GL_FLOAT)
                                                                {
+                                                                       p = (const GLfloat *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
                                                                        if (gl_state.units[j].pointer_texcoord_components == 4)
-                                                                               qglTexCoord4f(p[0], p[1], p[2], p[3]);
+                                                                               qglVertexAttrib4f(GLSLATTRIB_TEXCOORD0 + j, p[0], p[1], p[2], p[3]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 3)
-                                                                               qglTexCoord3f(p[0], p[1], p[2]);
+                                                                               qglVertexAttrib3f(GLSLATTRIB_TEXCOORD0 + j, p[0], p[1], p[2]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 2)
-                                                                               qglTexCoord2f(p[0], p[1]);
+                                                                               qglVertexAttrib2f(GLSLATTRIB_TEXCOORD0 + j, p[0], p[1]);
                                                                        else
-                                                                               qglTexCoord1f(p[0]);
+                                                                               qglVertexAttrib1f(GLSLATTRIB_TEXCOORD0 + j, p[0]);
                                                                }
-                                                       }
-                                                       else if (gl_state.units[j].pointer_texcoord_gltype == GL_SHORT)
-                                                       {
-                                                               const GLshort *s = (const GLshort *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
-                                                               if (vid.texarrayunits > 1)
+                                                               else if (gl_state.units[j].pointer_texcoord_gltype == GL_SHORT)
                                                                {
+                                                                       const GLshort *s = (const GLshort *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
                                                                        if (gl_state.units[j].pointer_texcoord_components == 4)
-                                                                               qglMultiTexCoord4f(GL_TEXTURE0_ARB + j, s[0], s[1], s[2], s[3]);
+                                                                               qglVertexAttrib4f(GLSLATTRIB_TEXCOORD0 + j, s[0], s[1], s[2], s[3]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 3)
-                                                                               qglMultiTexCoord3f(GL_TEXTURE0_ARB + j, s[0], s[1], s[2]);
+                                                                               qglVertexAttrib3f(GLSLATTRIB_TEXCOORD0 + j, s[0], s[1], s[2]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 2)
-                                                                               qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, s[0], s[1]);
+                                                                               qglVertexAttrib2f(GLSLATTRIB_TEXCOORD0 + j, s[0], s[1]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 1)
-                                                                               qglMultiTexCoord1f(GL_TEXTURE0_ARB + j, s[0]);
+                                                                               qglVertexAttrib1f(GLSLATTRIB_TEXCOORD0 + j, s[0]);
                                                                }
-                                                               else
+                                                               else if (gl_state.units[j].pointer_texcoord_gltype == GL_BYTE)
                                                                {
+                                                                       const GLbyte *sb = (const GLbyte *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
                                                                        if (gl_state.units[j].pointer_texcoord_components == 4)
-                                                                               qglTexCoord4f(s[0], s[1], s[2], s[3]);
+                                                                               qglVertexAttrib4f(GLSLATTRIB_TEXCOORD0 + j, sb[0], sb[1], sb[2], sb[3]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 3)
-                                                                               qglTexCoord3f(s[0], s[1], s[2]);
+                                                                               qglVertexAttrib3f(GLSLATTRIB_TEXCOORD0 + j, sb[0], sb[1], sb[2]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 2)
-                                                                               qglTexCoord2f(s[0], s[1]);
+                                                                               qglVertexAttrib2f(GLSLATTRIB_TEXCOORD0 + j, sb[0], sb[1]);
                                                                        else if (gl_state.units[j].pointer_texcoord_components == 1)
-                                                                               qglTexCoord1f(s[0]);
+                                                                               qglVertexAttrib1f(GLSLATTRIB_TEXCOORD0 + j, sb[0]);
                                                                }
                                                        }
-                                                       else if (gl_state.units[j].pointer_texcoord_gltype == GL_BYTE)
+                                               }
+                                               if (gl_state.pointer_color_pointer && gl_state.pointer_color_enabled && gl_state.pointer_color_components == 4)
+                                               {
+                                                       if (gl_state.pointer_color_gltype == GL_FLOAT)
+                                                       {
+                                                               p = (const GLfloat *)((const unsigned char *)gl_state.pointer_color_pointer + element * gl_state.pointer_color_stride);
+                                                               qglVertexAttrib4f(GLSLATTRIB_COLOR, p[0], p[1], p[2], p[3]);
+                                                       }
+                                                       else if (gl_state.pointer_color_gltype == GL_UNSIGNED_BYTE)
+                                                       {
+                                                               const GLubyte *ub = (const GLubyte *)((const unsigned char *)gl_state.pointer_color_pointer + element * gl_state.pointer_color_stride);
+                                                               qglVertexAttrib4Nub(GLSLATTRIB_COLOR, ub[0], ub[1], ub[2], ub[3]);
+                                                       }
+                                               }
+                                               if (gl_state.pointer_vertex_gltype == GL_FLOAT)
+                                               {
+                                                       p = (const GLfloat *)((const unsigned char *)gl_state.pointer_vertex_pointer + element * gl_state.pointer_vertex_stride);
+                                                       if (gl_state.pointer_vertex_components == 4)
+                                                               qglVertexAttrib4f(GLSLATTRIB_POSITION, p[0], p[1], p[2], p[3]);
+                                                       else if (gl_state.pointer_vertex_components == 3)
+                                                               qglVertexAttrib3f(GLSLATTRIB_POSITION, p[0], p[1], p[2]);
+                                                       else
+                                                               qglVertexAttrib2f(GLSLATTRIB_POSITION, p[0], p[1]);
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       for (i = 0;i < (unsigned int) numtriangles * 3;i++)
+                                       {
+                                               if (element3i)
+                                                       element = element3i[i];
+                                               else if (element3s)
+                                                       element = element3s[i];
+                                               else
+                                                       element = firstvertex + i;
+                                               for (j = 0;j < vid.texarrayunits;j++)
+                                               {
+                                                       if (gl_state.units[j].pointer_texcoord_pointer && gl_state.units[j].arrayenabled)
                                                        {
-                                                               const GLbyte *sb = (const GLbyte *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
-                                                               if (vid.texarrayunits > 1)
+                                                               if (gl_state.units[j].pointer_texcoord_gltype == GL_FLOAT)
                                                                {
-                                                                       if (gl_state.units[j].pointer_texcoord_components == 4)
-                                                                               qglMultiTexCoord4f(GL_TEXTURE0_ARB + j, sb[0], sb[1], sb[2], sb[3]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 3)
-                                                                               qglMultiTexCoord3f(GL_TEXTURE0_ARB + j, sb[0], sb[1], sb[2]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 2)
-                                                                               qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, sb[0], sb[1]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 1)
-                                                                               qglMultiTexCoord1f(GL_TEXTURE0_ARB + j, sb[0]);
+                                                                       p = (const GLfloat *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
+                                                                       if (vid.texarrayunits > 1)
+                                                                       {
+                                                                               if (gl_state.units[j].pointer_texcoord_components == 4)
+                                                                                       qglMultiTexCoord4f(GL_TEXTURE0_ARB + j, p[0], p[1], p[2], p[3]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 3)
+                                                                                       qglMultiTexCoord3f(GL_TEXTURE0_ARB + j, p[0], p[1], p[2]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 2)
+                                                                                       qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, p[0], p[1]);
+                                                                               else
+                                                                                       qglMultiTexCoord1f(GL_TEXTURE0_ARB + j, p[0]);
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               if (gl_state.units[j].pointer_texcoord_components == 4)
+                                                                                       qglTexCoord4f(p[0], p[1], p[2], p[3]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 3)
+                                                                                       qglTexCoord3f(p[0], p[1], p[2]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 2)
+                                                                                       qglTexCoord2f(p[0], p[1]);
+                                                                               else
+                                                                                       qglTexCoord1f(p[0]);
+                                                                       }
                                                                }
-                                                               else
+                                                               else if (gl_state.units[j].pointer_texcoord_gltype == GL_SHORT)
                                                                {
-                                                                       if (gl_state.units[j].pointer_texcoord_components == 4)
-                                                                               qglTexCoord4f(sb[0], sb[1], sb[2], sb[3]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 3)
-                                                                               qglTexCoord3f(sb[0], sb[1], sb[2]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 2)
-                                                                               qglTexCoord2f(sb[0], sb[1]);
-                                                                       else if (gl_state.units[j].pointer_texcoord_components == 1)
-                                                                               qglTexCoord1f(sb[0]);
+                                                                       const GLshort *s = (const GLshort *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
+                                                                       if (vid.texarrayunits > 1)
+                                                                       {
+                                                                               if (gl_state.units[j].pointer_texcoord_components == 4)
+                                                                                       qglMultiTexCoord4f(GL_TEXTURE0_ARB + j, s[0], s[1], s[2], s[3]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 3)
+                                                                                       qglMultiTexCoord3f(GL_TEXTURE0_ARB + j, s[0], s[1], s[2]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 2)
+                                                                                       qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, s[0], s[1]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 1)
+                                                                                       qglMultiTexCoord1f(GL_TEXTURE0_ARB + j, s[0]);
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               if (gl_state.units[j].pointer_texcoord_components == 4)
+                                                                                       qglTexCoord4f(s[0], s[1], s[2], s[3]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 3)
+                                                                                       qglTexCoord3f(s[0], s[1], s[2]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 2)
+                                                                                       qglTexCoord2f(s[0], s[1]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 1)
+                                                                                       qglTexCoord1f(s[0]);
+                                                                       }
+                                                               }
+                                                               else if (gl_state.units[j].pointer_texcoord_gltype == GL_BYTE)
+                                                               {
+                                                                       const GLbyte *sb = (const GLbyte *)((const unsigned char *)gl_state.units[j].pointer_texcoord_pointer + element * gl_state.units[j].pointer_texcoord_stride);
+                                                                       if (vid.texarrayunits > 1)
+                                                                       {
+                                                                               if (gl_state.units[j].pointer_texcoord_components == 4)
+                                                                                       qglMultiTexCoord4f(GL_TEXTURE0_ARB + j, sb[0], sb[1], sb[2], sb[3]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 3)
+                                                                                       qglMultiTexCoord3f(GL_TEXTURE0_ARB + j, sb[0], sb[1], sb[2]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 2)
+                                                                                       qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, sb[0], sb[1]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 1)
+                                                                                       qglMultiTexCoord1f(GL_TEXTURE0_ARB + j, sb[0]);
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               if (gl_state.units[j].pointer_texcoord_components == 4)
+                                                                                       qglTexCoord4f(sb[0], sb[1], sb[2], sb[3]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 3)
+                                                                                       qglTexCoord3f(sb[0], sb[1], sb[2]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 2)
+                                                                                       qglTexCoord2f(sb[0], sb[1]);
+                                                                               else if (gl_state.units[j].pointer_texcoord_components == 1)
+                                                                                       qglTexCoord1f(sb[0]);
+                                                                       }
                                                                }
                                                        }
                                                }
-                                       }
-                                       if (gl_state.pointer_color_pointer && gl_state.pointer_color_enabled && gl_state.pointer_color_components == 4)
-                                       {
-                                               if (gl_state.pointer_color_gltype == GL_FLOAT)
+                                               if (gl_state.pointer_color_pointer && gl_state.pointer_color_enabled && gl_state.pointer_color_components == 4)
                                                {
-                                                       p = (const GLfloat *)((const unsigned char *)gl_state.pointer_color_pointer + element * gl_state.pointer_color_stride);
-                                                       qglColor4f(p[0], p[1], p[2], p[3]);
+                                                       if (gl_state.pointer_color_gltype == GL_FLOAT)
+                                                       {
+                                                               p = (const GLfloat *)((const unsigned char *)gl_state.pointer_color_pointer + element * gl_state.pointer_color_stride);
+                                                               qglColor4f(p[0], p[1], p[2], p[3]);
+                                                       }
+                                                       else if (gl_state.pointer_color_gltype == GL_UNSIGNED_BYTE)
+                                                       {
+                                                               const GLubyte *ub = (const GLubyte *)((const unsigned char *)gl_state.pointer_color_pointer + element * gl_state.pointer_color_stride);
+                                                               qglColor4ub(ub[0], ub[1], ub[2], ub[3]);
+                                                       }
                                                }
-                                               else if (gl_state.pointer_color_gltype == GL_UNSIGNED_BYTE)
+                                               if (gl_state.pointer_vertex_gltype == GL_FLOAT)
                                                {
-                                                       const GLubyte *ub = (const GLubyte *)((const unsigned char *)gl_state.pointer_color_pointer + element * gl_state.pointer_color_stride);
-                                                       qglColor4ub(ub[0], ub[1], ub[2], ub[3]);
+                                                       p = (const GLfloat *)((const unsigned char *)gl_state.pointer_vertex_pointer + element * gl_state.pointer_vertex_stride);
+                                                       if (gl_state.pointer_vertex_components == 4)
+                                                               qglVertex4f(p[0], p[1], p[2], p[3]);
+                                                       else if (gl_state.pointer_vertex_components == 3)
+                                                               qglVertex3f(p[0], p[1], p[2]);
+                                                       else
+                                                               qglVertex2f(p[0], p[1]);
                                                }
                                        }
-                                       if (gl_state.pointer_vertex_gltype == GL_FLOAT)
-                                       {
-                                               p = (const GLfloat *)((const unsigned char *)gl_state.pointer_vertex_pointer + element * gl_state.pointer_vertex_stride);
-                                               if (gl_state.pointer_vertex_components == 4)
-                                                       qglVertex4f(p[0], p[1], p[2], p[3]);
-                                               else if (gl_state.pointer_vertex_components == 3)
-                                                       qglVertex3f(p[0], p[1], p[2]);
-                                               else
-                                                       qglVertex2f(p[0], p[1]);
-                                       }
                                }
                                qglEnd();
                                CHECKGLERROR