Allow disabling primitive restart index. Also, better handling of unsupported shader languages.
This commit is contained in:
parent
2c4fbf08be
commit
0f35480fcf
|
|
@ -555,26 +555,30 @@ reset() {
|
|||
#ifndef OPENGLES
|
||||
_glPrimitiveRestartIndex = NULL;
|
||||
|
||||
if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_ES3_compatibility")) {
|
||||
/*if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_ES3_compatibility")) {
|
||||
// As long as we enable this, OpenGL will always use the highest possible index
|
||||
// for a numeric type as strip cut index, which coincides with our convention.
|
||||
// This saves us a call to glPrimitiveRestartIndex.
|
||||
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
||||
_supported_geom_rendering |= Geom::GR_strip_cut_index;
|
||||
|
||||
} else if (is_at_least_gl_version(3, 1)) {
|
||||
glEnable(GL_PRIMITIVE_RESTART);
|
||||
_supported_geom_rendering |= Geom::GR_strip_cut_index;
|
||||
} else
|
||||
*/
|
||||
if (gl_support_primitive_restart_index) {
|
||||
if (is_at_least_gl_version(3, 1)) {
|
||||
glEnable(GL_PRIMITIVE_RESTART);
|
||||
_supported_geom_rendering |= Geom::GR_strip_cut_index;
|
||||
|
||||
_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)
|
||||
get_extension_func("glPrimitiveRestartIndex");
|
||||
_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)
|
||||
get_extension_func("glPrimitiveRestartIndex");
|
||||
|
||||
} else if (has_extension("GL_NV_primitive_restart")) {
|
||||
glEnable(GL_PRIMITIVE_RESTART_NV);
|
||||
_supported_geom_rendering |= Geom::GR_strip_cut_index;
|
||||
} else if (has_extension("GL_NV_primitive_restart")) {
|
||||
glEnable(GL_PRIMITIVE_RESTART_NV);
|
||||
_supported_geom_rendering |= Geom::GR_strip_cut_index;
|
||||
|
||||
_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)
|
||||
get_extension_func("glPrimitiveRestartIndexNV");
|
||||
_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)
|
||||
get_extension_func("glPrimitiveRestartIndexNV");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -4357,18 +4361,31 @@ prepare_shader(Shader *se) {
|
|||
ShaderContext *result = NULL;
|
||||
|
||||
switch (se->get_language()) {
|
||||
#if defined(HAVE_CG) && !defined(OPENGLES)
|
||||
case Shader::SL_Cg:
|
||||
result = new CLP(CgShaderContext)(this, se);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Shader::SL_GLSL:
|
||||
if (_supports_glsl) {
|
||||
result = new CLP(ShaderContext)(this, se);
|
||||
break;
|
||||
} else {
|
||||
GLCAT.error()
|
||||
<< "Tried to load GLSL shader, but GLSL shaders not supported.\n";
|
||||
return NULL;
|
||||
}
|
||||
// Fall through.
|
||||
|
||||
#if defined(HAVE_CG) && !defined(OPENGLES)
|
||||
case Shader::SL_Cg:
|
||||
if (_supports_basic_shaders) {
|
||||
result = new CLP(CgShaderContext)(this, se);
|
||||
break;
|
||||
} else {
|
||||
GLCAT.error()
|
||||
<< "Tried to load Cg shader, but basic shaders not supported.\n";
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
GLCAT.error()
|
||||
<< "Tried to load Cg shader, but Cg support not compiled in.\n";
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
default:
|
||||
GLCAT.error()
|
||||
|
|
@ -5157,7 +5174,9 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z,
|
|||
}
|
||||
|
||||
if (uses_mipmaps && _glGenerateMipmap != NULL) {
|
||||
glEnable(target);
|
||||
_glGenerateMipmap(target);
|
||||
glDisable(target);
|
||||
}
|
||||
|
||||
gtc->_has_storage = true;
|
||||
|
|
@ -6668,7 +6687,6 @@ void CLP(GraphicsStateGuardian)::
|
|||
set_draw_buffer(int rbtype) {
|
||||
#ifndef OPENGLES // Draw buffers not supported by OpenGL ES.
|
||||
if (_current_fbo) {
|
||||
|
||||
GLuint buffers[16];
|
||||
int nbuffers = 0;
|
||||
int index = 0;
|
||||
|
|
@ -6705,7 +6723,6 @@ set_draw_buffer(int rbtype) {
|
|||
_glDrawBuffers(nbuffers, buffers);
|
||||
|
||||
} else {
|
||||
|
||||
switch (rbtype & RenderBuffer::T_color) {
|
||||
case RenderBuffer::T_front:
|
||||
glDrawBuffer(GL_FRONT);
|
||||
|
|
|
|||
|
|
@ -244,6 +244,21 @@ ConfigVariableBool gl_enable_memory_barriers
|
|||
"this off may give a slight performance increase, but you "
|
||||
"have to know what you're doing."));
|
||||
|
||||
ConfigVariableBool gl_vertex_array_objects
|
||||
("gl-vertex-array-objects", true,
|
||||
PRC_DESC("Setting this causes Panda to make use of vertex array "
|
||||
"objects to more efficiently switch between sets of "
|
||||
"vertex arrays. This only has effect when vertex-arrays "
|
||||
"and vertex-buffers are both set. This should usually be "
|
||||
"true unless you suspect a bug in the implementation. "));
|
||||
|
||||
ConfigVariableBool gl_support_primitive_restart_index
|
||||
("gl-support-primitive-restart-index", true,
|
||||
PRC_DESC("Setting this causes Panda to make use of primitive "
|
||||
"restart indices to more efficiently render line "
|
||||
"segment primitives. Set to false if you suspect a bug "
|
||||
"in the driver implementation."));
|
||||
|
||||
extern ConfigVariableBool gl_parallel_arrays;
|
||||
|
||||
void CLP(init_classes)() {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ extern ConfigVariableBool gl_dump_compiled_shaders;
|
|||
extern ConfigVariableBool gl_immutable_texture_storage;
|
||||
extern ConfigVariableBool gl_use_bindless_texture;
|
||||
extern ConfigVariableBool gl_enable_memory_barriers;
|
||||
extern ConfigVariableBool gl_vertex_array_objects;
|
||||
extern ConfigVariableBool gl_support_primitive_restart_index;
|
||||
|
||||
extern EXPCL_GL void CLP(init_classes)();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue