|
|
@@ -1537,6 +1537,20 @@ prepare_display_region(DisplayRegionPipelineReader *dr,
|
|
|
do_point_size();
|
|
|
}
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: GLGraphicsStateGuardian::clear_before_callback
|
|
|
+// Access: Public, Virtual
|
|
|
+// Description: Resets any non-standard graphics state that might
|
|
|
+// give a callback apoplexy. Some drivers require that
|
|
|
+// the graphics state be restored to neutral before
|
|
|
+// performing certain operations. In OpenGL, for
|
|
|
+// instance, this closes any open vertex buffers.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+void CLP(GraphicsStateGuardian)::
|
|
|
+clear_before_callback() {
|
|
|
+ unbind_buffers();
|
|
|
+}
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: GLGraphicsStateGuardian::calc_projection_mat
|
|
|
// Access: Public, Virtual
|
|
|
@@ -1955,22 +1969,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|
|
|
|
|
// Before we compile or call a display list, make sure the current
|
|
|
// buffers are unbound, or the nVidia drivers may crash.
|
|
|
- if (_current_vbuffer_index != 0) {
|
|
|
- if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
|
|
- GLCAT.debug()
|
|
|
- << "unbinding vertex buffer\n";
|
|
|
- }
|
|
|
- _glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
- _current_vbuffer_index = 0;
|
|
|
- }
|
|
|
- if (_current_ibuffer_index != 0) {
|
|
|
- if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
|
|
- GLCAT.debug()
|
|
|
- << "unbinding index buffer\n";
|
|
|
- }
|
|
|
- _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
|
- _current_ibuffer_index = 0;
|
|
|
- }
|
|
|
+ unbind_buffers();
|
|
|
|
|
|
GeomContext *gc = ((Geom *)geom_reader->get_object())->prepare_now(get_prepared_objects(), this);
|
|
|
nassertr(gc != (GeomContext *)NULL, false);
|
|
|
@@ -2303,6 +2302,35 @@ update_standard_vertex_arrays(bool force) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+// Function: GLGraphicsStateGuardian::unbind_buffers
|
|
|
+// Access: Protected
|
|
|
+// Description: Ensures the vertex and array buffers are no longer
|
|
|
+// bound. Some graphics drivers crash if these are left
|
|
|
+// bound indiscriminantly.
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
+void CLP(GraphicsStateGuardian)::
|
|
|
+unbind_buffers() {
|
|
|
+ if (_current_vbuffer_index != 0) {
|
|
|
+ if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
|
|
+ GLCAT.debug()
|
|
|
+ << "unbinding vertex buffer\n";
|
|
|
+ }
|
|
|
+ _glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
+ _current_vbuffer_index = 0;
|
|
|
+ }
|
|
|
+ if (_current_ibuffer_index != 0) {
|
|
|
+ if (GLCAT.is_debug() && CLP(debug_buffers)) {
|
|
|
+ GLCAT.debug()
|
|
|
+ << "unbinding index buffer\n";
|
|
|
+ }
|
|
|
+ _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
|
+ _current_ibuffer_index = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ disable_standard_vertex_arrays();
|
|
|
+}
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: GLGraphicsStateGuardian::disable_standard_vertex_arrays
|
|
|
// Access: Protected
|