浏览代码

GL: Added GL error flush.

Branimir Karadžić 9 年之前
父节点
当前提交
0d9035311f
共有 1 个文件被更改,包括 12 次插入2 次删除
  1. 12 2
      src/renderer_gl.cpp

+ 12 - 2
src/renderer_gl.cpp

@@ -1129,6 +1129,11 @@ namespace bgfx { namespace gl
 		tfi.m_type        = _type;
 	}
 
+	void flushGlError()
+	{
+		for (GLenum err = glGetError(); err != 0; err = glGetError());
+	}
+
 	GLenum initTestTexture(TextureFormat::Enum _format, bool _srgb, bool _mipmaps)
 	{
 		const TextureFormatInfo& tfi = s_textureFormat[_format];
@@ -1140,6 +1145,7 @@ namespace bgfx { namespace gl
 		GLsizei size = (16*16*getBitsPerPixel(_format) )/8;
 		void* data = bx::alignPtr(alloca(size+16), 0, 16);
 
+		flushGlError();
 		GLenum err = 0;
 
 		if (isCompressed(_format) )
@@ -1219,8 +1225,12 @@ namespace bgfx { namespace gl
 		GLuint id;
 		GL_CHECK(glGenTextures(1, &id) );
 		GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) );
+
+		flushGlError();
+		GLenum err = 0;
+
 		glTexStorage2D(GL_TEXTURE_2D, 1, s_imageFormat[_format], 16, 16);
-		GLenum err = glGetError();
+		err |= glGetError();
 		if (0 == err)
 		{
 			glBindImageTexture(0
@@ -1231,7 +1241,7 @@ namespace bgfx { namespace gl
 				, GL_READ_WRITE
 				, s_imageFormat[_format]
 				);
-			err = glGetError();
+			err |= glGetError();
 		}
 
 		GL_CHECK(glDeleteTextures(1, &id) );