glIndexBufferContext_src.cxx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Filename: glIndexBufferContext_src.cxx
  2. // Created by: drose (17Mar05)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. TypeHandle CLP(IndexBufferContext)::_type_handle;
  15. ////////////////////////////////////////////////////////////////////
  16. // Function: GLIndexBufferContext::evict_lru
  17. // Access: Public, Virtual
  18. // Description: Evicts the page from the LRU. Called internally when
  19. // the LRU determines that it is full. May also be
  20. // called externally when necessary to explicitly evict
  21. // the page.
  22. //
  23. // It is legal for this method to either evict the page
  24. // as requested, do nothing (in which case the eviction
  25. // will be requested again at the next epoch), or
  26. // requeue itself on the tail of the queue (in which
  27. // case the eviction will be requested again much
  28. // later).
  29. ////////////////////////////////////////////////////////////////////
  30. void CLP(IndexBufferContext)::
  31. evict_lru() {
  32. dequeue_lru();
  33. // Make sure the buffer is unbound before we delete it.
  34. if (_glgsg->_current_ibuffer_index == _index) {
  35. if (GLCAT.is_debug() && CLP(debug_buffers)) {
  36. GLCAT.debug()
  37. << "unbinding index buffer\n";
  38. }
  39. _glgsg->_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
  40. _glgsg->_current_ibuffer_index = 0;
  41. }
  42. // Free the buffer.
  43. _glgsg->_glDeleteBuffers(1, &_index);
  44. // We still need a valid index number, though, in case we want to
  45. // re-load the buffer later.
  46. _glgsg->_glGenBuffers(1, &_index);
  47. update_data_size_bytes(0);
  48. mark_unloaded();
  49. }