From e5f88a9883adfe5316458e7db81c0f252ed14f26 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 8 Aug 2016 16:18:07 +0200 Subject: [PATCH] - fixed: The textured automap was not using correct light levels. In order for the externally passed vertex attribute to work the buffer's color attrib array needs to be disabled for these. --- src/gl/data/gl_vertexbuffer.cpp | 27 +++++++++++++++++++++++++++ src/gl/data/gl_vertexbuffer.h | 1 + src/gl/renderer/gl_2ddrawer.cpp | 13 +++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 8e27c34fe6..2faae2990b 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -96,6 +96,33 @@ void FSimpleVertexBuffer::BindVBO() } } +void FSimpleVertexBuffer::EnableColorArray(bool on) +{ + if (on) + { + if (gl.glslversion > 0) + { + glEnableVertexAttribArray(VATTR_COLOR); + } + else + { + glEnableClientState(GL_COLOR_ARRAY); + } + } + else + { + if (gl.glslversion > 0) + { + glDisableVertexAttribArray(VATTR_COLOR); + } + else + { + glDisableClientState(GL_COLOR_ARRAY); + } + } +} + + void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) { glBindBuffer(GL_ARRAY_BUFFER, vbo_id); diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 31251653d1..4d2252fe01 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -67,6 +67,7 @@ public: } void BindVBO(); void set(FSimpleVertex *verts, int count); + void EnableColorArray(bool on); }; class FFlatVertexBuffer : public FVertexBuffer diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index 75f76bbe69..67cb5f2f47 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -384,6 +384,8 @@ void F2DDrawer::AddPixel(int x1, int y1, int palcolor, uint32 color) void F2DDrawer::Flush() { + F2DDrawer::EDrawType lasttype = DrawTypeTexture; + if (mData.Size() == 0) return; SBYTE savedlightmode = glset.lightmode; // lightmode is only relevant for automap subsectors, @@ -394,6 +396,17 @@ void F2DDrawer::Flush() for (unsigned i = 0; i < mData.Size();) { DataGeneric *dg = (DataGeneric *)&mData[i]; + // DrawTypePoly may not use the color part of the vertex buffer because it needs to use gl_SetColor to produce proper output. + if (lasttype == DrawTypePoly && dg->mType != DrawTypePoly) + { + EnableColorArray(true); + } + else if (lasttype != DrawTypePoly && dg->mType == DrawTypePoly) + { + EnableColorArray(false); + } + lasttype = dg->mType; + switch (dg->mType) { default: