MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / drawTexturedRect3D

Method drawTexturedRect3D

examples/OpenGLWindow/GLPrimitiveRenderer.cpp:222–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222void GLPrimitiveRenderer::drawTexturedRect3D(const PrimVertex &v0, const PrimVertex &v1, const PrimVertex &v2, const PrimVertex &v3, float viewMat[16], float projMat[16], bool useRGBA)
223{
224 //B3_PROFILE("GLPrimitiveRenderer::drawTexturedRect3D");
225
226 b3Assert(glGetError() == GL_NO_ERROR);
227
228 glUseProgram(m_data->m_shaderProg);
229
230 glUniformMatrix4fv(m_data->m_viewmatUniform, 1, false, viewMat);
231 glUniformMatrix4fv(m_data->m_projMatUniform, 1, false, projMat);
232
233 b3Assert(glGetError() == GL_NO_ERROR);
234
235 glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vertexBuffer);
236 glBindVertexArray(m_data->m_vertexArrayObject);
237
238 bool useFiltering = false;
239 if (useFiltering)
240 {
241 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
242 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
243 }
244 else
245 {
246 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
247 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
248 }
249
250 PrimVertex vertexData[4] = {
251 v0, v1, v2, v3};
252
253 glBufferSubData(GL_ARRAY_BUFFER, 0, 4 * sizeof(PrimVertex), vertexData);
254
255 b3Assert(glGetError() == GL_NO_ERROR);
256
257 PrimVec2 p(0.f, 0.f); //?b?0.5f * sinf(timeValue), 0.5f * cosf(timeValue) );
258 if (useRGBA)
259 {
260 p.p[0] = 1.f;
261 p.p[1] = 1.f;
262 }
263
264 glUniform2fv(m_data->m_positionUniform, 1, (const GLfloat *)&p);
265
266 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
267
268 b3Assert(glGetError() == GL_NO_ERROR);
269
270 glEnableVertexAttribArray(m_data->m_positionAttribute);
271 b3Assert(glGetError() == GL_NO_ERROR);
272
273 glEnableVertexAttribArray(m_data->m_colourAttribute);
274 b3Assert(glGetError() == GL_NO_ERROR);
275
276 glEnableVertexAttribArray(m_data->m_textureAttribute);
277
278 glVertexAttribPointer(m_data->m_positionAttribute, 4, GL_FLOAT, GL_FALSE, sizeof(PrimVertex), (const GLvoid *)0);
279 glVertexAttribPointer(m_data->m_colourAttribute, 4, GL_FLOAT, GL_FALSE, sizeof(PrimVertex), (const GLvoid *)sizeof(PrimVec4));

Callers 1

drawText3DMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected