7 #include "VertexBinding.h"
12 #define BindVertexArray(va) Eegeo_GL(glBindVertexArrayOES(va))
13 #elif defined(EEGEO_OSX)
14 #define BindVertexArray(va) Eegeo_GL(glBindVertexArrayAPPLE(va))
16 #define BindVertexArray(va)
23 namespace VertexBufferBindingHelpers
25 inline void UnbindVertexBuffers()
28 Eegeo_GL(glBindVertexArrayOES(0));
30 Eegeo_GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
31 Eegeo_GL(glBindBuffer(GL_ARRAY_BUFFER, 0));
35 inline void BindVertexBuffersImmediate(
const TVertexBufferId vertexBuffer,
36 const TIndexBufferId indexBuffer,
37 const VertexLayouts::VertexBinding* pVertexBinding,
38 Rendering::GLState& glState)
40 Eegeo_ASSERT(pVertexBinding != NULL);
42 Eegeo_GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer));
43 Eegeo_GL(glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer));
45 pVertexBinding->BindVertices();
48 inline void BindVertexBuffersImmediate(
const TVertexBufferId vertexBuffer,
49 const VertexLayouts::VertexBinding* pVertexBinding,
50 Rendering::GLState& glState)
52 Eegeo_ASSERT(pVertexBinding != NULL);
54 Eegeo_GL(glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer));
55 Eegeo_GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
57 pVertexBinding->BindVertices();
60 #if defined(EEGEO_IOS)
61 inline void BindVertexBuffersVAO(
const TVertexBufferId vertexBuffer,
62 const TIndexBufferId indexBuffer,
63 const VertexLayouts::VertexBinding* pVertexBinding,
64 Rendering::GLState& glState,
67 GLuint vertexArrayObject;
69 if(!vaoCache.TryGetVAOForVertexBinding(pVertexBinding, &vertexArrayObject))
71 vertexArrayObject = vaoCache.CreateVAOForVertexBinding(pVertexBinding);
73 BindVertexArray(vertexArrayObject);
75 BindVertexBuffersImmediate(vertexBuffer, indexBuffer, pVertexBinding, glState);
76 Eegeo_GL(glBindBuffer(GL_ARRAY_BUFFER, 0));
80 BindVertexArray(vertexArrayObject);
83 inline void BindVertexBuffersVAO(
const TVertexBufferId vertexBuffer,
84 const VertexLayouts::VertexBinding* pVertexBinding,
85 Rendering::GLState& glState,
88 GLuint vertexArrayObject;
90 if(!vaoCache.TryGetVAOForVertexBinding(pVertexBinding, &vertexArrayObject))
92 vertexArrayObject = vaoCache.CreateVAOForVertexBinding(pVertexBinding);
94 BindVertexArray(vertexArrayObject);
96 BindVertexBuffersImmediate(vertexBuffer, pVertexBinding, glState);
97 Eegeo_GL(glBindBuffer(GL_ARRAY_BUFFER, 0));
101 BindVertexArray(vertexArrayObject);