mirror of https://github.com/bkaradzic/bgfx
GL 3.1 core context cleanup.
This commit is contained in:
parent
9b5cf3c9a7
commit
678da1c0b3
File diff suppressed because it is too large
Load Diff
|
@ -139,8 +139,8 @@ namespace stl {
|
|||
#elif BGFX_CONFIG_RENDERER_DIRECT3D11
|
||||
# define BGFX_RENDERER_NAME "Direct3D 11"
|
||||
#elif BGFX_CONFIG_RENDERER_OPENGL
|
||||
# if BGFX_CONFIG_RENDERER_OPENGL == 32
|
||||
# define BGFX_RENDERER_NAME "OpenGL 3.2"
|
||||
# if BGFX_CONFIG_RENDERER_OPENGL == 31
|
||||
# define BGFX_RENDERER_NAME "OpenGL 3.1"
|
||||
# else
|
||||
# define BGFX_RENDERER_NAME "OpenGL 2.1"
|
||||
# endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
|
|
@ -199,24 +199,29 @@ namespace bgfx
|
|||
result = SetPixelFormat(m_hdc, pixelFormat, &pfd);
|
||||
BGFX_FATAL(0 != result, Fatal::UnableToInitialize, "SetPixelFormat failed (last err: 0x%08x)!", GetLastError() );
|
||||
|
||||
const int32_t contextAttrs[] =
|
||||
uint32_t flags = BGFX_CONFIG_DEBUG ? WGL_CONTEXT_DEBUG_BIT_ARB : 0;
|
||||
int32_t contextAttrs[] =
|
||||
{
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL == 32
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL == 31
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
WGL_CONTEXT_FLAGS_ARB, flags,
|
||||
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
|
||||
#else
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL == 32
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL == 31
|
||||
0
|
||||
};
|
||||
|
||||
m_context = wglCreateContextAttribsARB(m_hdc, 0, contextAttrs);
|
||||
BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create context.");
|
||||
if (NULL == m_context)
|
||||
{
|
||||
// nVidia doesn't like context profile mask for contexts below 3.2?
|
||||
contextAttrs[6] = WGL_CONTEXT_PROFILE_MASK_ARB == contextAttrs[6] ? 0 : contextAttrs[6];
|
||||
m_context = wglCreateContextAttribsARB(m_hdc, 0, contextAttrs);
|
||||
}
|
||||
BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create context 0x%08x.", GetLastError() );
|
||||
}
|
||||
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
|
|
|
@ -16,7 +16,7 @@ GL_IMPORT(false, PFNGLGETERRORPROC, glGetError);
|
|||
GL_IMPORT(false, PFNGLREADPIXELSPROC, glReadPixels);
|
||||
GL_IMPORT(false, PFNGLTEXIMAGE2DPROC, glTexImage2D);
|
||||
GL_IMPORT(false, PFNGLTEXSUBIMAGE2DPROC, glTexSubImage2D);
|
||||
GL_IMPORT(false, PFNGLPIXELSTOREI, glPixelStorei);
|
||||
GL_IMPORT(false, PFNGLPIXELSTOREIPROC, glPixelStorei);
|
||||
GL_IMPORT(false, PFNGLTEXPARAMETERIPROC, glTexParameteri);
|
||||
GL_IMPORT(false, PFNGLTEXPARAMETERIVPROC, glTexParameteriv);
|
||||
GL_IMPORT(false, PFNGLTEXPARAMETERFPROC, glTexParameterf);
|
||||
|
@ -124,10 +124,6 @@ GL_IMPORT(true, PFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer);
|
|||
GL_IMPORT(true, PFNGLQUERYCOUNTERPROC, glQueryCounter);
|
||||
GL_IMPORT(true, PFNGLGETQUERYOBJECTI64VPROC, glGetQueryObjecti64v);
|
||||
GL_IMPORT(true, PFNGLGETQUERYOBJECTUI64VPROC, glGetQueryObjectui64v);
|
||||
GL_IMPORT(true, PFNGLGETQUERYOBJECTI64VEXTPROC, glGetQueryObjecti64vEXT);
|
||||
GL_IMPORT(true, PFNGLGETQUERYOBJECTUI64VEXTPROC, glGetQueryObjectui64vEXT);
|
||||
|
||||
GL_IMPORT(true, PFNGLSAMPLECOVERAGEARBPROC, glSampleCoverageARB);
|
||||
|
||||
GL_IMPORT(true, PFNGLBINDVERTEXARRAYPROC, glBindVertexArray);
|
||||
GL_IMPORT(true, PFNGLDELETEVERTEXARRAYSPROC, glDeleteVertexArrays);
|
||||
|
|
|
@ -68,47 +68,47 @@ namespace bgfx
|
|||
|
||||
static Extension s_extension[Extension::Count] =
|
||||
{
|
||||
{ "GL_EXT_texture_filter_anisotropic", false, true },
|
||||
{ "GL_EXT_texture_format_BGRA8888", false, true },
|
||||
{ "GL_EXT_bgra", false, true },
|
||||
{ "GL_EXT_texture_compression_s3tc", false, true },
|
||||
{ "GL_EXT_texture_compression_dxt1", false, true },
|
||||
{ "GL_CHROMIUM_texture_compression_dxt3", false, true },
|
||||
{ "GL_CHROMIUM_texture_compression_dxt5", false, true },
|
||||
{ "GL_EXT_texture_compression_latc", false, true },
|
||||
{ "GL_EXT_texture_compression_rgtc", false, true },
|
||||
{ "GL_ARB_texture_float", false, true },
|
||||
{ "GL_OES_texture_float", false, true },
|
||||
{ "GL_OES_texture_float_linear", false, true },
|
||||
{ "GL_OES_texture_half_float", false, true },
|
||||
{ "GL_OES_texture_half_float_linear", false, true },
|
||||
{ "GL_EXT_texture_type_2_10_10_10_REV", false, true },
|
||||
{ "GL_EXT_texture_sRGB", false, true },
|
||||
{ "GL_ARB_texture_swizzle", false, true },
|
||||
{ "GL_EXT_texture_swizzle", false, true },
|
||||
{ "GL_ARB_texture_multisample", false, true },
|
||||
{ "GL_OES_standard_derivatives", false, true },
|
||||
{ "GL_ARB_get_program_binary", false, true },
|
||||
{ "GL_OES_get_program_binary", false, false },
|
||||
{ "GL_EXT_framebuffer_blit", false, true },
|
||||
{ "GL_ARB_timer_query", false, true },
|
||||
{ "GL_EXT_timer_query", false, true },
|
||||
{ "GL_ARB_framebuffer_sRGB", false, true },
|
||||
{ "GL_EXT_framebuffer_sRGB", false, true },
|
||||
{ "GL_ARB_multisample", false, true },
|
||||
{ "GL_CHROMIUM_framebuffer_multisample", false, true },
|
||||
{ "GL_ANGLE_translated_shader_source", false, true },
|
||||
{ "GL_ARB_instanced_arrays", false, true },
|
||||
{ "GL_ANGLE_instanced_arrays", false, true },
|
||||
{ "GL_ARB_half_float_vertex", false, true },
|
||||
{ "GL_OES_vertex_half_float", false, true },
|
||||
{ "GL_ARB_vertex_type_2_10_10_10_rev", false, true },
|
||||
{ "GL_OES_vertex_type_10_10_10_2", false, true },
|
||||
{ "GL_EXT_occlusion_query_boolean", false, true },
|
||||
{ "GL_ARB_vertex_array_object", false, true },
|
||||
{ "OES_vertex_array_object", false, true },
|
||||
{ "GL_ATI_meminfo", false, true },
|
||||
{ "GL_NVX_gpu_memory_info", false, true },
|
||||
{ "GL_EXT_texture_filter_anisotropic", false, true },
|
||||
{ "GL_EXT_texture_format_BGRA8888", false, true },
|
||||
{ "GL_EXT_bgra", false, true },
|
||||
{ "GL_EXT_texture_compression_s3tc", false, true },
|
||||
{ "GL_EXT_texture_compression_dxt1", false, true },
|
||||
{ "GL_CHROMIUM_texture_compression_dxt3", false, true },
|
||||
{ "GL_CHROMIUM_texture_compression_dxt5", false, true },
|
||||
{ "GL_EXT_texture_compression_latc", false, true },
|
||||
{ "GL_EXT_texture_compression_rgtc", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
|
||||
{ "GL_ARB_texture_float", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
|
||||
{ "GL_OES_texture_float", false, true },
|
||||
{ "GL_OES_texture_float_linear", false, true },
|
||||
{ "GL_OES_texture_half_float", false, true },
|
||||
{ "GL_OES_texture_half_float_linear", false, true },
|
||||
{ "GL_EXT_texture_type_2_10_10_10_REV", false, true },
|
||||
{ "GL_EXT_texture_sRGB", false, true },
|
||||
{ "GL_ARB_texture_swizzle", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
||||
{ "GL_EXT_texture_swizzle", false, true },
|
||||
{ "GL_ARB_texture_multisample", false, true },
|
||||
{ "GL_OES_standard_derivatives", false, true },
|
||||
{ "GL_ARB_get_program_binary", BGFX_CONFIG_RENDERER_OPENGL >= 41, true },
|
||||
{ "GL_OES_get_program_binary", false, false },
|
||||
{ "GL_EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
|
||||
{ "GL_ARB_timer_query", false, true },
|
||||
{ "GL_EXT_timer_query", false, true },
|
||||
{ "GL_ARB_framebuffer_sRGB", false, true },
|
||||
{ "GL_EXT_framebuffer_sRGB", false, true },
|
||||
{ "GL_ARB_multisample", false, true },
|
||||
{ "GL_CHROMIUM_framebuffer_multisample", false, true },
|
||||
{ "GL_ANGLE_translated_shader_source", false, true },
|
||||
{ "GL_ARB_instanced_arrays", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
||||
{ "GL_ANGLE_instanced_arrays", false, true },
|
||||
{ "GL_ARB_half_float_vertex", false, true },
|
||||
{ "GL_OES_vertex_half_float", false, true },
|
||||
{ "GL_ARB_vertex_type_2_10_10_10_rev", false, true },
|
||||
{ "GL_OES_vertex_type_10_10_10_2", false, true },
|
||||
{ "GL_EXT_occlusion_query_boolean", false, true },
|
||||
{ "GL_ARB_vertex_array_object", BGFX_CONFIG_RENDERER_OPENGL >= 31, true },
|
||||
{ "OES_vertex_array_object", false, true },
|
||||
{ "GL_ATI_meminfo", false, true },
|
||||
{ "GL_NVX_gpu_memory_info", false, true },
|
||||
};
|
||||
|
||||
static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/)
|
||||
|
@ -163,7 +163,7 @@ namespace bgfx
|
|||
, m_maxAnisotropy(0.0f)
|
||||
, m_maxMsaa(0)
|
||||
, m_vao(0)
|
||||
, m_vaoSupport(BGFX_CONFIG_RENDERER_OPENGL >= 32)
|
||||
, m_vaoSupport(BGFX_CONFIG_RENDERER_OPENGL >= 31)
|
||||
, m_programBinarySupport(false)
|
||||
, m_textureSwizzleSupport(false)
|
||||
, m_flip(false)
|
||||
|
@ -1848,7 +1848,7 @@ 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 && BGFX_CONFIG_RENDERER_OPENGL < 32
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 31
|
||||
GL_CHECK(glDisable(GL_ALPHA_TEST) );
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
|
@ -2001,101 +2001,101 @@ namespace bgfx
|
|||
BX_TRACE("\t%2d: %s", ii, s_extension[ii].m_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool bc123Supported = s_extension[Extension::EXT_texture_compression_s3tc].m_supported;
|
||||
s_textureFormat[TextureFormat::BC1].m_supported = bc123Supported || s_extension[Extension::EXT_texture_compression_dxt1].m_supported;
|
||||
s_textureFormat[TextureFormat::BC2].m_supported = bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt3].m_supported;
|
||||
s_textureFormat[TextureFormat::BC3].m_supported = bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt5].m_supported;
|
||||
bool bc123Supported = s_extension[Extension::EXT_texture_compression_s3tc].m_supported;
|
||||
s_textureFormat[TextureFormat::BC1].m_supported = bc123Supported || s_extension[Extension::EXT_texture_compression_dxt1].m_supported;
|
||||
s_textureFormat[TextureFormat::BC2].m_supported = bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt3].m_supported;
|
||||
s_textureFormat[TextureFormat::BC3].m_supported = bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt5].m_supported;
|
||||
|
||||
bool bc45Supported = s_extension[Extension::EXT_texture_compression_latc].m_supported
|
||||
|| s_extension[Extension::EXT_texture_compression_rgtc].m_supported
|
||||
;
|
||||
s_textureFormat[TextureFormat::BC4].m_supported = bc45Supported;
|
||||
s_textureFormat[TextureFormat::BC5].m_supported = bc45Supported;
|
||||
bool bc45Supported = s_extension[Extension::EXT_texture_compression_latc].m_supported
|
||||
|| s_extension[Extension::EXT_texture_compression_rgtc].m_supported
|
||||
;
|
||||
s_textureFormat[TextureFormat::BC4].m_supported = bc45Supported;
|
||||
s_textureFormat[TextureFormat::BC5].m_supported = bc45Supported;
|
||||
|
||||
s_renderCtx.m_vaoSupport = !!BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|| s_extension[Extension::ARB_vertex_array_object].m_supported
|
||||
|| s_extension[Extension::OES_vertex_array_object].m_supported
|
||||
;
|
||||
s_renderCtx.m_vaoSupport = !!BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|| s_extension[Extension::ARB_vertex_array_object].m_supported
|
||||
|| s_extension[Extension::OES_vertex_array_object].m_supported
|
||||
;
|
||||
|
||||
s_renderCtx.m_programBinarySupport = !!BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|| s_extension[Extension::ARB_get_program_binary].m_supported
|
||||
|| s_extension[Extension::OES_get_program_binary].m_supported
|
||||
;
|
||||
s_renderCtx.m_programBinarySupport = !!BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|| s_extension[Extension::ARB_get_program_binary].m_supported
|
||||
|| s_extension[Extension::OES_get_program_binary].m_supported
|
||||
;
|
||||
|
||||
s_renderCtx.m_textureSwizzleSupport = false
|
||||
|| s_extension[Extension::ARB_texture_swizzle].m_supported
|
||||
|| s_extension[Extension::EXT_texture_swizzle].m_supported
|
||||
;
|
||||
s_renderCtx.m_textureSwizzleSupport = false
|
||||
|| s_extension[Extension::ARB_texture_swizzle].m_supported
|
||||
|| s_extension[Extension::EXT_texture_swizzle].m_supported
|
||||
;
|
||||
|
||||
if (s_extension[Extension::EXT_texture_filter_anisotropic].m_supported)
|
||||
{
|
||||
GL_CHECK(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &s_renderCtx.m_maxAnisotropy) );
|
||||
}
|
||||
if (s_extension[Extension::EXT_texture_filter_anisotropic].m_supported)
|
||||
{
|
||||
GL_CHECK(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &s_renderCtx.m_maxAnisotropy) );
|
||||
}
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
if (s_extension[Extension::ARB_texture_multisample].m_supported)
|
||||
{
|
||||
GL_CHECK(glGetIntegerv(GL_MAX_SAMPLES, &s_renderCtx.m_maxMsaa) );
|
||||
}
|
||||
if (s_extension[Extension::ARB_texture_multisample].m_supported)
|
||||
{
|
||||
GL_CHECK(glGetIntegerv(GL_MAX_SAMPLES, &s_renderCtx.m_maxMsaa) );
|
||||
}
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|
||||
if (s_extension[Extension::EXT_texture_format_BGRA8888].m_supported
|
||||
|| s_extension[Extension::EXT_bgra].m_supported)
|
||||
{
|
||||
s_textureFormat[TextureFormat::BGRX8].m_fmt = GL_BGRA_EXT;
|
||||
s_textureFormat[TextureFormat::BGRA8].m_fmt = GL_BGRA_EXT;
|
||||
if (s_extension[Extension::EXT_texture_format_BGRA8888].m_supported
|
||||
|| s_extension[Extension::EXT_bgra].m_supported)
|
||||
{
|
||||
s_textureFormat[TextureFormat::BGRX8].m_fmt = GL_BGRA_EXT;
|
||||
s_textureFormat[TextureFormat::BGRA8].m_fmt = GL_BGRA_EXT;
|
||||
|
||||
// Mixing GLES and GL extensions here. OpenGL EXT_bgra wants
|
||||
// format to be BGRA but internal format to stay RGBA, but
|
||||
// EXT_texture_format_BGRA8888 wants both format and internal
|
||||
// format to be BGRA.
|
||||
//
|
||||
// Reference:
|
||||
// https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_format_BGRA8888.txt
|
||||
// https://www.opengl.org/registry/specs/EXT/bgra.txt
|
||||
if (!s_extension[Extension::EXT_bgra].m_supported)
|
||||
{
|
||||
s_textureFormat[TextureFormat::BGRX8].m_internalFmt = GL_BGRA_EXT;
|
||||
s_textureFormat[TextureFormat::BGRA8].m_internalFmt = GL_BGRA_EXT;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_extension[Extension::EXT_texture_compression_rgtc].m_supported)
|
||||
// Mixing GLES and GL extensions here. OpenGL EXT_bgra wants
|
||||
// format to be BGRA but internal format to stay RGBA, but
|
||||
// EXT_texture_format_BGRA8888 wants both format and internal
|
||||
// format to be BGRA.
|
||||
//
|
||||
// Reference:
|
||||
// https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_format_BGRA8888.txt
|
||||
// https://www.opengl.org/registry/specs/EXT/bgra.txt
|
||||
if (!s_extension[Extension::EXT_bgra].m_supported)
|
||||
{
|
||||
s_textureFormat[TextureFormat::BC4].m_fmt = GL_COMPRESSED_RED_RGTC1_EXT;
|
||||
s_textureFormat[TextureFormat::BC4].m_internalFmt = GL_COMPRESSED_RED_RGTC1_EXT;
|
||||
s_textureFormat[TextureFormat::BC5].m_fmt = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
|
||||
s_textureFormat[TextureFormat::BC5].m_internalFmt = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
|
||||
s_textureFormat[TextureFormat::BGRX8].m_internalFmt = GL_BGRA_EXT;
|
||||
s_textureFormat[TextureFormat::BGRA8].m_internalFmt = GL_BGRA_EXT;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_extension[Extension::EXT_texture_compression_rgtc].m_supported)
|
||||
{
|
||||
s_textureFormat[TextureFormat::BC4].m_fmt = GL_COMPRESSED_RED_RGTC1_EXT;
|
||||
s_textureFormat[TextureFormat::BC4].m_internalFmt = GL_COMPRESSED_RED_RGTC1_EXT;
|
||||
s_textureFormat[TextureFormat::BC5].m_fmt = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
|
||||
s_textureFormat[TextureFormat::BC5].m_internalFmt = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
|
||||
}
|
||||
|
||||
#if !BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
if (NULL != glVertexAttribDivisor
|
||||
&& NULL != glDrawArraysInstanced
|
||||
&& NULL != glDrawElementsInstanced)
|
||||
{
|
||||
s_vertexAttribDivisor = glVertexAttribDivisor;
|
||||
s_drawArraysInstanced = glDrawArraysInstanced;
|
||||
s_drawElementsInstanced = glDrawElementsInstanced;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_vertexAttribDivisor = stubVertexAttribDivisor;
|
||||
s_drawArraysInstanced = stubDrawArraysInstanced;
|
||||
s_drawElementsInstanced = stubDrawElementsInstanced;
|
||||
}
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
if (NULL != glVertexAttribDivisor
|
||||
&& NULL != glDrawArraysInstanced
|
||||
&& NULL != glDrawElementsInstanced)
|
||||
{
|
||||
s_vertexAttribDivisor = glVertexAttribDivisor;
|
||||
s_drawArraysInstanced = glDrawArraysInstanced;
|
||||
s_drawElementsInstanced = glDrawElementsInstanced;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_vertexAttribDivisor = stubVertexAttribDivisor;
|
||||
s_drawArraysInstanced = stubDrawArraysInstanced;
|
||||
s_drawElementsInstanced = stubDrawElementsInstanced;
|
||||
}
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|
||||
if (s_renderCtx.m_vaoSupport)
|
||||
{
|
||||
GL_CHECK(glGenVertexArrays(1, &s_renderCtx.m_vao) );
|
||||
}
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL >= 32
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
s_textureFormat[TextureFormat::L8].m_internalFmt = GL_R8;
|
||||
s_textureFormat[TextureFormat::L8].m_fmt = GL_RED;
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 32
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
}
|
||||
|
||||
void Context::rendererShutdown()
|
||||
|
@ -2500,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 && BGFX_CONFIG_RENDERER_OPENGL < 32
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 31
|
||||
if (BGFX_STATE_ALPHA_TEST & newFlags)
|
||||
{
|
||||
GL_CHECK(glEnable(GL_ALPHA_TEST) );
|
||||
|
@ -2509,7 +2509,7 @@ namespace bgfx
|
|||
{
|
||||
GL_CHECK(glDisable(GL_ALPHA_TEST) );
|
||||
}
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 32
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 31
|
||||
}
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
|
|
@ -11,74 +11,58 @@
|
|||
#define BGFX_USE_NSGL 0
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
# if BX_PLATFORM_LINUX
|
||||
# define GL_PROTOTYPES
|
||||
# define GL_GLEXT_LEGACY
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glx.h>
|
||||
# undef GL_PROTOTYPES
|
||||
# elif BX_PLATFORM_OSX
|
||||
# define GL_GLEXT_LEGACY
|
||||
# define long ptrdiff_t
|
||||
# include <OpenGL/gl.h>
|
||||
# undef long
|
||||
# undef GL_VERSION_1_2
|
||||
# undef GL_VERSION_1_3
|
||||
# undef GL_VERSION_1_4
|
||||
# undef GL_VERSION_1_5
|
||||
# undef GL_VERSION_2_0
|
||||
# if BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
# include <gl/glcorearb.h>
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif // BX_PLATFORM_
|
||||
# if BX_PLATFORM_LINUX
|
||||
# define GL_PROTOTYPES
|
||||
# define GL_GLEXT_LEGACY
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glx.h>
|
||||
# undef GL_PROTOTYPES
|
||||
# elif BX_PLATFORM_OSX
|
||||
# define GL_GLEXT_LEGACY
|
||||
# define long ptrdiff_t
|
||||
# include <OpenGL/gl.h>
|
||||
# undef long
|
||||
# undef GL_VERSION_1_2
|
||||
# undef GL_VERSION_1_3
|
||||
# undef GL_VERSION_1_4
|
||||
# undef GL_VERSION_1_5
|
||||
# undef GL_VERSION_2_0
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif // BX_PLATFORM_
|
||||
|
||||
// remove deprecated from glext.h
|
||||
# define GL_VERSION_1_2_DEPRECATED
|
||||
# define GL_ARB_imaging_DEPRECATED
|
||||
# define GL_VERSION_1_3_DEPRECATED
|
||||
# define GL_VERSION_1_4_DEPRECATED
|
||||
# define GL_VERSION_1_5_DEPRECATED
|
||||
# define GL_VERSION_2_0_DEPRECATED
|
||||
# define GL_VERSION_2_1_DEPRECATED
|
||||
// ignore everything above 2.1
|
||||
# define GL_VERSION_3_0
|
||||
# define GL_VERSION_3_0_DEPRECATED
|
||||
# define GL_VERSION_3_1
|
||||
# define GL_VERSION_3_2
|
||||
# define GL_VERSION_3_3
|
||||
# define GL_VERSION_4_0
|
||||
# define GL_VERSION_4_1
|
||||
# define GL_VERSION_4_2
|
||||
# include <gl/glext.h>
|
||||
# endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
|
||||
# define glVertexAttribDivisor glVertexAttribDivisorARB
|
||||
# define glDrawArraysInstanced glDrawArraysInstancedARB
|
||||
# define glDrawElementsInstanced glDrawElementsInstancedARB
|
||||
|
||||
# if BX_PLATFORM_WINDOWS
|
||||
# undef BGFX_USE_WGL
|
||||
# define BGFX_USE_WGL 1
|
||||
# endif // BX_PLATFORM_
|
||||
|
||||
// remove deprecated from glext.h
|
||||
# define GL_VERSION_1_2_DEPRECATED
|
||||
# define GL_ARB_imaging_DEPRECATED
|
||||
# define GL_VERSION_1_3_DEPRECATED
|
||||
# define GL_VERSION_1_4_DEPRECATED
|
||||
# define GL_VERSION_1_5_DEPRECATED
|
||||
# define GL_VERSION_2_0_DEPRECATED
|
||||
# define GL_VERSION_2_1_DEPRECATED
|
||||
// ignore everything above 2.1
|
||||
# define GL_VERSION_3_0
|
||||
# define GL_VERSION_3_0_DEPRECATED
|
||||
# define GL_VERSION_3_1
|
||||
# define GL_VERSION_3_2
|
||||
# define GL_VERSION_3_3
|
||||
# define GL_VERSION_4_0
|
||||
# define GL_VERSION_4_1
|
||||
# define GL_VERSION_4_2
|
||||
# include <gl/glext.h>
|
||||
# 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
|
||||
# define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
|
||||
# endif // GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
|
||||
# endif // GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
# define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
|
||||
# endif // GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A
|
||||
# endif // GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B
|
||||
# endif // GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
|
||||
#elif BGFX_CONFIG_RENDERER_OPENGLES2 || BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
# if BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
# include <GLES2/gl2platform.h>
|
||||
|
@ -110,6 +94,14 @@
|
|||
# include <emscripten/emscripten.h>
|
||||
# endif // BX_PLATFORM_EMSCRIPTEN
|
||||
|
||||
typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
|
||||
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
# ifndef GL_LUMINANCE
|
||||
# define GL_LUMINANCE 0x1909
|
||||
# endif // GL_LUMINANCE
|
||||
|
||||
# ifndef GL_BGRA_EXT
|
||||
# define GL_BGRA_EXT 0x80E1
|
||||
# endif // GL_BGRA_EXT
|
||||
|
@ -154,9 +146,38 @@
|
|||
# define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
# endif // GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
|
||||
typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
|
||||
# ifndef GL_VBO_FREE_MEMORY_ATI
|
||||
# define GL_VBO_FREE_MEMORY_ATI 0x87FB
|
||||
# endif // GL_VBO_FREE_MEMORY_ATI
|
||||
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
# ifndef GL_TEXTURE_FREE_MEMORY_ATI
|
||||
# define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
|
||||
# endif // GL_TEXTURE_FREE_MEMORY_ATI
|
||||
|
||||
# ifndef GL_RENDERBUFFER_FREE_MEMORY_ATI
|
||||
# define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
|
||||
# endif // GL_RENDERBUFFER_FREE_MEMORY_ATI
|
||||
|
||||
// http://developer.download.nvidia.com/opengl/specs/GL_NVX_gpu_memory_info.txt
|
||||
# ifndef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
# define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
|
||||
# endif // GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
|
||||
# endif // GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
# define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
|
||||
# endif // GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A
|
||||
# endif // GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B
|
||||
# endif // GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
|
||||
#ifndef GL_RGBA16
|
||||
# define GL_RGBA16 0x805B
|
||||
|
|
Loading…
Reference in New Issue