From 8f155985b677c7dc99f464505d312fb9ee386f82 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 3 Feb 2013 12:17:33 -0800 Subject: [PATCH] Fixed GL_ARB_instanced_arrays on MESA. --- src/glimports.h | 6 +++++- src/renderer_gl.cpp | 6 +----- src/renderer_gl.h | 12 ++++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/glimports.h b/src/glimports.h index 06692fdc..b6a9cf98 100644 --- a/src/glimports.h +++ b/src/glimports.h @@ -160,7 +160,11 @@ GL_IMPORT(true, PFNGLGENVERTEXARRAYSOESPROC, glGenVertexArraysOES); #endif // BGFX_CONFIG_RENDERER_ -#if !BGFX_CONFIG_RENDERER_OPENGLES3 +#if BGFX_CONFIG_RENDERER_OPENGL +GL_IMPORT(true, PFNGLVERTEXATTRIBDIVISORBGFXPROC, glVertexAttribDivisorARB); +GL_IMPORT(true, PFNGLDRAWARRAYSINSTANCEDBGFXPROC, glDrawArraysInstancedARB); +GL_IMPORT(true, PFNGLDRAWELEMENTSINSTANCEDBGFXPROC, glDrawElementsInstancedARB); +#elif BGFX_CONFIG_RENDERER_OPENGLES2 GL_IMPORT(true, PFNGLVERTEXATTRIBDIVISORBGFXPROC, glVertexAttribDivisor); GL_IMPORT(true, PFNGLDRAWARRAYSINSTANCEDBGFXPROC, glDrawArraysInstanced); GL_IMPORT(true, PFNGLDRAWELEMENTSINSTANCEDBGFXPROC, glDrawElementsInstanced); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index d37bc018..8585ab65 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -540,11 +540,7 @@ namespace bgfx { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, true }, { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, true }, { GL_RGBA16, GL_RGBA, GL_UNSIGNED_BYTE, 64, true }, -#if BGFX_CONFIG_RENDERER_OPENGL - { GL_RGBA16, GL_RGBA, GL_HALF_FLOAT, 64, true }, -#else - { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 64, true }, -#endif // BGFX_CONFIG_RENDERER_OPENGL + { GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 64, true }, { GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, true }, { GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, true }, { GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, true }, diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 83d85362..c224b9ac 100755 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -54,6 +54,9 @@ # define GL_VERSION_4_1 # define GL_VERSION_4_2 # include +# define glVertexAttribDivisor glVertexAttribDivisorARB +# define glDrawArraysInstanced glDrawArraysInstancedARB +# define glDrawElementsInstanced glDrawElementsInstancedARB // http://developer.download.nvidia.com/opengl/specs/GL_NVX_gpu_memory_info.txt # ifndef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX @@ -111,6 +114,14 @@ # define GL_BGRA_EXT 0x80E1 # endif // GL_BGRA_EXT +# ifndef GL_RGBA16 +# define GL_RGBA16 0x805B +# endif // GL_RGBA16 + +# ifndef GL_RGBA16F +# define GL_RGBA16F 0x881A +# endif // GL_RGBA16F + # ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT # define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 # endif // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT @@ -187,6 +198,7 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b namespace bgfx { + // Both GL_ARB_instanced_arrays and GL_ANGLE_instanced_arrays use the same function signature. typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORBGFXPROC)(GLuint _index, GLuint _divisor); typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDBGFXPROC)(GLenum _mode, GLint _first, GLsizei _count, GLsizei _primcount); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBGFXPROC)(GLenum _mode, GLsizei _count, GLenum _type, const GLvoid* _indices, GLsizei _primcount);