diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 85af00357..31f6f4f0c 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -68,7 +68,7 @@ static GLenum createFBO(GLuint &framebuffer, TextureType texType, PixelFormat fo if (isPixelFormatDepthStencil(format)) { - glClearDepth(1.0); + gl.clearDepth(1.0); glClearStencil(0); glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } @@ -128,7 +128,7 @@ static bool createRenderbuffer(int width, int height, int &samples, PixelFormat { if (isPixelFormatDepthStencil(pixelformat)) { - glClearDepth(1.0); + gl.clearDepth(1.0); glClearStencil(0); glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 884df355d..2147a680b 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -728,7 +728,7 @@ void Graphics::clear(OptionalColorf c, OptionalInt stencil, OptionalDouble depth if (depth.hasValue) { - glClearDepth(depth.value); + gl.clearDepth(depth.value); flags |= GL_DEPTH_BUFFER_BIT; } @@ -809,7 +809,7 @@ void Graphics::clear(const std::vector &colors, OptionalInt sten if (depth.hasValue) { - glClearDepth(depth.value); + gl.clearDepth(depth.value); flags |= GL_DEPTH_BUFFER_BIT; } diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 96a2caa22..25811d96e 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -710,6 +710,14 @@ void OpenGL::setVertexPointers(vertex::CommonFormat format, love::graphics::Buff setVertexPointers(format, stride, offset); } +void OpenGL::clearDepth(double value) +{ + if (GLAD_ES_VERSION_2_0) + glClearDepthf((GLfloat) value); + else + glClearDepth(value); +} + void OpenGL::setViewport(const Rect &v) { glViewport(v.x, v.y, v.w, v.h); diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index b459ef8b2..a5c62101b 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -224,6 +224,11 @@ public: void setVertexPointers(vertex::CommonFormat format, love::graphics::Buffer *buffer, size_t offset); void setVertexPointers(vertex::CommonFormat format, love::graphics::Buffer *buffer, size_t stride, size_t offset); + /** + * Wrapper for glClearDepth and glClearDepthf. + **/ + void clearDepth(double value); + /** * Sets the OpenGL rendering viewport to the specified rectangle. * The y-coordinate starts at the top.