| 166 | } |
| 167 | |
| 168 | void Shader::Render(IndexBuf* ibuf, glm::mat4* mvpMat) { |
| 169 | MY_ASSERT(mPreparedVertexBuf != NULL); |
| 170 | |
| 171 | // push MVP matrix to shader |
| 172 | PushMVPMatrix(mvpMat); |
| 173 | |
| 174 | if (ibuf) { |
| 175 | // draw with index buffer |
| 176 | ibuf->BindBuffer(); |
| 177 | glDrawElements(mPreparedVertexBuf->GetPrimitive(), ibuf->GetCount(), |
| 178 | GL_UNSIGNED_SHORT, nullptr); |
| 179 | ibuf->UnbindBuffer(); |
| 180 | } else { |
| 181 | // draw straight from vertex buffer |
| 182 | glDrawArrays(mPreparedVertexBuf->GetPrimitive(), 0, |
| 183 | mPreparedVertexBuf->GetCount()); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | void Shader::EndRender() { |
| 188 | if (mPreparedVertexBuf) { |
no test coverage detected