]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed iOS rendering (set the vertex attribute bindings before attaching the shaders...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 9 Feb 2011 02:04:58 +0000 (02:04 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 9 Feb 2011 02:04:58 +0000 (02:04 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10833 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_rmain.c

index e4a157e4a7154c0dcb92dab6abbdde630bab7edf..e6f3b17d77725adff0b169a5dd69e0b05a11386b 100644 (file)
@@ -1375,7 +1375,7 @@ static void GL_Backend_ResetState(void)
        gl_state.color4f[0] = gl_state.color4f[1] = gl_state.color4f[2] = gl_state.color4f[3] = 1;
        gl_state.lockrange_first = 0;
        gl_state.lockrange_count = 0;
-       gl_state.cullface = GL_NONE;
+       gl_state.cullface = GL_FRONT;
        gl_state.cullfaceenable = false;
        gl_state.polygonoffset[0] = 0;
        gl_state.polygonoffset[1] = 0;
@@ -2055,7 +2055,7 @@ void GL_SetMirrorState(qboolean state)
                case RENDERPATH_GL20:
                case RENDERPATH_CGGL:
                case RENDERPATH_GLES2:
-                       qglCullFace(gl_state.cullface);
+                       qglCullFace(gl_state.cullface);CHECKGLERROR
                        break;
                case RENDERPATH_D3D9:
 #ifdef SUPPORTD3D
@@ -2543,6 +2543,20 @@ unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **ver
        if (!programobject)
                return 0;
 
+       if (vid.renderpath == RENDERPATH_GLES2)
+       {
+               qglBindAttribLocation(programobject, GLES2ATTRIB_POSITION , "Attrib_Position" );
+               qglBindAttribLocation(programobject, GLES2ATTRIB_COLOR    , "Attrib_Color"    );
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD0, "Attrib_TexCoord0");
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD1, "Attrib_TexCoord1");
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD2, "Attrib_TexCoord2");
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD3, "Attrib_TexCoord3");
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD4, "Attrib_TexCoord4");
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD5, "Attrib_TexCoord5");
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD6, "Attrib_TexCoord6");
+               qglBindAttribLocation(programobject, GLES2ATTRIB_TEXCOORD7, "Attrib_TexCoord7");
+       }
+
        if (vertexstrings_count && !GL_Backend_CompileShader(programobject, GL_VERTEX_SHADER, "vertex", vertexstrings_count, vertexstrings_list))
                goto cleanup;
 
@@ -2981,8 +2995,34 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtri
                        // GLES does not have glDrawRangeElements, and generally
                        // underperforms with index buffers, so this code path is
                        // relatively straightforward...
-                       //if (qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
-                       //      Con_DPrintf("fbo %i not complete (default %i)\n", gl_state.framebufferobject, gl_state.defaultframebufferobject);
+#if 0
+                       if (gl_paranoid.integer)
+                       {
+                               int r, prog, enabled, i;
+                               GLsizei         attriblength;
+                               GLint           attribsize;
+                               GLenum          attribtype;
+                               GLchar          attribname[1024];
+                               r = qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);CHECKGLERROR
+                               if (r != GL_FRAMEBUFFER_COMPLETE_EXT)
+                                       Con_DPrintf("fbo %i not complete (default %i)\n", gl_state.framebufferobject, gl_state.defaultframebufferobject);
+#ifndef GL_CURRENT_PROGRAM
+#define GL_CURRENT_PROGRAM 0x8B8D
+#endif
+                               qglGetIntegerv(GL_CURRENT_PROGRAM, &r);CHECKGLERROR
+                               if (r < 0 || r > 10000)
+                                       Con_DPrintf("GL_CURRENT_PROGRAM = %i\n", r);
+                               prog = r;
+                               for (i = 0;i < 8;i++)
+                               {
+                                       qglGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &r);CHECKGLERROR
+                                       if (!r)
+                                               continue;
+                                       qglGetActiveAttrib(prog, i, sizeof(attribname), &attriblength, &attribsize, &attribtype, attribname);CHECKGLERROR
+                                       Con_DPrintf("prog %i position %i length %i size %04X type %i name \"%s\"\n", prog, i, (int)attriblength, (int)attribsize, (int)attribtype, (char *)attribname);
+                               }
+                       }
+#endif
                        if (element3s)
                        {
                                qglDrawElements(GL_TRIANGLES, numelements, GL_UNSIGNED_SHORT, element3s);
index d63fb72e2c8a58aeb5a53de8a480b33d242f26a3..196c4fefd580122c02d3e65e0dc43b2f3375b9fc 100644 (file)
@@ -5207,19 +5207,6 @@ static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode
                if (p->loc_Texture_ScreenSpecular  >= 0) {p->tex_Texture_ScreenSpecular   = sampler;qglUniform1i(p->loc_Texture_ScreenSpecular  , sampler);sampler++;}
                if (p->loc_Texture_ReflectMask     >= 0) {p->tex_Texture_ReflectMask      = sampler;qglUniform1i(p->loc_Texture_ReflectMask     , sampler);sampler++;}
                if (p->loc_Texture_ReflectCube     >= 0) {p->tex_Texture_ReflectCube      = sampler;qglUniform1i(p->loc_Texture_ReflectCube     , sampler);sampler++;}
-               if (vid.renderpath == RENDERPATH_GLES2)
-               {
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_POSITION , "Attrib_Position" );
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_COLOR    , "Attrib_Color"    );
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD0, "Attrib_TexCoord0");
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD1, "Attrib_TexCoord1");
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD2, "Attrib_TexCoord2");
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD3, "Attrib_TexCoord3");
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD4, "Attrib_TexCoord4");
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD5, "Attrib_TexCoord5");
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD6, "Attrib_TexCoord6");
-                       qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD7, "Attrib_TexCoord7");
-               }
                CHECKGLERROR
                Con_DPrintf("^5GLSL shader %s compiled (%i textures).\n", permutationname, sampler);
        }