diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index d9d96c855..a1d553e15 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -115,9 +115,9 @@ FFlatVertexBuffer::FFlatVertexBuffer() glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); - glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); + glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableVertexAttribArray(VATTR_TEXCOORD); glBindVertexArray(0); } @@ -140,6 +140,7 @@ CVAR(Bool, gl_testbuffer, false, 0) void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) { +#if 0 if (!gl_testbuffer) // todo: remove the immediate mode calls once the uniform array method has been tested. { glBegin(primtype); @@ -151,6 +152,7 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs glEnd(); } else +#endif { if (count > 20) { diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 3ea25aead..e779cb0c9 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -117,7 +117,7 @@ FModelVertexBuffer::FModelVertexBuffer() glBufferData(GL_ELEMENT_ARRAY_BUFFER,ibo_shadowdata.Size() * sizeof(unsigned int), &ibo_shadowdata[0], GL_STATIC_DRAW); glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_VERTEX2); glBindVertexArray(0); } @@ -141,7 +141,7 @@ FModelVertexBuffer::~FModelVertexBuffer() unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, float factor) { glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); return frame1; } diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index c54fb8c16..0b902bba0 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -81,10 +81,10 @@ FSkyVertexBuffer::FSkyVertexBuffer() glBindVertexArray(vao_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); - glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableVertexAttribArray(VATTR_TEXCOORD); glEnableVertexAttribArray(VATTR_COLOR); glBindVertexArray(0); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ba3db27ea..86f4ec928 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -157,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_TEXCOORD, "aTexCoord"); glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 2e0731346..6675e235e 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -9,8 +9,10 @@ extern bool gl_shaderactive; enum { - VATTR_COLOR = 14, - VATTR_VERTEX2 = 15 + VATTR_VERTEX = 0, + VATTR_TEXCOORD = 1, + VATTR_COLOR = 2, + VATTR_VERTEX2 = 3 }; diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 8a1709ecf..7c62f77f8 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -1,4 +1,5 @@ +in vec2 aTexCoord; in vec4 aColor; #ifndef SIMPLE // we do not need these for simple shaders in vec4 aVertex2; @@ -15,26 +16,23 @@ uniform float fakeVB[100]; void main() { - -#ifdef UNIFORM_VB vec4 vert; vec4 tc; + +#ifdef UNIFORM_VB if (gl_MultiTexCoord0.x >= 100000.0) { - int fakeVI = int(gl_MultiTexCoord0.y)*5; + int fakeVI = int(aTexCoord.y)*5; vert = gl_Vertex + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0); tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0); } else +#endif { vert = gl_Vertex; - tc = gl_MultiTexCoord0; + tc = vec4(aTexCoord, 0.0, 0.0); } -#else - #define vert gl_Vertex - #define tc gl_MultiTexCoord0 -#endif #ifndef SIMPLE vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor);