Added support for GL_ANGLE_instanced_arrays.

This commit is contained in:
bkaradzic 2012-11-05 23:09:17 -08:00
parent aac1f29278
commit 2f370a6f06
2 changed files with 31 additions and 2 deletions

View file

@ -5,7 +5,6 @@ project "bgfx"
includedirs { includedirs {
BGFX_DIR .. "../tinystl/include", BGFX_DIR .. "../tinystl/include",
BGFX_DIR .. "../bx/include", BGFX_DIR .. "../bx/include",
BGFX_DIR .. "3rdparty/glext",
} }
buildoptions { buildoptions {
@ -26,6 +25,12 @@ project "bgfx"
"$(DXSDK_DIR)/include", "$(DXSDK_DIR)/include",
} }
configuration { "not nacl" }
includedirs {
--nacl has GLES2 headers modified...
BGFX_DIR .. "3rdparty/glext",
}
configuration {} configuration {}
includedirs { includedirs {

View file

@ -76,6 +76,7 @@ namespace bgfx
, m_instance(0) , m_instance(0)
, m_instInterface(NULL) , m_instInterface(NULL)
, m_graphicsInterface(NULL) , m_graphicsInterface(NULL)
, m_instancedArrays(NULL)
#elif BGFX_USE_WGL #elif BGFX_USE_WGL
, m_context(NULL) , m_context(NULL)
, m_hdc(NULL) , m_hdc(NULL)
@ -529,6 +530,7 @@ namespace bgfx
PP_Instance m_instance; PP_Instance m_instance;
const PPB_Instance* m_instInterface; const PPB_Instance* m_instInterface;
const PPB_Graphics3D* m_graphicsInterface; const PPB_Graphics3D* m_graphicsInterface;
const PPB_OpenGLES2InstancedArrays* m_instancedArrays;
#elif BGFX_USE_WGL #elif BGFX_USE_WGL
HMODULE m_opengl32dll; HMODULE m_opengl32dll;
HGLRC m_context; HGLRC m_context;
@ -547,20 +549,42 @@ namespace bgfx
RendererContext s_renderCtx; RendererContext s_renderCtx;
#if BX_PLATFORM_NACL #if BX_PLATFORM_NACL
static void GL_APIENTRY naclVertexAttribDivisor(GLuint _index, GLuint _divisor)
{
s_renderCtx.m_instancedArrays->VertexAttribDivisorANGLE(s_renderCtx.m_context, _index, _divisor);
}
static void GL_APIENTRY naclDrawArraysInstanced(GLenum _mode, GLint _first, GLsizei _count, GLsizei _primcount)
{
s_renderCtx.m_instancedArrays->DrawArraysInstancedANGLE(s_renderCtx.m_context, _mode, _first, _count, _primcount);
}
static void GL_APIENTRY naclDrawElementsInstanced(GLenum _mode, GLsizei _count, GLenum _type, const GLvoid* _indices, GLsizei _primcount)
{
s_renderCtx.m_instancedArrays->DrawElementsInstancedANGLE(s_renderCtx.m_context, _mode, _count, _type, _indices, _primcount);
}
void naclSetIntefraces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers) void naclSetIntefraces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
{ {
s_renderCtx.m_instance = _instance; s_renderCtx.m_instance = _instance;
s_renderCtx.m_instInterface = _instInterface; s_renderCtx.m_instInterface = _instInterface;
s_renderCtx.m_graphicsInterface = _graphicsInterface; s_renderCtx.m_graphicsInterface = _graphicsInterface;
s_renderCtx.m_postSwapBuffers = _postSwapBuffers; s_renderCtx.m_postSwapBuffers = _postSwapBuffers;
s_renderCtx.m_instancedArrays = glGetInstancedArraysInterfacePPAPI();
s_renderCtx.setRenderContextSize(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT); s_renderCtx.setRenderContextSize(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT);
if (NULL != s_renderCtx.m_instancedArrays)
{
s_vertexAttribDivisor = naclVertexAttribDivisor;
s_drawArraysInstanced = naclDrawArraysInstanced;
s_drawElementsInstanced = naclDrawElementsInstanced;
}
} }
void naclSwapCompleteCb(void* /*_data*/, int32_t /*_result*/) void naclSwapCompleteCb(void* /*_data*/, int32_t /*_result*/)
{ {
renderFrame(); renderFrame();
} }
#elif BX_PLATFORM_LINUX #elif BX_PLATFORM_LINUX
bool linuxGetDisplay(Display** _display, Window* _window) bool linuxGetDisplay(Display** _display, Window* _window)
{ {