From aadd9bd1c133a83a1add12668a990e9f1785faf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 10 Apr 2014 19:21:10 -0700 Subject: [PATCH] Fixed NaCl crash. --- src/renderer_gl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index da66578d..e3646b01 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -670,13 +670,16 @@ namespace bgfx const TextureFormatInfo& tfi = s_textureFormat[_format]; + GLsizei size = (16*16*getBitsPerPixel(_format) )/8; + void* data = alloca(size); + if (isCompressed(_format) ) { - glCompressedTexImage2D(GL_TEXTURE_2D, 0, tfi.m_internalFmt, 16, 16, 0, (16*16*getBitsPerPixel(_format) )/8, NULL); + glCompressedTexImage2D(GL_TEXTURE_2D, 0, tfi.m_internalFmt, 16, 16, 0, size, data); } else { - glTexImage2D(GL_TEXTURE_2D, 0, tfi.m_internalFmt, 16, 16, 0, tfi.m_fmt, tfi.m_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, tfi.m_internalFmt, 16, 16, 0, tfi.m_fmt, tfi.m_type, data); } GLenum err = glGetError();