diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 46313df809..0066db4b01 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -472,16 +472,14 @@ public: void BindVBO() override { // set up the vertex buffer for drawing the 2D elements. - glGenBuffers(1, &vbo_id); - glGenBuffers(1, &ibo_id); - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSimpleVertex), &TDiO->x); glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSimpleVertex), &TDiO->u); glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSimpleVertex), &TDiO->color0); glEnableVertexAttribArray(VATTR_VERTEX); glEnableVertexAttribArray(VATTR_TEXCOORD); - glEnableVertexAttribArray(VATTR_COLOR); + //glEnableVertexAttribArray(VATTR_COLOR); glDisableVertexAttribArray(VATTR_VERTEX2); glDisableVertexAttribArray(VATTR_NORMAL); } @@ -506,6 +504,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer) { // Change from BGRA to RGBA std::swap(v.color0.r, v.color0.b); + v.color0 = 0xffffffff; } auto vb = new F2DVertexBuffer; vb->UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size()); @@ -514,7 +513,6 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer) for(auto &cmd : commands) { - gl_RenderState.ResetColor(); // this is needed to reset the desaturation. int tm, sb, db, be; // The texture mode being returned here cannot be used, because the higher level code // already manipulated the data so that some cases will not be handled correctly. @@ -565,6 +563,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer) gl_RenderState.SetFixedColormap(CM_PLAIN2D); } } + gl_RenderState.SetColor(1, 1, 1, 1, cmd.mDesaturate); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); @@ -584,26 +583,26 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer) gl_RenderState.EnableTexture(false); } gl_RenderState.Apply(); - glDrawElements(GL_TRIANGLES, cmd.mIndexCount, GL_UNSIGNED_INT, (const void *)(cmd.mIndexIndex * sizeof(unsigned int))); + glDrawArrays(GL_TRIANGLE_STRIP, cmd.mVertIndex, 4); + //glDrawElements(GL_TRIANGLES, cmd.mIndexCount, GL_UNSIGNED_INT, (const void *)(cmd.mIndexIndex * sizeof(unsigned int))); break; case F2DDrawer::DrawTypeLines: gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); glDrawArrays(GL_LINES, cmd.mVertIndex, cmd.mVertCount); - gl_RenderState.EnableTexture(true); break; case F2DDrawer::DrawTypePoints: gl_RenderState.EnableTexture(false); gl_RenderState.Apply(); glDrawArrays(GL_POINTS, cmd.mVertIndex, cmd.mVertCount); - gl_RenderState.EnableTexture(true); break; } } glDisable(GL_SCISSOR_TEST); gl_RenderState.SetVertexBuffer(nullptr); + gl_RenderState.EnableTexture(true); delete vb; } \ No newline at end of file diff --git a/src/v_2ddrawer.h b/src/v_2ddrawer.h index 578f4498b2..6b47403653 100644 --- a/src/v_2ddrawer.h +++ b/src/v_2ddrawer.h @@ -46,7 +46,7 @@ public: float u, v; PalEntry color0; - void Set(float xx, float zz, float yy) + void Set(float xx, float yy, float zz) { x = xx; z = zz; @@ -56,7 +56,7 @@ public: color0 = 0; } - void Set(double xx, double zz, double yy, double uu, double vv, PalEntry col) + void Set(double xx, double yy, double zz, double uu, double vv, PalEntry col) { x = (float)xx; z = (float)zz; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 04e16ff42d..aacaef7cbd 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -193,6 +193,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawTexture) void DFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) { + m2DDrawer.AddTexture(img, parms); } //==========================================================================