| 1267 | } |
| 1268 | |
| 1269 | void 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(); |
no test coverage detected