]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_models.c
fixed animated textures in realtime lighting mode (now calls R_UpdateTextureInfo)
[xonotic/darkplaces.git] / gl_models.c
index 17e1f2bf749d25e9e23ba78464f495fb2d8078f2..223be1b81b87af20c877d54b988831638ee23e9e 100644 (file)
@@ -234,15 +234,13 @@ void R_DrawAliasModelCallback (const void *calldata1, int calldata2)
                                m.texrgbscale[0] = 4;
                        }
                }
-               R_Mesh_State_Texture(&m);
+               m.pointer_vertex = varray_vertex3f;
 
                c_alias_polys += mesh->num_triangles;
-               GL_VertexPointer(varray_vertex3f);
                R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_VERTEX, varray_vertex3f);
                if (layer->flags & ALIASLAYER_FOG)
                {
                        colorscale *= fog;
-                       GL_ColorPointer(NULL);
                        GL_Color(fogcolor[0] * colorscale, fogcolor[1] * colorscale, fogcolor[2] * colorscale, ent->alpha);
                }
                else
@@ -266,26 +264,23 @@ void R_DrawAliasModelCallback (const void *calldata1, int calldata2)
                                VectorScale(tint, r_shadow_realtime_world_lightmaps.value, tint);
                        colorscale *= ifog;
                        if (fullbright)
-                       {
-                               GL_ColorPointer(NULL);
                                GL_Color(tint[0] * colorscale, tint[1] * colorscale, tint[2] * colorscale, ent->alpha);
-                       }
                        else
                        {
                                if (R_LightModel(ambientcolor4f, diffusecolor, diffusenormal, ent, tint[0] * colorscale, tint[1] * colorscale, tint[2] * colorscale, ent->alpha, false))
                                {
-                                       GL_ColorPointer(varray_color4f);
+                                       m.pointer_color = varray_color4f;
                                        R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_NORMAL, varray_normal3f);
                                        R_LightModel_CalcVertexColors(ambientcolor4f, diffusecolor, diffusenormal, mesh->num_vertices, varray_vertex3f, varray_normal3f, varray_color4f);
                                }
                                else
-                               {
-                                       GL_ColorPointer(NULL);
                                        GL_Color(ambientcolor4f[0], ambientcolor4f[1], ambientcolor4f[2], ambientcolor4f[3]);
-                               }
                        }
                }
+               R_Mesh_State(&m);
+               GL_LockArrays(0, mesh->num_vertices);
                R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);
+               GL_LockArrays(0, 0);
        }
 }
 
@@ -385,7 +380,7 @@ void R_Model_Alias_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, v
                        if (layer->flags & ALIASLAYER_SPECULAR)
                        {
                                c_alias_polys += mesh->num_triangles;
-                               R_Shadow_SpecularLighting(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i, aliasvert_vertex3f, aliasvert_svector3f, aliasvert_tvector3f, aliasvert_normal3f, mesh->data_texcoord2f, relativelightorigin, relativeeyeorigin, lightcolor2, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, layer->texture, layer->nmap, lightcubemap);
+                               R_Shadow_RenderLighting(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i, aliasvert_vertex3f, aliasvert_svector3f, aliasvert_tvector3f, aliasvert_normal3f, mesh->data_texcoord2f, relativelightorigin, relativeeyeorigin, lightcolor2, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, layer->texture, layer->nmap, layer->texture, lightcubemap, LIGHTING_SPECULAR);
                        }
                        else if (layer->flags & ALIASLAYER_DIFFUSE)
                        {
@@ -414,7 +409,7 @@ void R_Model_Alias_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, v
                                        lightcolor2[2] *= bcolor[2] * (1.0f / 255.0f);
                                }
                                c_alias_polys += mesh->num_triangles;
-                               R_Shadow_DiffuseLighting(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i, aliasvert_vertex3f, aliasvert_svector3f, aliasvert_tvector3f, aliasvert_normal3f, mesh->data_texcoord2f, relativelightorigin, lightcolor2, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, layer->texture, layer->nmap, lightcubemap);
+                               R_Shadow_RenderLighting(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i, aliasvert_vertex3f, aliasvert_svector3f, aliasvert_tvector3f, aliasvert_normal3f, mesh->data_texcoord2f, relativelightorigin, relativeeyeorigin, lightcolor2, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, layer->texture, layer->nmap, layer->texture, lightcubemap, LIGHTING_DIFFUSE);
                        }
                }
        }
@@ -739,7 +734,6 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
                GL_DepthMask(true);
        }
        GL_DepthTest(true);
-       GL_VertexPointer(varray_vertex3f);
 
        memset(&mstate, 0, sizeof(mstate));
        colorscale = 1.0f;
@@ -750,7 +744,7 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        }
        mstate.tex[0] = R_GetTexture(texture);
        mstate.pointer_texcoord[0] = ent->model->alias.zymdata_texcoords;
-       R_Mesh_State_Texture(&mstate);
+       mstate.pointer_vertex = varray_vertex3f;
 
        ZymoticLerpBones(ent->model->alias.zymnum_bones, (zymbonematrix *) ent->model->alias.zymdata_poses, ent->frameblend, ent->model->alias.zymdata_bones);
 
@@ -758,15 +752,15 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        ZymoticCalcNormal3f(numverts, varray_vertex3f, aliasvert_normal3f, ent->model->alias.zymnum_shaders, ent->model->alias.zymdata_renderlist);
        if (R_LightModel(ambientcolor4f, diffusecolor, diffusenormal, ent, ifog * colorscale, ifog * colorscale, ifog * colorscale, ent->alpha, false))
        {
-               GL_ColorPointer(varray_color4f);
+               mstate.pointer_color = varray_color4f;
                R_LightModel_CalcVertexColors(ambientcolor4f, diffusecolor, diffusenormal, numverts, varray_vertex3f, aliasvert_normal3f, varray_color4f);
        }
        else
-       {
-               GL_ColorPointer(NULL);
                GL_Color(ambientcolor4f[0], ambientcolor4f[1], ambientcolor4f[2], ambientcolor4f[3]);
-       }
+       R_Mesh_State(&mstate);
+       GL_LockArrays(0, numverts);
        R_Mesh_Draw(numverts, numtriangles, elements);
+       GL_LockArrays(0, 0);
        c_alias_polys += numtriangles;
 
        if (fog)
@@ -774,18 +768,20 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                GL_DepthMask(false);
                GL_DepthTest(true);
-               GL_VertexPointer(varray_vertex3f);
 
                memset(&mstate, 0, sizeof(mstate));
                // FIXME: need alpha mask for fogging...
                //mstate.tex[0] = R_GetTexture(texture);
                //mstate.pointer_texcoord = ent->model->alias.zymdata_texcoords;
-               R_Mesh_State_Texture(&mstate);
+               mstate.pointer_vertex = varray_vertex3f;
+               R_Mesh_State(&mstate);
 
-               GL_ColorPointer(NULL);
                GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha * fog);
                ZymoticTransformVerts(numverts, varray_vertex3f, ent->model->alias.zymdata_vertbonecounts, ent->model->alias.zymdata_verts);
+               R_Mesh_State(&mstate);
+               GL_LockArrays(0, numverts);
                R_Mesh_Draw(numverts, numtriangles, elements);
+               GL_LockArrays(0, 0);
                c_alias_polys += numtriangles;
        }
 }