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
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
index b30d535..0a794ed 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
@@ -28,17 +28,38 @@
 {
     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);