Skip to content

Commit

Permalink
Fixed|OpenGL|Client: Vertex color normalization and DGL shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Apr 23, 2017
1 parent 1598fa7 commit 9195cbd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doomsday/apps/client/include/gl/gl_main.h
Expand Up @@ -315,8 +315,8 @@ void GL_CalcLuminance(uint8_t const *buffer, int width, int height, int comps,
colorpaletteid_t paletteId, float *brightX, float *brightY,
struct ColorRawf_s *color, float *lumSize);

void DGL_Shutdown();
void DGL_AssertNotInPrimitive(void);

de::Matrix4f DGL_Matrix(DGLenum matrixMode);
void DGL_CurrentColor(DGLubyte *rgba);
void DGL_CurrentColor(float *rgba);
Expand Down
17 changes: 14 additions & 3 deletions doomsday/apps/client/src/gl/dgl_draw.cpp
Expand Up @@ -91,8 +91,8 @@ struct DGLDrawState
// 4 vertices become 6.
//
// 0--1 0--1 5
// | | => \ | |\
// | | \| | \
// | | \ | |\
// | | => \| | \
// 3--2 2 4--3

vertices.append(vertices.last());
Expand Down Expand Up @@ -193,6 +193,12 @@ struct DGLDrawState
}
}

void glDeinit()
{
LIBGUI_GL.glDeleteVertexArrays(1, &gl->vertexArray);
gl.reset();
}

void glBindArrays()
{
uint const stride = sizeof(Vertex);
Expand All @@ -211,7 +217,7 @@ struct DGLDrawState

// Updated pointers.
GL.glVertexAttribPointer(VAA_VERTEX, 3, GL_FLOAT, GL_FALSE, stride, &basePtr->vertex);
GL.glVertexAttribPointer(VAA_COLOR, 4, GL_UNSIGNED_BYTE, GL_FALSE, stride, &basePtr->color);
GL.glVertexAttribPointer(VAA_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, &basePtr->color);
GL.glVertexAttribPointer(VAA_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, stride, &basePtr->texCoord[0]);
GL.glVertexAttribPointer(VAA_TEXCOORD1, 2, GL_FLOAT, GL_FALSE, stride, &basePtr->texCoord[1]);
GL.glVertexAttribPointer(VAA_TEXCOORD2, 2, GL_FLOAT, GL_FALSE, stride, &basePtr->texCoord[2]);
Expand Down Expand Up @@ -269,6 +275,11 @@ struct DGLDrawState

static DGLDrawState dglDraw;

void DGL_Shutdown()
{
dglDraw.glDeinit();
}

void DGL_CurrentColor(DGLubyte *rgba)
{
std::memcpy(rgba, dglDraw.vertex().color.constPtr(), 4);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/gl/gl_main.cpp
Expand Up @@ -337,8 +337,8 @@ void GL_Shutdown()
Rend_ModelShutdown();
LensFx_Shutdown();
Rend_Reset();

GL_ShutdownRefresh();
DGL_Shutdown();

// Shutdown OpenGL.
Sys_GLShutdown();
Expand Down

0 comments on commit 9195cbd

Please sign in to comment.