Add GL function pointers for indirect draw

This commit is contained in:
rdb 2015-10-28 13:18:12 +01:00
parent be652bb112
commit bac5401a9d
5 changed files with 38 additions and 0 deletions

View File

@ -808,6 +808,18 @@ get_supports_geometry_instancing() const {
return _supports_geometry_instancing;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::get_supports_indirect_draw
// Access: Published
// Description: Returns true if this particular GSG supports
// draw calls for which the information comes from a
// buffer.
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsStateGuardian::
get_supports_indirect_draw() const {
return _supports_indirect_draw;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::get_supports_occlusion_query
// Access: Published

View File

@ -245,6 +245,7 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system,
_supports_stencil_wrap = false;
_supports_two_sided_stencil = false;
_supports_geometry_instancing = false;
_supports_indirect_draw = false;
// Assume a maximum of 1 render target in absence of MRT.
_max_color_targets = 1;

View File

@ -160,6 +160,7 @@ PUBLISHED:
INLINE bool get_supports_stencil() const;
INLINE bool get_supports_two_sided_stencil() const;
INLINE bool get_supports_geometry_instancing() const;
INLINE bool get_supports_indirect_draw() const;
INLINE bool get_supports_occlusion_query() const;
INLINE bool get_supports_timer_query() const;
@ -538,6 +539,7 @@ protected:
bool _supports_stencil_wrap;
bool _supports_two_sided_stencil;
bool _supports_geometry_instancing;
bool _supports_indirect_draw;
int _max_color_targets;

View File

@ -1757,6 +1757,24 @@ reset() {
}
#endif
// Check if we support indirect draw.
_supports_indirect_draw = false;
#ifndef OPENGLES
if (is_at_least_gl_version(4, 0) || has_extension("GL_ARB_draw_indirect")) {
_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)
get_extension_func("glDrawArraysIndirect");
_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)
get_extension_func("glDrawElementsIndirect");
if (_glDrawArraysIndirect == NULL || _glDrawElementsIndirect == NULL) {
GLCAT.warning()
<< "Indirect draw advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n";
} else {
_supports_indirect_draw = true;
}
}
#endif
#ifdef OPENGLES_2
// In OpenGL ES 2.x, FBO's are supported in the core.
_supports_framebuffer_object = true;

View File

@ -763,6 +763,11 @@ public:
PFNGLDELETEVERTEXARRAYSPROC _glDeleteVertexArrays;
PFNGLGENVERTEXARRAYSPROC _glGenVertexArrays;
#ifndef OPENGLES
PFNGLDRAWARRAYSINDIRECTPROC _glDrawArraysIndirect;
PFNGLDRAWELEMENTSINDIRECTPROC _glDrawElementsIndirect;
#endif
bool _supports_framebuffer_object;
PFNGLISRENDERBUFFEREXTPROC _glIsRenderbuffer;
PFNGLBINDRENDERBUFFEREXTPROC _glBindRenderbuffer;