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

Method drawLines

examples/OpenGLWindow/GLInstancingRenderer.cpp:1991–2050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1989}
1990
1991void GLInstancingRenderer::drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float lineWidthIn)
1992{
1993 glActiveTexture(GL_TEXTURE0);
1994 glBindTexture(GL_TEXTURE_2D, 0);
1995
1996 float lineWidth = lineWidthIn;
1997 b3Clamp(lineWidth, (float)lineWidthRange[0], (float)lineWidthRange[1]);
1998 glLineWidth(lineWidth);
1999
2000 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2001
2002 glActiveTexture(GL_TEXTURE0);
2003 glBindTexture(GL_TEXTURE_2D, 0);
2004
2005 b3Assert(glGetError() == GL_NO_ERROR);
2006 glUseProgram(linesShader);
2007 glUniformMatrix4fv(lines_ProjectionMatrix, 1, false, &m_data->m_projectionMatrix[0]);
2008 glUniformMatrix4fv(lines_ModelViewMatrix, 1, false, &m_data->m_viewMatrix[0]);
2009 glUniform4f(lines_colour, color[0], color[1], color[2], color[3]);
2010
2011 // glPointSize(pointDrawSize);
2012 glBindVertexArray(linesVertexArrayObject);
2013
2014 b3Assert(glGetError() == GL_NO_ERROR);
2015 glBindBuffer(GL_ARRAY_BUFFER, linesVertexBufferObject);
2016
2017 {
2018 glBufferData(GL_ARRAY_BUFFER, numPoints * pointStrideInBytes, 0, GL_DYNAMIC_DRAW);
2019
2020 glBufferSubData(GL_ARRAY_BUFFER, 0, numPoints * pointStrideInBytes, positions);
2021 b3Assert(glGetError() == GL_NO_ERROR);
2022 glBindBuffer(GL_ARRAY_BUFFER, 0);
2023 glBindBuffer(GL_ARRAY_BUFFER, linesVertexBufferObject);
2024 glEnableVertexAttribArray(0);
2025
2026 b3Assert(glGetError() == GL_NO_ERROR);
2027 int numFloats = 3;
2028 glVertexAttribPointer(0, numFloats, GL_FLOAT, GL_FALSE, pointStrideInBytes, 0);
2029 b3Assert(glGetError() == GL_NO_ERROR);
2030
2031 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, linesIndexVbo);
2032 int indexBufferSizeInBytes = numIndices * sizeof(int);
2033
2034 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexBufferSizeInBytes, NULL, GL_DYNAMIC_DRAW);
2035 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexBufferSizeInBytes, indices);
2036
2037 glDrawElements(GL_LINES, numIndices, GL_UNSIGNED_INT, 0);
2038 }
2039
2040 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2041 glBindBuffer(GL_ARRAY_BUFFER, 0);
2042 // for (int i=0;i<numIndices;i++)
2043 // printf("indicec[i]=%d]\n",indices[i]);
2044 b3Assert(glGetError() == GL_NO_ERROR);
2045 glBindVertexArray(0);
2046 b3Assert(glGetError() == GL_NO_ERROR);
2047 glPointSize(1);
2048 b3Assert(glGetError() == GL_NO_ERROR);

Callers 9

drawGridMethod · 0.45
drawGridMethod · 0.45
flushLinesFunction · 0.45
drawMethod · 0.45
renderSceneMethod · 0.45
drawUserDebugLinesMethod · 0.45
drawMethod · 0.45
physicsDebugDrawMethod · 0.45

Calls 1

b3ClampFunction · 0.85

Tested by

no test coverage detected