From 5a322742c350007b5f2b715de7e565673e78a635 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Jul 2014 00:37:13 +0200 Subject: [PATCH] - remove use of builtin and deprecated color vertex attribute. --- src/gl/renderer/gl_renderstate.cpp | 2 +- src/gl/scene/gl_skydome.cpp | 4 ++-- src/gl/shaders/gl_shader.cpp | 5 +++-- src/gl/shaders/gl_shader.h | 1 + wadsrc/static/shaders/glsl/main.vp | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 917170872..6f5b9be14 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -136,7 +136,7 @@ bool FRenderState::ApplyShader() } } - glColor4fv(mColor.vec); + glVertexAttrib4fv(VATTR_COLOR, mColor.vec); activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 240bf6762..c54fb8c16 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -82,10 +82,10 @@ FSkyVertexBuffer::FSkyVertexBuffer() glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); + glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); + glEnableVertexAttribArray(VATTR_COLOR); glBindVertexArray(0); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 4373955c2..ba3db27ea 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -120,6 +120,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * fp_comb.Substitute("vec4 frag = ProcessTexel();", "vec4 frag = Process(vec4(1.0));"); } fp_comb << pp_data.GetString().GetChars(); + fp_comb.Substitute("gl_TexCoord[0]", "vTexCoord"); // fix old custom shaders. if (pp_data.GetString().IndexOf("ProcessLight") < 0) { @@ -156,6 +157,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * glAttachShader(hShader, hVertProg); glAttachShader(hShader, hFragProg); + glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); + glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); glLinkProgram(hShader); @@ -213,8 +216,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); - glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); - glUseProgram(hShader); int texture_index = glGetUniformLocation(hShader, "texture2"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index bed37cbb0..2e0731346 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -9,6 +9,7 @@ extern bool gl_shaderactive; enum { + VATTR_COLOR = 14, VATTR_VERTEX2 = 15 }; diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index e1349857e..8a1709ecf 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -1,4 +1,5 @@ +in vec4 aColor; #ifndef SIMPLE // we do not need these for simple shaders in vec4 aVertex2; out vec4 pixelpos; @@ -43,7 +44,7 @@ void main() vec4 eyeCoordPos = ViewMatrix * worldcoord; - vColor = gl_Color; + vColor = aColor; #ifndef SIMPLE pixelpos.xyz = worldcoord.xyz;