From f0dce80492d9885dc8a75037e2f802dc0832ce32 Mon Sep 17 00:00:00 2001 From: Guy Zadikario Date: Sat, 4 Jun 2011 15:12:18 +0300 Subject: [PATCH] opengl renderer: Fixed colorBuffer texture creation. The created texture format which represents the color buffer must be of type GL_RGB or GL_RGBA also for the 565/5551 surface formats. Change-Id: I7799a4824a0a5b8d57e3bfc507cac5664340725e --- .../host/libs/libOpenglRender/ColorBuffer.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp index b30d53555..0a794ed97 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp @@ -28,17 +28,38 @@ ColorBuffer *ColorBuffer::create(int p_width, int p_height, { FrameBuffer *fb = FrameBuffer::getFB(); + GLenum texInternalFormat = 0; + + switch(p_internalFormat) { + case GL_RGB: + case GL_RGB565_OES: + texInternalFormat = GL_RGB; + break; + + case GL_RGBA: + case GL_RGB5_A1_OES: + case GL_RGBA4_OES: + texInternalFormat = GL_RGBA; + break; + + default: + return NULL; + break; + } + if (!fb->bind_locked()) { return NULL; } ColorBuffer *cb = new ColorBuffer(); + s_gl.glGenTextures(1, &cb->m_tex); s_gl.glBindTexture(GL_TEXTURE_2D, cb->m_tex); - s_gl.glTexImage2D(GL_TEXTURE_2D, 0, p_internalFormat, + s_gl.glTexImage2D(GL_TEXTURE_2D, 0, texInternalFormat, p_width, p_height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); + texInternalFormat, + GL_UNSIGNED_BYTE, NULL); s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);