Browse Source

Fix crashes on OpenGL ES (thanks xenthral!)

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
30a63b6642

+ 2 - 2
src/modules/graphics/opengl/Canvas.cpp

@@ -68,7 +68,7 @@ static GLenum createFBO(GLuint &framebuffer, TextureType texType, PixelFormat fo
 
 
 					if (isPixelFormatDepthStencil(format))
 					if (isPixelFormatDepthStencil(format))
 					{
 					{
-						glClearDepth(1.0);
+						gl.clearDepth(1.0);
 						glClearStencil(0);
 						glClearStencil(0);
 						glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 						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))
 		if (isPixelFormatDepthStencil(pixelformat))
 		{
 		{
-			glClearDepth(1.0);
+			gl.clearDepth(1.0);
 			glClearStencil(0);
 			glClearStencil(0);
 			glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 			glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 		}
 		}

+ 2 - 2
src/modules/graphics/opengl/Graphics.cpp

@@ -728,7 +728,7 @@ void Graphics::clear(OptionalColorf c, OptionalInt stencil, OptionalDouble depth
 
 
 	if (depth.hasValue)
 	if (depth.hasValue)
 	{
 	{
-		glClearDepth(depth.value);
+		gl.clearDepth(depth.value);
 		flags |= GL_DEPTH_BUFFER_BIT;
 		flags |= GL_DEPTH_BUFFER_BIT;
 	}
 	}
 
 
@@ -809,7 +809,7 @@ void Graphics::clear(const std::vector<OptionalColorf> &colors, OptionalInt sten
 
 
 	if (depth.hasValue)
 	if (depth.hasValue)
 	{
 	{
-		glClearDepth(depth.value);
+		gl.clearDepth(depth.value);
 		flags |= GL_DEPTH_BUFFER_BIT;
 		flags |= GL_DEPTH_BUFFER_BIT;
 	}
 	}
 
 

+ 8 - 0
src/modules/graphics/opengl/OpenGL.cpp

@@ -710,6 +710,14 @@ void OpenGL::setVertexPointers(vertex::CommonFormat format, love::graphics::Buff
 	setVertexPointers(format, stride, offset);
 	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)
 void OpenGL::setViewport(const Rect &v)
 {
 {
 	glViewport(v.x, v.y, v.w, v.h);
 	glViewport(v.x, v.y, v.w, v.h);

+ 5 - 0
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 offset);
 	void setVertexPointers(vertex::CommonFormat format, love::graphics::Buffer *buffer, size_t stride, 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.
 	 * Sets the OpenGL rendering viewport to the specified rectangle.
 	 * The y-coordinate starts at the top.
 	 * The y-coordinate starts at the top.