From 4ef1f3474e12f1c78af44947c44a22c99d8c2557 Mon Sep 17 00:00:00 2001 From: Guy Zadikario Date: Sun, 12 Jun 2011 15:19:30 +0300 Subject: [PATCH] emulator opengl: initialize new colorbuffers Initialize new allocated color buffers with zeros. Change-Id: I64a63c2eda83fdec1926c387e171324fb07ebe83 --- .../opengl/host/libs/libOpenglRender/ColorBuffer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp index 099eeea74..adc84d27a 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp @@ -56,10 +56,16 @@ ColorBuffer *ColorBuffer::create(int p_width, int p_height, s_gl.glGenTextures(1, &cb->m_tex); s_gl.glBindTexture(GL_TEXTURE_2D, cb->m_tex); + int nComp = (texInternalFormat == GL_RGB ? 3 : 4); + char *zBuff = new char[nComp*p_width*p_height]; + if (zBuff) { + memset(zBuff, 0, nComp*p_width*p_height); + } s_gl.glTexImage2D(GL_TEXTURE_2D, 0, texInternalFormat, p_width, p_height, 0, texInternalFormat, - GL_UNSIGNED_BYTE, NULL); + GL_UNSIGNED_BYTE, zBuff); + delete [] zBuff; 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);