| 247 | }; |
| 248 | |
| 249 | void GLDrawBatch::Render(RenderDevice* renderDevice, RenderWindow* renderWindow) |
| 250 | { |
| 251 | if (mIdxIdx == 0) |
| 252 | return; |
| 253 | |
| 254 | gBFDrawBatchCount++; |
| 255 | |
| 256 | GLRenderDevice* glRenderDevice = (GLRenderDevice*) gBFApp->mRenderDevice; |
| 257 | GLShader* curShader = (GLShader*)mRenderState->mShader; |
| 258 | |
| 259 | if (glRenderDevice->mGLVAO == 0) |
| 260 | { |
| 261 | bf_glGenVertexArrays(1, &glRenderDevice->mGLVAO); |
| 262 | bf_glBindVertexArray(glRenderDevice->mGLVAO); |
| 263 | |
| 264 | bf_glGenBuffers(1, &glRenderDevice->mGLVertexBuffer); |
| 265 | bf_glGenBuffers(1, &glRenderDevice->mGLIndexBuffer); |
| 266 | } |
| 267 | |
| 268 | auto glVertices = (GLVertex3D*)mVertices; |
| 269 | |
| 270 | bf_glBindBuffer(GL_ARRAY_BUFFER, glRenderDevice->mGLVertexBuffer); |
| 271 | bf_glBufferData(GL_ARRAY_BUFFER, mVtxIdx * sizeof(GLVertex3D), mVertices, GL_STREAM_DRAW); |
| 272 | |
| 273 | bf_glEnableVertexAttribArray(curShader->mAttribPosition); |
| 274 | bf_glVertexAttribPointer(curShader->mAttribPosition, 3, GL_FLOAT, GL_FALSE, sizeof(GLVertex3D), (void*)offsetof(GLVertex3D, x)); |
| 275 | bf_glEnableVertexAttribArray(curShader->mAttribTexCoord0); |
| 276 | bf_glVertexAttribPointer(curShader->mAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(GLVertex3D), (void*)offsetof(GLVertex3D, u)); |
| 277 | bf_glEnableVertexAttribArray(curShader->mAttribColor); |
| 278 | bf_glVertexAttribPointer(curShader->mAttribColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(GLVertex3D), (void*)offsetof(GLVertex3D, color)); |
| 279 | |
| 280 | if (mRenderState != renderDevice->mPhysRenderState) |
| 281 | renderDevice->PhysSetRenderState(mRenderState); |
| 282 | |
| 283 | bf_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glRenderDevice->mGLIndexBuffer); |
| 284 | bf_glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIdxIdx * sizeof(int16), mIndices, GL_STREAM_DRAW); |
| 285 | bf_glDrawElements(GL_TRIANGLES, mIdxIdx, GL_UNSIGNED_SHORT, NULL); |
| 286 | |
| 287 | bf_glBufferData(GL_ELEMENT_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW); |
| 288 | bf_glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW); |
| 289 | } |
| 290 | |
| 291 | GLDrawLayer::GLDrawLayer() |
| 292 | { |
nothing calls this directly
no test coverage detected