Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 221 vs 223 for /trunk/Source Code/Libs/src/GLIM/glimBatchData.cpp

Diff revisions: vs.
  @@ -70,10 +70,10 @@
70 70 }
71 71 }
72 72
73 - void glimBatchData::Upload (void)
73 + void glimBatchData::Upload (unsigned int uiCurrentProgram)
74 74 {
75 75 #ifdef AE_RENDERAPI_OPENGL
76 - UploadOGL ();
76 + UploadOGL (uiCurrentProgram);
77 77 #else
78 78 UploadD3D11 ();
79 79 #endif
  @@ -108,6 +108,8 @@
108 108 m_pIndexBuffer_Lines = NULL;
109 109 m_pIndexBuffer_Triangles = NULL;
110 110 m_pIndexBuffer_Wireframe = NULL;
111 + #else
112 + vaoID = 0;
111 113 #endif
112 114
113 115 Reset ();
  @@ -127,7 +129,10 @@
127 129 glDeleteBuffers (1, &m_uiElementBufferID_Lines);
128 130 glDeleteBuffers (1, &m_uiElementBufferID_Triangles);
129 131 glDeleteBuffers (1, &m_uiElementBufferID_Wireframe);
132 + glDeleteVertexArrays(1, &vaoID);
133 + vaoID = 0;
130 134 }
135 +
131 136 #endif
132 137 }
133 138
  @@ -370,19 +375,17 @@
370 375
371 376 void glimBatchData::UnbindOGL (void)
372 377 {
373 - // make sure no VAO is bound, such that GLIM does not accidently change it's state
374 -
375 - // if the pointer is != NULL, the extension should be available
376 - if (glBindVertexArray)
377 - {
378 - glBindVertexArray (0);
379 - }
380 378
381 - glBindBuffer (GL_ARRAY_BUFFER, 0);
379 + /*glBindBuffer (GL_ARRAY_BUFFER, 0);
382 380 glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
383 381
384 382 for (int i = 0; i < 16; ++i)
385 383 glDisableVertexAttribArray (i);
384 + */
385 + if (glBindVertexArray)
386 + {
387 + glBindVertexArray (0);
388 + }
386 389 }
387 390
388 391 void glimBatchData::BindOGL (unsigned int uiCurrentProgram)
  @@ -395,7 +398,7 @@
395 398 // if the pointer is != NULL, the extension should be available
396 399 if (glBindVertexArray)
397 400 {
398 - glBindVertexArray (0);
401 + glBindVertexArray (vaoID);
399 402 }
400 403
401 404 if (GLEW_NV_vertex_buffer_unified_memory)
  @@ -453,9 +456,10 @@
453 456 // set the pointer for position last
454 457 glEnableVertexAttribArray (m_VertAttribLocation);
455 458 glVertexAttribPointer (m_VertAttribLocation, 3, GL_FLOAT, false, 0, BUFFER_OFFSET (0));
459 +
456 460 }
457 461
458 - void glimBatchData::UploadOGL (void)
462 + void glimBatchData::UploadOGL (unsigned int uiCurrentProgram)
459 463 {
460 464 if (m_bUploadedToGPU)
461 465 return;
  @@ -464,15 +468,7 @@
464 468 return;
465 469
466 470 m_bUploadedToGPU = true;
467 -
468 -
469 - // make sure no VAO is bound, such that GLIM does not accidently change it's state
470 -
471 - // if the pointer is != NULL, the extension should be available
472 - if (glBindVertexArray)
473 - {
474 - glBindVertexArray (0);
475 - }
471 +
476 472
477 473 if (GLEW_NV_vertex_buffer_unified_memory)
478 474 {
  @@ -486,15 +482,14 @@
486 482 if (!m_bCreatedVBOs)
487 483 {
488 484 m_bCreatedVBOs = true;
489 -
485 + glGenVertexArrays(1, &vaoID);
490 486 glGenBuffers (1, &m_uiVertexBufferID);
491 487 glGenBuffers (1, &m_uiElementBufferID_Points);
492 488 glGenBuffers (1, &m_uiElementBufferID_Lines);
493 489 glGenBuffers (1, &m_uiElementBufferID_Triangles);
494 490 glGenBuffers (1, &m_uiElementBufferID_Wireframe);
495 491 }
496 -
497 -
492 +
498 493 glBindBuffer (GL_ARRAY_BUFFER, m_uiVertexBufferID);
499 494 glBufferData (GL_ARRAY_BUFFER, uiVertices * uiVertexDataSize, NULL, GL_STATIC_DRAW);
500 495
  @@ -567,16 +562,7 @@
567 562 m_IndexBuffer_Triangles.clear ();
568 563 }
569 564
570 -
571 - // upload the index buffer for wireframe
572 - glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, m_uiElementBufferID_Wireframe);
573 -
574 - if (!m_IndexBuffer_Wireframe.empty ())
575 - {
576 - m_uiWireframeElements = (unsigned int) m_IndexBuffer_Wireframe.size ();
577 - glBufferData (GL_ELEMENT_ARRAY_BUFFER, m_IndexBuffer_Wireframe.size () * 4, &m_IndexBuffer_Wireframe[0], GL_STATIC_DRAW);
578 - m_IndexBuffer_Wireframe.clear ();
579 - }
565 +
580 566 }
581 567 #endif
582 568 }