From 1598fa762ae2d3d525fe56c88de349a08a167b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sun, 23 Apr 2017 17:01:13 +0300 Subject: [PATCH] OpenGL|Client: Adapting old drawing code for OpenGL 3.3 --- doomsday/apps/api/api_gl.h | 1 - doomsday/apps/client/include/gl/gl_main.h | 2 + .../renderer.pack/shaders/dgl/dgl.dei | 4 +- .../renderer.pack/shaders/dgl/dgl_draw.vsh | 2 +- doomsday/apps/client/src/gl/dgl_common.cpp | 29 +- doomsday/apps/client/src/gl/dgl_draw.cpp | 97 ++++-- doomsday/apps/client/src/gl/gl_main.cpp | 5 +- .../apps/client/src/gl/texturecontent.cpp | 281 ++++++++++-------- doomsday/apps/client/src/render/rend_font.cpp | 2 +- doomsday/apps/client/src/ui/busyvisual.cpp | 10 +- .../apps/client/src/world/base/blockmap.cpp | 4 +- 11 files changed, 267 insertions(+), 170 deletions(-) diff --git a/doomsday/apps/api/api_gl.h b/doomsday/apps/api/api_gl.h index 98b104ebbb..63b0e064be 100644 --- a/doomsday/apps/api/api_gl.h +++ b/doomsday/apps/api/api_gl.h @@ -126,7 +126,6 @@ typedef enum dglprimtype_e { DGL_TRIANGLE_FAN, DGL_TRIANGLE_STRIP, DGL_QUADS, - DGL_QUAD_STRIP, DGL_POINTS, } dglprimtype_t; diff --git a/doomsday/apps/client/include/gl/gl_main.h b/doomsday/apps/client/include/gl/gl_main.h index 5d8b9d3adc..a7e6565169 100644 --- a/doomsday/apps/client/include/gl/gl_main.h +++ b/doomsday/apps/client/include/gl/gl_main.h @@ -318,6 +318,8 @@ void GL_CalcLuminance(uint8_t const *buffer, int width, int height, int comps, void DGL_AssertNotInPrimitive(void); de::Matrix4f DGL_Matrix(DGLenum matrixMode); +void DGL_CurrentColor(DGLubyte *rgba); +void DGL_CurrentColor(float *rgba); // Console commands. D_CMD(UpdateGammaRamp); diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei index a6bc55c1c0..3fad05a668 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei @@ -1,5 +1,5 @@ # Shader for the DGL drawing routines that emulate OpenGL 1.x behavior. shader dgl.draw { - vertex.path = "dgl_draw.vsh" - fragment.path = "dgl_draw.fsh" + path.vertex = "dgl_draw.vsh" + path.fragment = "dgl_draw.fsh" } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh index b1d6789014..7d35530735 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh @@ -20,7 +20,7 @@ #version 330 -layout(location = 0) in vec3 aVertex; +layout(location = 0) in vec4 aVertex; layout(location = 1) in vec4 aColor; layout(location = 2) in vec2 aTexCoord[3]; diff --git a/doomsday/apps/client/src/gl/dgl_common.cpp b/doomsday/apps/client/src/gl/dgl_common.cpp index b90899f582..3713a8b952 100644 --- a/doomsday/apps/client/src/gl/dgl_common.cpp +++ b/doomsday/apps/client/src/gl/dgl_common.cpp @@ -458,28 +458,28 @@ dd_bool DGL_GetIntegerv(int name, int *v) break; case DGL_CURRENT_COLOR_R: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = int(color[0] * 255); break; case DGL_CURRENT_COLOR_G: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = int(color[1] * 255); break; case DGL_CURRENT_COLOR_B: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = int(color[2] * 255); break; case DGL_CURRENT_COLOR_A: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = int(color[3] * 255); break; case DGL_CURRENT_COLOR_RGBA: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); - for(int i = 0; i < 4; ++i) + DGL_CurrentColor(color); + for (int i = 0; i < 4; ++i) { v[i] = int(color[i] * 255); } @@ -530,31 +530,31 @@ dd_bool DGL_GetFloatv(int name, float *v) DENG_ASSERT_GL_CONTEXT_ACTIVE(); float color[4]; - switch(name) + switch (name) { case DGL_CURRENT_COLOR_R: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = color[0]; break; case DGL_CURRENT_COLOR_G: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = color[1]; break; case DGL_CURRENT_COLOR_B: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = color[2]; break; case DGL_CURRENT_COLOR_A: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); + DGL_CurrentColor(color); *v = color[3]; break; case DGL_CURRENT_COLOR_RGBA: - LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, color); - for(int i = 0; i < 4; ++i) + DGL_CurrentColor(color); + for (int i = 0; i < 4; ++i) { v[i] = color[i]; } @@ -651,7 +651,8 @@ int DGL_Enable(int cap) break; case DGL_POINT_SMOOTH: - Deferred_glEnable(GL_POINT_SMOOTH); + //Deferred_glEnable(GL_POINT_SMOOTH); + // TODO: Not needed? break; default: diff --git a/doomsday/apps/client/src/gl/dgl_draw.cpp b/doomsday/apps/client/src/gl/dgl_draw.cpp index 97c5472857..a86fa10eb8 100644 --- a/doomsday/apps/client/src/gl/dgl_draw.cpp +++ b/doomsday/apps/client/src/gl/dgl_draw.cpp @@ -59,8 +59,8 @@ struct DGLDrawState NUM_VERTEX_ATTRIB_ARRAYS }; - int primLevel = 0; - dglprimtype_t currentPrimitive = DGL_NO_PRIMITIVE; + dglprimtype_t primType = DGL_NO_PRIMITIVE; + int primIndex = 0; QVector vertices; struct GLData @@ -70,6 +70,7 @@ struct DGLDrawState GLUniform uTextureMatrix { "uTextureMatrix", GLUniform::Mat4 }; GLUniform uEnabledTextures { "uEnabledTextures", GLUniform::Int }; GLuint vertexArray = 0; + GLBuffer buffer; }; std::unique_ptr gl; @@ -81,12 +82,39 @@ struct DGLDrawState void commitVertex() { vertices.append(vertices.last()); + ++primIndex; + + if (primType == DGL_QUADS) + { + if (primIndex == 4) + { + // 4 vertices become 6. + // + // 0--1 0--1 5 + // | | => \ | |\ + // | | \| | \ + // 3--2 2 4--3 + + vertices.append(vertices.last()); + vertices.append(vertices.last()); + + // 0 1 2 3 3 3 X + int const N = vertices.size(); + vertices[N - 4] = vertices[N - 5]; + vertices[N - 2] = vertices[N - 7]; + + primIndex = 0; + } + } } void clearVertices() { + Vertex const last = (vertices.isEmpty()? Vertex() : vertices.last()); vertices.clear(); - vertices.append(Vertex()); + vertices.append(last); + primIndex = 0; + primType = DGL_NO_PRIMITIVE; } int numVertices() const @@ -111,21 +139,16 @@ struct DGLDrawState void beginPrimitive(dglprimtype_t primitive) { - // We enter a Begin/End section. - primLevel++; + DENG2_ASSERT(primType == DGL_NO_PRIMITIVE); - DENG2_ASSERT(currentPrimitive == DGL_NO_PRIMITIVE); - currentPrimitive = primitive; + // We enter a Begin/End section. + primType = primitive; } void endPrimitive() { - DENG2_ASSERT(primLevel > 0); - DENG2_ASSERT(currentPrimitive != DGL_NO_PRIMITIVE); - - if (primLevel > 0) + if (primType != DGL_NO_PRIMITIVE) { - primLevel--; drawPrimitives(); } clearVertices(); @@ -175,36 +198,46 @@ struct DGLDrawState uint const stride = sizeof(Vertex); auto &GL = LIBGUI_GL; + // Upload the vertex data. + gl->buffer.setData(&vertices[0], sizeof(Vertex) * vertices.size(), gl::Dynamic); + GL.glBindVertexArray(gl->vertexArray); + LIBGUI_ASSERT_GL_OK(); - // Updated pointers. - GL.glVertexAttribPointer(VAA_VERTEX, 3, GL_FLOAT, GL_FALSE, stride, &vertices[0].vertex); - GL.glVertexAttribPointer(VAA_COLOR, 4, GL_UNSIGNED_BYTE, GL_FALSE, stride, &vertices[0].color); - GL.glVertexAttribPointer(VAA_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, stride, &vertices[0].texCoord[0]); - GL.glVertexAttribPointer(VAA_TEXCOORD1, 2, GL_FLOAT, GL_FALSE, stride, &vertices[0].texCoord[1]); - GL.glVertexAttribPointer(VAA_TEXCOORD2, 2, GL_FLOAT, GL_FALSE, stride, &vertices[0].texCoord[2]); + GL.glBindBuffer(GL_ARRAY_BUFFER, gl->buffer.glName()); + LIBGUI_ASSERT_GL_OK(); + + Vertex const *basePtr = nullptr; + // 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_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]); LIBGUI_ASSERT_GL_OK(); + + GL.glBindBuffer(GL_ARRAY_BUFFER, 0); } void glUnbindArrays() { LIBGUI_GL.glBindVertexArray(0); + LIBGUI_ASSERT_GL_OK(); } GLenum glPrimitive() const { - switch (currentPrimitive) + switch (primType) { case DGL_POINTS: return GL_POINTS; case DGL_LINES: return GL_LINES; case DGL_LINE_LOOP: return GL_LINE_LOOP; case DGL_LINE_STRIP: return GL_LINE_STRIP; - case DGL_QUADS: return GL_QUADS; - case DGL_QUAD_STRIP: return GL_QUAD_STRIP; case DGL_TRIANGLES: return GL_TRIANGLES; case DGL_TRIANGLE_FAN: return GL_TRIANGLE_FAN; case DGL_TRIANGLE_STRIP: return GL_TRIANGLE_STRIP; + case DGL_QUADS: return GL_TRIANGLES; // converted case DGL_NO_PRIMITIVE: DENG2_ASSERT(!"No primitive type specified"); return GL_NONE; } @@ -227,6 +260,7 @@ struct DGLDrawState { glBindArrays(); LIBGUI_GL.glDrawArrays(glPrimitive(), 0, numVertices()); + LIBGUI_ASSERT_GL_OK(); glUnbindArrays(); } gl->shader.endUse(); @@ -235,6 +269,17 @@ struct DGLDrawState static DGLDrawState dglDraw; +void DGL_CurrentColor(DGLubyte *rgba) +{ + std::memcpy(rgba, dglDraw.vertex().color.constPtr(), 4); +} + +void DGL_CurrentColor(float *rgba) +{ + Vector4f colorf = dglDraw.vertex().color.toVector4f() / 255.0; + std::memcpy(rgba, colorf.constPtr(), sizeof(float) * 4); +} + #undef DGL_Color3ub DENG_EXTERN_C void DGL_Color3ub(DGLubyte r, DGLubyte g, DGLubyte b) { @@ -401,8 +446,7 @@ DENG_EXTERN_C void DGL_Vertices3fctv(int num, const dgl_fct3vertex_t* vec) #undef DGL_Begin DENG_EXTERN_C void DGL_Begin(dglprimtype_t mode) { - if(novideo) - return; + if (novideo) return; DENG_ASSERT_IN_MAIN_THREAD(); DENG_ASSERT_GL_CONTEXT_ACTIVE(); @@ -412,14 +456,13 @@ DENG_EXTERN_C void DGL_Begin(dglprimtype_t mode) void DGL_AssertNotInPrimitive(void) { - DENG_ASSERT(dglDraw.currentPrimitive == DGL_NO_PRIMITIVE); + DENG_ASSERT(dglDraw.primType == DGL_NO_PRIMITIVE); } #undef DGL_End DENG_EXTERN_C void DGL_End(void) { - if(novideo) - return; + if (novideo) return; DENG_ASSERT_IN_MAIN_THREAD(); DENG_ASSERT_GL_CONTEXT_ACTIVE(); @@ -437,7 +480,7 @@ DENG_EXTERN_C void DGL_DrawLine(float x1, float y1, float x2, float y2, float r, #undef DGL_DrawRect DENG_EXTERN_C void DGL_DrawRect(RectRaw const *rect) { - if(!rect) return; + if (!rect) return; GL_DrawRect(Rectanglei::fromSize(Vector2i(rect->origin.xy), Vector2ui(rect->size.width, rect->size.height))); } diff --git a/doomsday/apps/client/src/gl/gl_main.cpp b/doomsday/apps/client/src/gl/gl_main.cpp index 87b800c937..bc3d451381 100644 --- a/doomsday/apps/client/src/gl/gl_main.cpp +++ b/doomsday/apps/client/src/gl/gl_main.cpp @@ -855,6 +855,8 @@ void GL_BindTextureUnmanaged(GLuint glName, gl::Wrapping wrapS, gl::Wrapping wra { if(ClientApp::busyRunner().inWorkerThread()) return; + LIBGUI_ASSERT_GL_OK(); + if(glName == 0) { GL_SetNoTexture(); @@ -865,7 +867,7 @@ void GL_BindTextureUnmanaged(GLuint glName, gl::Wrapping wrapS, gl::Wrapping wra DENG_ASSERT_GL_CONTEXT_ACTIVE(); LIBGUI_GL.glBindTexture(GL_TEXTURE_2D, glName); - Sys_GLCheckError(); + LIBGUI_ASSERT_GL_OK(); LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_Wrap(wrapS)); LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_Wrap(wrapT)); @@ -874,6 +876,7 @@ void GL_BindTextureUnmanaged(GLuint glName, gl::Wrapping wrapS, gl::Wrapping wra { LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GL_GetTexAnisoMul(texAniso)); } + LIBGUI_ASSERT_GL_OK(); } void GL_Bind(GLTextureUnit const &glTU) diff --git a/doomsday/apps/client/src/gl/texturecontent.cpp b/doomsday/apps/client/src/gl/texturecontent.cpp index b9bc7a1bbe..b13ce84fd6 100644 --- a/doomsday/apps/client/src/gl/texturecontent.cpp +++ b/doomsday/apps/client/src/gl/texturecontent.cpp @@ -40,7 +40,7 @@ using namespace de; static int BytesPerPixelFmt(dgltexformat_t format) { - switch(format) + switch (format) { case DGL_LUMINANCE: case DGL_COLOR_INDEX_8: return 1; @@ -63,7 +63,7 @@ static int BytesPerPixelFmt(dgltexformat_t format) */ static int BytesPerPixel(GLint format) { - switch(format) + switch (format) { case GL_COLOR_INDEX: case GL_STENCIL_INDEX: @@ -128,7 +128,7 @@ texturecontent_t *GL_ConstructTextureContentCopy(texturecontent_t const *other) void GL_DestroyTextureContent(texturecontent_t *content) { DENG_ASSERT(content); - if(content->pixels) M_Free((uint8_t *)content->pixels); + if (content->pixels) M_Free((uint8_t *)content->pixels); M_Free(content); } @@ -150,9 +150,9 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, bool const monochrome = (spec.flags & TSF_MONOCHROME) != 0; bool const scaleSharp = (spec.flags & TSF_UPSCALE_AND_SHARPEN) != 0; - if(spec.toAlpha) + if (spec.toAlpha) { - if(0 != image.paletteId) + if (0 != image.paletteId) { // Paletted. uint8_t *newPixels = GL_ConvertBuffer(image.pixels, image.size.x, image.size.y, @@ -167,28 +167,28 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, Image_ConvertToLuminance(image, false /*discard alpha*/); long total = image.size.x * image.size.y; - for(long i = 0; i < total; ++i) + for (long i = 0; i < total; ++i) { image.pixels[total + i] = image.pixels[i]; image.pixels[i] = 255; } image.pixelSize = 2; } - else if(0 != image.paletteId) + else if (0 != image.paletteId) { - if(fillOutlines && (image.flags & IMGF_IS_MASKED)) + if (fillOutlines && (image.flags & IMGF_IS_MASKED)) { ColorOutlinesIdx(image.pixels, image.size.x, image.size.y); } - if(monochrome && !scaleSharp) + if (monochrome && !scaleSharp) { GL_DeSaturatePalettedImage(image.pixels, App_Resources().colorPalettes().colorPalette(image.paletteId), image.size.x, image.size.y); } - if(scaleSharp) + if (scaleSharp) { int scaleMethod = GL_ChooseSmartFilter(image.size.x, image.size.y, 0); bool origMasked = (image.flags & IMGF_IS_MASKED) != 0; @@ -197,7 +197,7 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, uint8_t *newPixels = GL_ConvertBuffer(image.pixels, image.size.x, image.size.y, ((image.flags & IMGF_IS_MASKED)? 2 : 1), image.paletteId, 4); - if(newPixels != image.pixels) + if (newPixels != image.pixels) { M_Free(image.pixels); image.pixels = newPixels; @@ -206,7 +206,7 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, image.flags &= ~IMGF_IS_MASKED; } - if(monochrome) + if (monochrome) { Desaturate(image.pixels, image.size.x, image.size.y, image.pixelSize); } @@ -215,7 +215,7 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, newPixels = GL_SmartFilter(scaleMethod, image.pixels, image.size.x, image.size.y, 0, &newWidth, &newHeight); image.size = Vector2ui(newWidth, newHeight); - if(newPixels != image.pixels) + if (newPixels != image.pixels) { M_Free(image.pixels); image.pixels = newPixels; @@ -226,7 +226,7 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, //BlackOutlines(image.pixels, image.size.x, image.size.y, image.pixelSize); // Back to paletted+alpha? - if(monochrome) + if (monochrome) { // No. We'll convert from RGB(+A) to Luminance(+A) and upload as is. // Replace the old buffer. @@ -239,13 +239,13 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, (origMasked? 2 : 1), origPaletteId, 4); - if(newPixels != image.pixels) + if (newPixels != image.pixels) { M_Free(image.pixels); image.pixels = newPixels; image.pixelSize = (origMasked? 2 : 1); image.paletteId = origPaletteId; - if(origMasked) + if (origMasked) { image.flags |= IMGF_IS_MASKED; } @@ -253,9 +253,9 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, } } } - else if(image.pixelSize > 2) + else if (image.pixelSize > 2) { - if(monochrome) + if (monochrome) { Image_ConvertToLuminance(image); AmplifyLuma(image.pixels, image.size.x, image.size.y, image.pixelSize == 2); @@ -265,11 +265,11 @@ static dgltexformat_t prepareImageAsTexture(image_t &image, /* * Choose the final GL texture format. */ - if(monochrome) + if (monochrome) { return image.pixelSize == 2? DGL_LUMINANCE_PLUS_A8 : DGL_LUMINANCE; } - if(image.paletteId) + if (image.paletteId) { return (image.flags & IMGF_IS_MASKED)? DGL_COLOR_INDEX_8_PLUS_A8 : DGL_COLOR_INDEX_8; } @@ -299,7 +299,7 @@ static dgltexformat_t prepareImageAsDetailTexture(image_t &image, DENG_UNUSED(spec); // We want a luminance map. - if(image.pixelSize > 2) + if (image.pixelSize > 2) { Image_ConvertToLuminance(image, false /*discard alpha*/); } @@ -323,7 +323,7 @@ void GL_PrepareTextureContent(texturecontent_t &c, GL_InitTextureContent(&c); c.name = glTexName; - switch(spec.type) + switch (spec.type) { case TST_GENERAL: { variantspecification_t const &vspec = spec.variant; @@ -342,12 +342,12 @@ void GL_PrepareTextureContent(texturecontent_t &c, c.pixels = image.pixels; c.paletteId = image.paletteId; - if(noCompression || (image.size.x < 128 || image.size.y < 128)) + if (noCompression || (image.size.x < 128 || image.size.y < 128)) c.flags |= TXCF_NO_COMPRESSION; - if(vspec.gammaCorrection) c.flags |= TXCF_APPLY_GAMMACORRECTION; - if(vspec.noStretch) c.flags |= TXCF_UPLOAD_ARG_NOSTRETCH; - if(vspec.mipmapped) c.flags |= TXCF_MIPMAP; - if(noSmartFilter) c.flags |= TXCF_UPLOAD_ARG_NOSMARTFILTER; + if (vspec.gammaCorrection) c.flags |= TXCF_APPLY_GAMMACORRECTION; + if (vspec.noStretch) c.flags |= TXCF_UPLOAD_ARG_NOSTRETCH; + if (vspec.mipmapped) c.flags |= TXCF_MIPMAP; + if (noSmartFilter) c.flags |= TXCF_UPLOAD_ARG_NOSMARTFILTER; c.magFilter = vspec.glMagFilter(); c.minFilter = vspec.glMinFilter(); @@ -365,7 +365,7 @@ void GL_PrepareTextureContent(texturecontent_t &c, // Determine the gray mipmap factor. int grayMipmapFactor = dspec.contrast; - if(baMul != 1 || hiMul != 1 || loMul != 1) + if (baMul != 1 || hiMul != 1 || loMul != 1) { // Integrate the normalization factor with contrast. float const hiContrast = 1 - 1. / hiMul; @@ -385,7 +385,7 @@ void GL_PrepareTextureContent(texturecontent_t &c, c.flags = TXCF_GRAY_MIPMAP | TXCF_UPLOAD_ARG_NOSMARTFILTER; // Disable compression? - if(image.size.x < 128 || image.size.y < 128) + if (image.size.x < 128 || image.size.y < 128) c.flags |= TXCF_NO_COMPRESSION; c.grayMipmap = grayMipmapFactor; @@ -416,36 +416,36 @@ static GLint ChooseTextureFormat(dgltexformat_t format, dd_bool allowCompression { dd_bool compress = (allowCompression && GL_state.features.texCompression); - switch(format) + switch (format) { case DGL_RGB: case DGL_COLOR_INDEX_8: - if(!compress) + if (!compress) return GL_RGB8; #if USE_TEXTURE_COMPRESSION_S3 - if(GLInfo::extensions().EXT_texture_compression_s3tc) + if (GLInfo::extensions().EXT_texture_compression_s3tc) return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; #endif return GL_COMPRESSED_RGB; case DGL_RGBA: case DGL_COLOR_INDEX_8_PLUS_A8: - if(!compress) + if (!compress) return GL_RGBA8; #if USE_TEXTURE_COMPRESSION_S3 - if(GLInfo::extensions().EXT_texture_compression_s3tc) + if (GLInfo::extensions().EXT_texture_compression_s3tc) return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; #endif return GL_COMPRESSED_RGBA; - case DGL_LUMINANCE: + /*case DGL_LUMINANCE: return !compress ? GL_LUMINANCE : GL_COMPRESSED_LUMINANCE; case DGL_LUMINANCE_PLUS_A8: - return !compress ? GL_LUMINANCE_ALPHA : GL_COMPRESSED_LUMINANCE_ALPHA; + return !compress ? GL_LUMINANCE_ALPHA : GL_COMPRESSED_LUMINANCE_ALPHA;*/ default: - App_Error("ChooseTextureFormat: Invalid source format %i.", (int) format); + DENG2_ASSERT(!"ChooseTextureFormat: Invalid texture source format"); return 0; // Unreachable. } } @@ -481,22 +481,22 @@ static dd_bool uploadTexture(int glFormat, int loadFormat, const uint8_t* pixels int mipLevel = 0; DENG_ASSERT(pixels); - if(!(GL_LUMINANCE_ALPHA == loadFormat || GL_LUMINANCE == loadFormat || + if (!(GL_LUMINANCE_ALPHA == loadFormat || GL_LUMINANCE == loadFormat || GL_RGB == loadFormat || GL_RGBA == loadFormat)) { throw Error("texturecontent_t::uploadTexture", "Unsupported load format " + String::number(loadFormat)); } // Can't operate on null texture. - if(width < 1 || height < 1) + if (width < 1 || height < 1) return false; // Check that the texture dimensions are valid. - if(width > GLInfo::limits().maxTexSize || height > GLInfo::limits().maxTexSize) + if (width > GLInfo::limits().maxTexSize || height > GLInfo::limits().maxTexSize) return false; // Negative indices signify a specific mipmap level is being uploaded. - if(genMipmaps < 0) + if (genMipmaps < 0) { mipLevel = -genMipmaps; genMipmaps = 0; @@ -508,47 +508,57 @@ static dd_bool uploadTexture(int glFormat, int loadFormat, const uint8_t* pixels auto &GL = LIBGUI_GL; // Automatic mipmap generation? - if (genMipmaps) + /*if (genMipmaps) { GL.glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - } + LIBGUI_ASSERT_GL_OK(); + }*/ //LIBGUI_GL.glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); GLint oldPixelStore[8]; for (int i = 0; i < 8; ++i) { GL.glGetIntegerv(properties[i], &oldPixelStore[i]); + LIBGUI_ASSERT_GL_OK(); } GL.glPixelStorei(GL_PACK_ROW_LENGTH, (GLint)packRowLength); + LIBGUI_ASSERT_GL_OK(); GL.glPixelStorei(GL_PACK_ALIGNMENT, (GLint)packAlignment); + LIBGUI_ASSERT_GL_OK(); GL.glPixelStorei(GL_PACK_SKIP_ROWS, (GLint)packSkipRows); + LIBGUI_ASSERT_GL_OK(); GL.glPixelStorei(GL_PACK_SKIP_PIXELS, (GLint)packSkipPixels); + LIBGUI_ASSERT_GL_OK(); GL.glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint)unpackRowLength); + LIBGUI_ASSERT_GL_OK(); GL.glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint)unpackAlignment); + LIBGUI_ASSERT_GL_OK(); GL.glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint)unpackSkipRows); + LIBGUI_ASSERT_GL_OK(); GL.glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint)unpackSkipPixels); + LIBGUI_ASSERT_GL_OK(); #if 0 - if(genMipmaps && !GLInfo::extensions().SGIS_generate_mipmap) + if (genMipmaps && !GLInfo::extensions().SGIS_generate_mipmap) { // Build all mipmap levels. int neww, newh, bpp, w, h; void* image, *newimage; bpp = BytesPerPixel(loadFormat); - if(bpp == 0) + if (bpp == 0) throw Error("texturecontent_t::uploadTexture", "Unknown GL format " + String::number(loadFormat)); GL_OptimalTextureSize(width, height, false, true, &w, &h); - if(w != width || h != height) + if (w != width || h != height) { // Must rescale image to get "top" mipmap texture image. image = GL_ScaleBufferEx(pixels, width, height, bpp, /*GL_UNSIGNED_BYTE,*/ unpackRowLength, unpackAlignment, unpackSkipRows, unpackSkipPixels, w, h, /*GL_UNSIGNED_BYTE,*/ packRowLength, packAlignment, packSkipRows, packSkipPixels); - if(!image) + if (!image) throw Error("texturecontent_t::uploadTexture", "Unknown error resizing mipmap level #0"); } else @@ -556,12 +566,12 @@ static dd_bool uploadTexture(int glFormat, int loadFormat, const uint8_t* pixels image = (void*) pixels; } - for(;;) + for (;;) { LIBGUI_GL.glTexImage2D(GL_TEXTURE_2D, mipLevel, (GLint)glFormat, w, h, 0, (GLint)loadFormat, GL_UNSIGNED_BYTE, image); - if(w == 1 && h == 1) + if (w == 1 && h == 1) break; ++mipLevel; @@ -571,10 +581,10 @@ static dd_bool uploadTexture(int glFormat, int loadFormat, const uint8_t* pixels unpackRowLength, unpackAlignment, unpackSkipRows, unpackSkipPixels, neww, newh, /*GL_UNSIGNED_BYTE,*/ packRowLength, packAlignment, packSkipRows, packSkipPixels); - if(!newimage) + if (!newimage) throw Error("texturecontent_t::uploadTexture", "Unknown error resizing mipmap level #" + String::number(mipLevel)); - if(image != pixels) + if (image != pixels) M_Free(image); image = newimage; @@ -582,14 +592,21 @@ static dd_bool uploadTexture(int glFormat, int loadFormat, const uint8_t* pixels h = newh; } - if(image != pixels) + if (image != pixels) M_Free(image); } else #endif { - LIBGUI_GL.glTexImage2D(GL_TEXTURE_2D, mipLevel, (GLint)glFormat, (GLsizei)width, - (GLsizei)height, 0, (GLint)loadFormat, GL_UNSIGNED_BYTE, pixels); + LIBGUI_GL.glTexImage2D(GL_TEXTURE_2D, mipLevel, GLint(glFormat), + GLsizei(width), GLsizei(height), 0, + GLenum(loadFormat), GL_UNSIGNED_BYTE, pixels); + LIBGUI_ASSERT_GL_OK(); + + if (genMipmaps) + { + LIBGUI_GL.glGenerateMipmap(GL_TEXTURE_2D); + } } //LIBGUI_GL.glPopClientAttrib(); @@ -597,6 +614,7 @@ static dd_bool uploadTexture(int glFormat, int loadFormat, const uint8_t* pixels for (int i = 0; i < 8; ++i) { GL.glPixelStorei(properties[i], oldPixelStore[i]); + LIBGUI_ASSERT_GL_OK(); } DENG_ASSERT(!Sys_GLCheckError()); @@ -623,7 +641,7 @@ static dd_bool uploadTextureGrayMipmap(int glFormat, int loadFormat, const uint8 float invFactor; DENG_ASSERT(pixels); - if(!(GL_RGB == loadFormat || GL_LUMINANCE == loadFormat)) + if (!(GL_RGB == loadFormat || GL_LUMINANCE == loadFormat)) { throw Error("texturecontent_t::uploadTextureGrayMipmap", "Unsupported load format " + String::number(loadFormat)); } @@ -631,11 +649,11 @@ static dd_bool uploadTextureGrayMipmap(int glFormat, int loadFormat, const uint8 pixelSize = (loadFormat == GL_LUMINANCE? 1 : 3); // Can't operate on null texture. - if(width < 1 || height < 1) + if (width < 1 || height < 1) return false; // Check that the texture dimensions are valid. - if(width > GLInfo::limits().maxTexSize || height > GLInfo::limits().maxTexSize) + if (width > GLInfo::limits().maxTexSize || height > GLInfo::limits().maxTexSize) return false; numLevels = GL_NumMipmapLevels(width, height); @@ -649,7 +667,7 @@ static dd_bool uploadTextureGrayMipmap(int glFormat, int loadFormat, const uint8 // Initial fading. in = pixels; out = image; - for(i = 0; i < numpels; ++i) + for (i = 0; i < numpels; ++i) { *out++ = (uint8_t) MINMAX_OF(0, (*in * grayFactor + 127 * invFactor), 255); in += pixelSize; @@ -662,14 +680,14 @@ static dd_bool uploadTextureGrayMipmap(int glFormat, int loadFormat, const uint8 // Generate all mipmaps levels. w = width; h = height; - for(i = 0; i < numLevels; ++i) + for (i = 0; i < numLevels; ++i) { GL_DownMipmap8(image, faded, w, h, (i * 1.75f) / numLevels); // Go down one level. - if(w > 1) + if (w > 1) w /= 2; - if(h > 1) + if (h > 1) h /= 2; LIBGUI_GL.glTexImage2D(GL_TEXTURE_2D, i + 1, glFormat, w, h, 0, (GLint)loadFormat, @@ -687,13 +705,13 @@ static dd_bool uploadTextureGrayMipmap(int glFormat, int loadFormat, const uint8 /// @note Texture parameters will NOT be set here! void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod method) { - if(method == gl::Deferred) + if (method == gl::Deferred) { GL_DeferTextureUpload(&content); return; } - if(novideo) return; + if (novideo) return; // Do this right away. No need to take a copy. bool generateMipmaps = (content.flags & (TXCF_MIPMAP|TXCF_GRAY_MIPMAP)) != 0; @@ -702,36 +720,38 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m bool noSmartFilter = (content.flags & TXCF_UPLOAD_ARG_NOSMARTFILTER) != 0; bool noStretch = (content.flags & TXCF_UPLOAD_ARG_NOSTRETCH) != 0; - int loadWidth = content.width, loadHeight = content.height; + int loadWidth = content.width; + int loadHeight = content.height; uint8_t const *loadPixels = content.pixels; - dgltexformat_t dglFormat = content.format; + dgltexformat_t dglFormat = content.format; - if(DGL_COLOR_INDEX_8 == dglFormat || DGL_COLOR_INDEX_8_PLUS_A8 == dglFormat) + // Convert a paletted source image to truecolor. + if (dglFormat == DGL_COLOR_INDEX_8 || dglFormat == DGL_COLOR_INDEX_8_PLUS_A8) { - // Convert a paletted source image to truecolor. uint8_t *newPixels = GL_ConvertBuffer(loadPixels, loadWidth, loadHeight, - DGL_COLOR_INDEX_8_PLUS_A8 == dglFormat ? 2 : 1, + dglFormat == DGL_COLOR_INDEX_8_PLUS_A8 ? 2 : 1, content.paletteId, - DGL_COLOR_INDEX_8_PLUS_A8 == dglFormat ? 4 : 3); - if(loadPixels != content.pixels) + dglFormat == DGL_COLOR_INDEX_8_PLUS_A8 ? 4 : 3); + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } loadPixels = newPixels; - dglFormat = DGL_COLOR_INDEX_8_PLUS_A8 == dglFormat ? DGL_RGBA : DGL_RGB; + dglFormat = (dglFormat == DGL_COLOR_INDEX_8_PLUS_A8 ? DGL_RGBA : DGL_RGB); } - if(DGL_RGBA == dglFormat || DGL_RGB == dglFormat) + // Gamma adjustment and smart filtering. + if (dglFormat == DGL_RGBA || dglFormat == DGL_RGB) { - int comps = (DGL_RGBA == dglFormat ? 4 : 3); + int comps = (dglFormat == DGL_RGBA ? 4 : 3); - if(applyTexGamma && texGamma > .0001f) + if (applyTexGamma && texGamma > .0001f) { uint8_t* dst, *localBuffer = 0; long const numPels = loadWidth * loadHeight; uint8_t const *src = loadPixels; - if(loadPixels == content.pixels) + if (loadPixels == content.pixels) { localBuffer = (uint8_t *) M_Malloc(comps * numPels); dst = localBuffer; @@ -741,21 +761,21 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m dst = const_cast(loadPixels); } - for(long i = 0; i < numPels; ++i) + for (long i = 0; i < numPels; ++i) { dst[CR] = R_TexGammaLut(src[CR]); dst[CG] = R_TexGammaLut(src[CG]); dst[CB] = R_TexGammaLut(src[CB]); - if(comps == 4) + if (comps == 4) dst[CA] = src[CA]; dst += comps; src += comps; } - if(localBuffer) + if (localBuffer) { - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } @@ -763,13 +783,13 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m } } - if(useSmartFilter && !noSmartFilter) + if (useSmartFilter && !noSmartFilter) { - if(comps == 3) + if (comps == 3) { // Need to add an alpha channel. uint8_t *newPixels = GL_ConvertBuffer(loadPixels, loadWidth, loadHeight, 3, 0, 4); - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } @@ -781,9 +801,9 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m loadPixels, loadWidth, loadHeight, ICF_UPSCALE_SAMPLE_WRAP, &loadWidth, &loadHeight); - if(filtered != loadPixels) + if (filtered != loadPixels) { - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } @@ -792,48 +812,73 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m } } - if(DGL_LUMINANCE_PLUS_A8 == dglFormat) + if (dglFormat == DGL_LUMINANCE && (content.flags & TXCF_CONVERT_8BIT_TO_ALPHA)) { // Needs converting. This adds some overhead. long const numPixels = content.width * content.height; - uint8_t *localBuffer = (uint8_t *) M_Malloc(2 * numPixels); + uint8_t *localBuffer = (uint8_t *) M_Malloc(4 * numPixels); + // Move the average color to the alpha channel, make the actual color white. uint8_t *pixel = localBuffer; - for(long i = 0; i < numPixels; ++i) + for (long i = 0; i < numPixels; ++i) { - pixel[0] = loadPixels[i]; - pixel[1] = loadPixels[numPixels + i]; - pixel += 2; + *pixel++ = 255; + *pixel++ = 255; + *pixel++ = 255; + *pixel++ = loadPixels[i]; } - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } loadPixels = localBuffer; + dglFormat = DGL_RGBA; } - - if(DGL_LUMINANCE == dglFormat && (content.flags & TXCF_CONVERT_8BIT_TO_ALPHA)) + else if (dglFormat == DGL_LUMINANCE) { // Needs converting. This adds some overhead. long const numPixels = content.width * content.height; - uint8_t *localBuffer = (uint8_t *) M_Malloc(2 * numPixels); + uint8_t *localBuffer = (uint8_t *) M_Malloc(3 * numPixels); // Move the average color to the alpha channel, make the actual color white. uint8_t *pixel = localBuffer; - for(long i = 0; i < numPixels; ++i) + for (long i = 0; i < numPixels; ++i) + { + *pixel++ = loadPixels[i]; + *pixel++ = loadPixels[i]; + *pixel++ = loadPixels[i]; + } + + if (loadPixels != content.pixels) + { + M_Free(const_cast(loadPixels)); + } + loadPixels = localBuffer; + dglFormat = DGL_RGB; + } + + if (dglFormat == DGL_LUMINANCE_PLUS_A8) + { + // Needs converting. This adds some overhead. + long const numPixels = content.width * content.height; + uint8_t *localBuffer = (uint8_t *) M_Malloc(4 * numPixels); + + uint8_t *pixel = localBuffer; + for (long i = 0; i < numPixels; ++i) { - pixel[0] = 255; - pixel[1] = loadPixels[i]; - pixel += 2; + *pixel++ = loadPixels[i]; + *pixel++ = loadPixels[i]; + *pixel++ = loadPixels[i]; + *pixel++ = loadPixels[numPixels + i]; } - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } loadPixels = localBuffer; - dglFormat = DGL_LUMINANCE_PLUS_A8; + dglFormat = DGL_RGBA; } // Calculate the final dimensions for the texture, as required by @@ -844,23 +889,23 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m &loadWidth, &loadHeight); // Do we need to resize? - if(width != loadWidth || height != loadHeight) + if (width != loadWidth || height != loadHeight) { int comps = BytesPerPixelFmt(dglFormat); - if(noStretch) + if (noStretch) { // Copy the texture into a power-of-two canvas. uint8_t *localBuffer = (uint8_t *) M_Calloc(comps * loadWidth * loadHeight); // Copy line by line. - for(int i = 0; i < height; ++i) + for (int i = 0; i < height; ++i) { std::memcpy(localBuffer + loadWidth * comps * i, loadPixels + width * comps * i, comps * width); } - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } @@ -871,7 +916,7 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m // Stretch into a new power-of-two texture. uint8_t *newPixels = GL_ScaleBuffer(loadPixels, width, height, comps, loadWidth, loadHeight); - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } @@ -887,16 +932,18 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, content.magFilter); LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, content.wrap[0]); LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, content.wrap[1]); - if(GL_state.features.texFilterAniso) + if (GL_state.features.texFilterAniso) LIBGUI_GL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GL_GetTexAnisoMul(content.anisoFilter)); - if(!(content.flags & TXCF_GRAY_MIPMAP)) + DENG2_ASSERT(dglFormat == DGL_RGB || dglFormat == DGL_RGBA); + + if (!(content.flags & TXCF_GRAY_MIPMAP)) { GLint loadFormat; - switch(dglFormat) + switch (dglFormat) { - case DGL_LUMINANCE_PLUS_A8: loadFormat = GL_LUMINANCE_ALPHA; break; - case DGL_LUMINANCE: loadFormat = GL_LUMINANCE; break; + //case DGL_LUMINANCE_PLUS_A8: loadFormat = GL_LUMINANCE_ALPHA; break; + //case DGL_LUMINANCE: loadFormat = GL_LUMINANCE; break; case DGL_RGB: loadFormat = GL_RGB; break; case DGL_RGBA: loadFormat = GL_RGBA; break; default: @@ -905,7 +952,7 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m GLint glFormat = ChooseTextureFormat(dglFormat, !noCompression); - if(!uploadTexture(glFormat, loadFormat, loadPixels, loadWidth, loadHeight, + if (!uploadTexture(glFormat, loadFormat, loadPixels, loadWidth, loadHeight, generateMipmaps ? true : false)) { throw Error("GL_UploadTextureContent", QString("TexImage failed (%1:%2 fmt%3)") @@ -919,18 +966,18 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m // Special fade-to-gray luminance texture (used for details). GLint glFormat, loadFormat; - switch(dglFormat) + switch (dglFormat) { - case DGL_LUMINANCE: loadFormat = GL_LUMINANCE; break; + //case DGL_LUMINANCE: loadFormat = GL_LUMINANCE; break; case DGL_RGB: loadFormat = GL_RGB; break; default: throw Error("GL_UploadTextureContent", QString("Unknown format %1").arg(int(dglFormat))); } - glFormat = ChooseTextureFormat(DGL_LUMINANCE, !noCompression); + glFormat = ChooseTextureFormat(dglFormat, !noCompression); - if(!uploadTextureGrayMipmap(glFormat, loadFormat, loadPixels, loadWidth, loadHeight, - content.grayMipmap * reciprocal255)) + if (!uploadTextureGrayMipmap(glFormat, loadFormat, loadPixels, loadWidth, loadHeight, + content.grayMipmap * reciprocal255)) { throw Error("GL_UploadTextureContent", QString("TexImageGrayMipmap failed (%1:%2 fmt%3)") .arg(content.name) @@ -939,7 +986,7 @@ void GL_UploadTextureContent(texturecontent_t const &content, gl::UploadMethod m } } - if(loadPixels != content.pixels) + if (loadPixels != content.pixels) { M_Free(const_cast(loadPixels)); } diff --git a/doomsday/apps/client/src/render/rend_font.cpp b/doomsday/apps/client/src/render/rend_font.cpp index e66614f1f9..def1819b7d 100644 --- a/doomsday/apps/client/src/render/rend_font.cpp +++ b/doomsday/apps/client/src/render/rend_font.cpp @@ -1270,7 +1270,7 @@ void FR_DrawText3(const char* text, const Point2Raw* _origin, int alignFlags, sh auto &GL = LIBGUI_GL; // We need to change the current color, so remember for restore. - GL.glGetFloatv(GL_CURRENT_COLOR, origColor); + DGL_CurrentColor(origColor); for(pass = ((_textFlags & DTF_NO_SHADOW) != 0? 1 : 0); pass < ((_textFlags & DTF_NO_GLITTER) != 0? 2 : 3); ++pass) diff --git a/doomsday/apps/client/src/ui/busyvisual.cpp b/doomsday/apps/client/src/ui/busyvisual.cpp index 60931e7393..c00844f1fd 100644 --- a/doomsday/apps/client/src/ui/busyvisual.cpp +++ b/doomsday/apps/client/src/ui/busyvisual.cpp @@ -187,15 +187,15 @@ void Con_DrawTransition(void) x = 0; s = 0; - DGL_Begin(DGL_QUAD_STRIP); + DGL_Begin(DGL_TRIANGLE_STRIP); for (i = 0; i <= SCREENWIDTH; ++i, x++, s += colWidth) { y = doomWipeSamples[i]; - DGL_Color4f(1, 1, 1, topAlpha); - DGL_TexCoord2f(0, s, 1); DGL_Vertex2f(x, y); DGL_Color4f(1, 1, 1, 1); DGL_TexCoord2f(0, s, div); DGL_Vertex2f(x, y + h); + DGL_Color4f(1, 1, 1, topAlpha); + DGL_TexCoord2f(0, s, 1); DGL_Vertex2f(x, y); } DGL_End(); @@ -203,13 +203,13 @@ void Con_DrawTransition(void) s = 0; DGL_Color4f(1, 1, 1, 1); - DGL_Begin(DGL_QUAD_STRIP); + DGL_Begin(DGL_TRIANGLE_STRIP); for (i = 0; i <= SCREENWIDTH; ++i, x++, s += colWidth) { y = doomWipeSamples[i] + h; - DGL_TexCoord2f(0, s, div); DGL_Vertex2f(x, y); DGL_TexCoord2f(0, s, 0); DGL_Vertex2f(x, y + (SCREENHEIGHT - h)); + DGL_TexCoord2f(0, s, div); DGL_Vertex2f(x, y); } DGL_End(); break; diff --git a/doomsday/apps/client/src/world/base/blockmap.cpp b/doomsday/apps/client/src/world/base/blockmap.cpp index 2d2faa55a5..6d1098d15e 100644 --- a/doomsday/apps/client/src/world/base/blockmap.cpp +++ b/doomsday/apps/client/src/world/base/blockmap.cpp @@ -24,6 +24,7 @@ #ifdef __CLIENT__ # include # include "api_gl.h" +# include "gl/gl_main.h" #endif #include @@ -728,7 +729,8 @@ void Blockmap::drawDebugVisual() const #define UNIT_SIZE 1 // We'll be changing the color, so query the current and restore later. - GLfloat oldColor[4]; LIBGUI_GL.glGetFloatv(GL_CURRENT_COLOR, oldColor); + GLfloat oldColor[4]; + DGL_CurrentColor(oldColor); /* * Draw the Quadtree.