Advertisement
Guest User

Untitled

a guest
Mar 10th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.78 KB | None | 0 0
  1. DLL_EXPORT void devRenderQueue2(Renderable* queue, char* const perObject, int perObjectSize, int queueSize, char* const perFrame, int poBuffer, int pfBuffer, unsigned shader, int primitive)
  2. {
  3.     if(queueSize <= 0)
  4.         return;
  5.     //Device::CheckError("Error came from another place. Fuck. %c");
  6.     Device::UseProgram(shader);
  7.     //Debug::Log("Binding shader program: %i", shader);
  8.     //Device::CheckError("Error binding shader. %c");
  9.  
  10.     if (pfBuffer >= 0)
  11.         ConstantBuffer::Update(pfBuffer, perFrame);
  12.  
  13.     unsigned maxUsedTextures = 0;
  14.  
  15.     for (int i = 0; i < queueSize; ++i)
  16.     {
  17.         Device::BindVertexArray(queue[i].vao);
  18.         //Debug::Log("Binding VAO: %i", queue[i].vao);
  19.         //Device::CheckError("Error binding VAO.");
  20.  
  21.  
  22.         if(maxUsedTextures < queue[i].textureCount)
  23.             maxUsedTextures = queue[i].textureCount;
  24.  
  25.         for (unsigned j = 0; j < queue[i].textureCount; ++j)
  26.         {
  27.             Device::BindTexture2D(GL_TEXTURE0 + j, queue[i].textures[j]);
  28.             //Debug::Log("Binding texture: %i. Total: %i", queue[i].textures[j], j);
  29.             //Device::CheckError("Error binding Texture: %c");
  30.         }
  31.         if(poBuffer >= 0)
  32.         {
  33.             ConstantBuffer::Update(poBuffer, (perObject + perObjectSize * i));
  34.         }
  35.         if(queue[i].baseVertex)
  36.             glDrawElementsBaseVertex(primitive, queue[i].numIndices, GL_UNSIGNED_INT, NULL, queue[i].baseVertex);
  37.         else
  38.             glDrawElements(primitive, queue[i].numIndices, GL_UNSIGNED_INT, NULL);
  39.         //Debug::Log("Draw stuff: Base Vertex: %i, Number of Indices: %i, Primitive: %i", queue[i].numIndices, queue[i].baseVertex, primitive);
  40.         //Device::CheckError("Error drawing stuff: %c");
  41.     }
  42.  
  43.     for (unsigned i = 0; i < maxUsedTextures; ++i)
  44.     {
  45.         Device::BindTexture2D(GL_TEXTURE0 + i, 0);
  46.     }
  47.  
  48.     Device::BindVertexArray(0);
  49.     Device::UseProgram(0);
  50. }
  51.  
  52. // size in floats
  53. DLL_EXPORT void devRenderQueue3(Renderable* queue, float* const perObject, int perObjectSize, int queueSize, float* const perFrame, int perFrameSize, int poBuffer, int pfBuffer, unsigned shader, int primitive)
  54. {
  55.     if (queueSize <= 0)
  56.         return;
  57.     // Device::CheckError("Error came from another place. Fuck. %c");
  58.     Device::UseProgram(shader);
  59.     // Debug::Log("Binding shader program: %i", shader);
  60.     // Device::CheckError("Error binding shader. %c");
  61.  
  62.     if (pfBuffer >= 0)
  63.     {
  64.         glUniformMatrix4fv(pfBuffer, perFrameSize / 16, false, perFrame);
  65.         // Device::CheckError("Error binding pfBuffer. %c");
  66.     }
  67.  
  68.     unsigned maxUsedTextures = 0;
  69.  
  70.     for (int i = 0; i < queueSize; ++i)
  71.     {
  72.         Device::BindVertexArray(queue[i].vao);
  73.         //Debug::Log("Binding VAO: %i", queue[i].vao);
  74.         // Device::CheckError("Error binding VAO.");
  75.  
  76.  
  77.         if (maxUsedTextures < queue[i].textureCount)
  78.             maxUsedTextures = queue[i].textureCount;
  79.  
  80.         for (unsigned j = 0; j < queue[i].textureCount; ++j)
  81.         {
  82.             Device::BindTexture2D(GL_TEXTURE0 + j, queue[i].textures[j]);
  83.             //Debug::Log("Binding texture: %i. Total: %i", queue[i].textures[j], j);
  84.             // Device::CheckError("Error binding Texture: %c");
  85.         }
  86.  
  87.         if(poBuffer >= 0)
  88.             glUniformMatrix4fv(poBuffer, perObjectSize / 16, false, (perObject + perObjectSize * i));
  89.  
  90.         if (queue[i].baseVertex)
  91.             glDrawElementsBaseVertex(primitive, queue[i].numIndices, GL_UNSIGNED_INT, NULL, queue[i].baseVertex);
  92.         else
  93.             glDrawElements(primitive, queue[i].numIndices, GL_UNSIGNED_INT, NULL);
  94.         //Debug::Log("Draw stuff: Base Vertex: %i, Number of Indices: %i, Primitive: %i", queue[i].numIndices, queue[i].baseVertex, primitive);
  95.         //Device::CheckError("Error drawing stuff: %c");
  96.     }
  97.  
  98.     for (unsigned i = 0; i < maxUsedTextures; ++i)
  99.     {
  100.         Device::BindTexture2D(GL_TEXTURE0 + i, 0);
  101.     }
  102.  
  103.     Device::BindVertexArray(0);
  104.     Device::UseProgram(0);
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement