MCPcopy Create free account
hub / github.com/Kitware/VTK / CoreDrawTriangles

Method CoreDrawTriangles

Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx:1269–1341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1267}
1268
1269void vtkOpenGLContextDevice2D::CoreDrawTriangles(
1270 std::vector<float>& tverts, unsigned char* colors, int numComp)
1271{
1272 if (SkipDraw())
1273 {
1274 return;
1275 }
1276
1277 vtkOpenGLClearErrorMacro();
1278
1279 float* texCoord = nullptr;
1280 vtkOpenGLHelper* cbo = nullptr;
1281 if (this->Brush->GetTexture())
1282 {
1283 this->ReadyVTBOProgram();
1284 cbo = this->VTBO;
1285 if (!cbo->Program)
1286 {
1287 return;
1288 }
1289 this->SetTexture(this->Brush->GetTexture(), this->Brush->GetTextureProperties());
1290 this->Storage->Texture->Render(this->Renderer);
1291 texCoord = this->Storage->TexCoords(tverts.data(), static_cast<int>(tverts.size() / 2));
1292
1293 int tunit = vtkOpenGLTexture::SafeDownCast(this->Storage->Texture)->GetTextureUnit();
1294 cbo->Program->SetUniformi("texture1", tunit);
1295 }
1296 else if (colors && numComp > 0)
1297 {
1298 this->ReadyVCBOProgram();
1299 cbo = this->VCBO;
1300 }
1301 else
1302 {
1303 // Skip transparent elements.
1304 if (this->Brush->GetColorObject().GetAlpha() == 0)
1305 {
1306 return;
1307 }
1308 this->ReadyVBOProgram();
1309 cbo = this->VBO;
1310 }
1311
1312 if (!cbo->Program)
1313 {
1314 return;
1315 }
1316
1317 cbo->Program->SetUniform4uc("vertexColor", this->Brush->GetColor());
1318
1319 this->BuildVBO(
1320 cbo, tverts.data(), static_cast<int>(tverts.size() / 2), colors, numComp, texCoord);
1321
1322 this->SetMatrices(cbo->Program);
1323
1324 PreDraw(*cbo, GL_TRIANGLES, tverts.size() / 2);
1325
1326 auto timer = this->RenderWindow->GetRenderTimer();

Callers 6

DrawQuadMethod · 0.95
DrawQuadStripMethod · 0.95
DrawPolygonMethod · 0.95
DrawColoredPolygonMethod · 0.95
DrawEllipseWedgeMethod · 0.95
DrawPolygonsMethod · 0.80

Calls 15

ReadyVTBOProgramMethod · 0.95
SetTextureMethod · 0.95
ReadyVCBOProgramMethod · 0.95
ReadyVBOProgramMethod · 0.95
BuildVBOMethod · 0.95
SetMatricesMethod · 0.95
SkipDrawFunction · 0.85
PreDrawFunction · 0.85
PostDrawFunction · 0.85
TexCoordsMethod · 0.80
GetAlphaMethod · 0.80
RenderMethod · 0.65

Tested by

no test coverage detected