MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / DrawPrimitive

Method DrawPrimitive

GTE/Graphics/GL46/GL46Engine.cpp:173–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173uint64_t GL46Engine::DrawPrimitive(VertexBuffer const* vbuffer, IndexBuffer const* ibuffer)
174{
175 uint32_t numActiveVertices = vbuffer->GetNumActiveElements();
176 uint32_t vertexOffset = vbuffer->GetOffset();
177
178 uint32_t numActiveIndices = ibuffer->GetNumActiveIndices();
179 uint32_t indexSize = ibuffer->GetElementSize();
180 GLenum indexType = (indexSize == 4 ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT);
181
182 GLenum topology = 0;
183 uint32_t type = ibuffer->GetPrimitiveType();
184 switch (type)
185 {
186 case IP_POLYPOINT:
187 topology = GL_POINTS;
188 break;
189 case IP_POLYSEGMENT_DISJOINT:
190 topology = GL_LINES;
191 break;
192 case IP_POLYSEGMENT_CONTIGUOUS:
193 topology = GL_LINE_STRIP;
194 break;
195 case IP_TRIMESH:
196 topology = GL_TRIANGLES;
197 break;
198 case IP_TRISTRIP:
199 topology = GL_TRIANGLE_STRIP;
200 break;
201 case IP_POLYSEGMENT_DISJOINT_ADJ:
202 topology = GL_LINES_ADJACENCY;
203 break;
204 case IP_POLYSEGMENT_CONTIGUOUS_ADJ:
205 topology = GL_LINE_STRIP_ADJACENCY;
206 break;
207 case IP_TRIMESH_ADJ:
208 topology = GL_TRIANGLES_ADJACENCY;
209 break;
210 case IP_TRISTRIP_ADJ:
211 topology = GL_TRIANGLE_STRIP_ADJACENCY;
212 break;
213 default:
214 LogError("Unknown primitive topology = " + std::to_string(type));
215 }
216
217 GLuint occlusionQuery = 0;
218 uint64_t numPixelsDrawn = 0;
219 if (mAllowOcclusionQuery)
220 {
221 occlusionQuery = BeginOcclusionQuery();
222 }
223
224 if (ibuffer->IsIndexed())
225 {
226 uint32_t offset = ibuffer->GetOffset();
227 void const* data = reinterpret_cast<void const*>(static_cast<size_t>(indexSize) * static_cast<size_t>(offset));
228 glDrawRangeElements(topology, 0, numActiveVertices - 1,
229 static_cast<GLsizei>(numActiveIndices), indexType, data);
230 }

Callers

nothing calls this directly

Calls 15

glDrawRangeElementsFunction · 0.85
glDrawArraysFunction · 0.85
glUseProgramFunction · 0.85
GetNumActiveIndicesMethod · 0.80
GetElementSizeMethod · 0.80
GetPrimitiveTypeMethod · 0.80
IsIndexedMethod · 0.80
StandardUsageMethod · 0.80
GetGLHandleMethod · 0.80
GetNumActiveElementsMethod · 0.45
GetOffsetMethod · 0.45
GetProgramHandleMethod · 0.45

Tested by

no test coverage detected