Added support for GL 3.2 core profile.

This commit is contained in:
bkaradzic 2013-03-03 22:30:50 -08:00
parent 42653612cf
commit c8bdf4e950
3 changed files with 47 additions and 22 deletions

View File

@ -139,7 +139,11 @@ namespace stl {
#elif BGFX_CONFIG_RENDERER_DIRECT3D11
# define BGFX_RENDERER_NAME "Direct3D 11"
#elif BGFX_CONFIG_RENDERER_OPENGL
# define BGFX_RENDERER_NAME "OpenGL"
# if BGFX_CONFIG_RENDERER_OPENGL == 32
# define BGFX_RENDERER_NAME "OpenGL 3.2"
# else
# define BGFX_RENDERER_NAME "OpenGL 2.1"
# endif // BGFX_CONFIG_RENDERER_OPENGL
#elif BGFX_CONFIG_RENDERER_OPENGLES2
# define BGFX_RENDERER_NAME "OpenGL ES 2"
#elif BGFX_CONFIG_RENDERER_OPENGLES3

View File

@ -201,17 +201,17 @@ namespace bgfx
const int32_t contextAttrs[] =
{
#if 1
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
#else
#if BGFX_CONFIG_RENDERER_OPENGL == 32
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
#endif // 1
#if BGFX_CONFIG_DEBUG
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
# if BGFX_CONFIG_DEBUG
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
#endif // BGFX_CONFIG_DEBUG
# endif // BGFX_CONFIG_DEBUG
#else
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
#endif // BGFX_CONFIG_RENDERER_OPENGL == 32
0
};

View File

@ -162,7 +162,8 @@ namespace bgfx
, m_captureSize(0)
, m_maxAnisotropy(0.0f)
, m_maxMsaa(0)
, m_vaoSupport(false)
, m_vao(0)
, m_vaoSupport(BGFX_CONFIG_RENDERER_OPENGL >= 32)
, m_programBinarySupport(false)
, m_textureSwizzleSupport(false)
, m_flip(false)
@ -442,6 +443,7 @@ namespace bgfx
uint32_t m_captureSize;
float m_maxAnisotropy;
int32_t m_maxMsaa;
GLuint m_vao;
bool m_vaoSupport;
bool m_programBinarySupport;
bool m_textureSwizzleSupport;
@ -1348,7 +1350,8 @@ namespace bgfx
}
else
{
if (swizzle)
if (NULL != data
&& swizzle)
{
rgbaToBgra(data, width, height);
}
@ -1828,9 +1831,9 @@ namespace bgfx
void TextVideoMemBlitter::setup()
{
if (s_renderCtx.m_vaoSupport)
if (0 != s_renderCtx.m_vao)
{
GL_CHECK(glBindVertexArray(0) );
GL_CHECK(glBindVertexArray(s_renderCtx.m_vao) );
}
uint32_t width = s_renderCtx.m_resolution.m_width;
@ -1845,9 +1848,9 @@ namespace bgfx
GL_CHECK(glDisable(GL_CULL_FACE) );
GL_CHECK(glDisable(GL_BLEND) );
GL_CHECK(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
#if BGFX_CONFIG_RENDERER_OPENGL
#if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 32
GL_CHECK(glDisable(GL_ALPHA_TEST) );
#endif // BGFX_CONFIG_RENDERER_OPENGL
#endif // BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL
Program& program = s_renderCtx.m_program[m_program.idx];
GL_CHECK(glUseProgram(program.m_id) );
@ -2083,10 +2086,27 @@ namespace bgfx
}
#endif // !BGFX_CONFIG_RENDERER_OPENGLES3
}
if (s_renderCtx.m_vaoSupport)
{
GL_CHECK(glGenVertexArrays(1, &s_renderCtx.m_vao) );
}
#if BGFX_CONFIG_RENDERER_OPENGL >= 32
s_textureFormat[TextureFormat::L8].m_internalFmt = GL_R8;
s_textureFormat[TextureFormat::L8].m_fmt = GL_RED;
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 32
}
void Context::rendererShutdown()
{
if (s_renderCtx.m_vaoSupport)
{
GL_CHECK(glBindVertexArray(0) );
GL_CHECK(glDeleteVertexArrays(1, &s_renderCtx.m_vao) );
s_renderCtx.m_vao = 0;
}
s_renderCtx.shutdown();
}
@ -2241,9 +2261,10 @@ namespace bgfx
void Context::rendererSubmit()
{
if (s_renderCtx.m_vaoSupport)
const GLuint defaultVao = s_renderCtx.m_vaoSupport;
if (0 != defaultVao)
{
GL_CHECK(glBindVertexArray(0) );
GL_CHECK(glBindVertexArray(defaultVao) );
}
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) );
@ -2479,7 +2500,7 @@ namespace bgfx
uint32_t ref = (newFlags&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT;
alphaRef = ref/255.0f;
#if BGFX_CONFIG_RENDERER_OPENGL
#if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 32
if (BGFX_STATE_ALPHA_TEST & newFlags)
{
GL_CHECK(glEnable(GL_ALPHA_TEST) );
@ -2488,7 +2509,7 @@ namespace bgfx
{
GL_CHECK(glDisable(GL_ALPHA_TEST) );
}
#endif // BGFX_CONFIG_RENDERER_OPENGL
#endif // BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 32
}
#if BGFX_CONFIG_RENDERER_OPENGL
@ -2760,7 +2781,7 @@ namespace bgfx
}
}
if (s_renderCtx.m_vaoSupport
if (0 != defaultVao
&& 0 == state.m_startVertex
&& 0 == state.m_instanceDataOffset)
{
@ -2833,10 +2854,10 @@ namespace bgfx
}
else
{
if (s_renderCtx.m_vaoSupport
if (0 != defaultVao
&& 0 != currentVao)
{
GL_CHECK(glBindVertexArray(0) );
GL_CHECK(glBindVertexArray(defaultVao) );
currentState.m_vertexBuffer.idx = invalidHandle;
currentState.m_indexBuffer.idx = invalidHandle;
bindAttribs = true;