Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Internals/OpenGLLinesProgram.cpp @ 698:8b6adfb62a2f refactor-viewport-controller
Code is broken -- stashing ongoing work in a branch
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 15 May 2019 16:56:17 +0200 |
parents | e3f21a265be5 |
children | 5c551f078c18 |
comparison
equal
deleted
inserted
replaced
660:cb3b76d16234 | 698:8b6adfb62a2f |
---|---|
203 { | 203 { |
204 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 204 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
205 } | 205 } |
206 | 206 |
207 // First triangle | 207 // First triangle |
208 coords.push_back(x1_); | 208 coords.push_back(static_cast<float>(x1_)); |
209 coords.push_back(y1_); | 209 coords.push_back(static_cast<float>(y1_)); |
210 coords.push_back(1); | 210 coords.push_back(static_cast<float>(1)); |
211 coords.push_back(x2_); | 211 coords.push_back(static_cast<float>(x2_)); |
212 coords.push_back(y2_); | 212 coords.push_back(static_cast<float>(y2_)); |
213 coords.push_back(-1); | 213 coords.push_back(static_cast<float>(-1)); |
214 coords.push_back(x2_); | 214 coords.push_back(static_cast<float>(x2_)); |
215 coords.push_back(y2_); | 215 coords.push_back(static_cast<float>(y2_)); |
216 coords.push_back(1); | 216 coords.push_back(static_cast<float>(1)); |
217 | 217 |
218 miterDirections.push_back(miterX1_); | 218 miterDirections.push_back(static_cast<float>(miterX1_)); |
219 miterDirections.push_back(miterY1_); | 219 miterDirections.push_back(static_cast<float>(miterY1_)); |
220 miterDirections.push_back(miterX2_); | 220 miterDirections.push_back(static_cast<float>(miterX2_)); |
221 miterDirections.push_back(miterY2_); | 221 miterDirections.push_back(static_cast<float>(miterY2_)); |
222 miterDirections.push_back(miterX2_); | 222 miterDirections.push_back(static_cast<float>(miterX2_)); |
223 miterDirections.push_back(miterY2_); | 223 miterDirections.push_back(static_cast<float>(miterY2_)); |
224 | 224 |
225 // Second triangle | 225 // Second triangle |
226 coords.push_back(x1_); | 226 coords.push_back(static_cast<float>(x1_)); |
227 coords.push_back(y1_); | 227 coords.push_back(static_cast<float>(y1_)); |
228 coords.push_back(1); | 228 coords.push_back(static_cast<float>(1)); |
229 coords.push_back(x1_); | 229 coords.push_back(static_cast<float>(x1_)); |
230 coords.push_back(y1_); | 230 coords.push_back(static_cast<float>(y1_)); |
231 coords.push_back(-1); | 231 coords.push_back(static_cast<float>(-1)); |
232 coords.push_back(x2_); | 232 coords.push_back(static_cast<float>(x2_)); |
233 coords.push_back(y2_); | 233 coords.push_back(static_cast<float>(y2_)); |
234 coords.push_back(-1); | 234 coords.push_back(static_cast<float>(-1)); |
235 | 235 |
236 miterDirections.push_back(miterX1_); | 236 miterDirections.push_back(static_cast<float>(miterX1_)); |
237 miterDirections.push_back(miterY1_); | 237 miterDirections.push_back(static_cast<float>(miterY1_)); |
238 miterDirections.push_back(miterX1_); | 238 miterDirections.push_back(static_cast<float>(miterX1_)); |
239 miterDirections.push_back(miterY1_); | 239 miterDirections.push_back(static_cast<float>(miterY1_)); |
240 miterDirections.push_back(miterX2_); | 240 miterDirections.push_back(static_cast<float>(miterX2_)); |
241 miterDirections.push_back(miterY2_); | 241 miterDirections.push_back(static_cast<float>(miterY2_)); |
242 } | 242 } |
243 }; | 243 }; |
244 | 244 |
245 | 245 |
246 OpenGLLinesProgram::Data::Data(OpenGL::IOpenGLContext& context, | 246 OpenGLLinesProgram::Data::Data(OpenGL::IOpenGLContext& context, |
247 const PolylineSceneLayer& layer) : | 247 const PolylineSceneLayer& layer) : |
248 context_(context), | 248 context_(context), |
249 verticesCount_(0), | 249 verticesCount_(0), |
250 thickness_(layer.GetThickness()), | 250 thickness_(static_cast<float>(layer.GetThickness())), |
251 red_(layer.GetRedAsFloat()), | 251 red_(layer.GetRedAsFloat()), |
252 green_(layer.GetGreenAsFloat()), | 252 green_(layer.GetGreenAsFloat()), |
253 blue_(layer.GetBlueAsFloat()) | 253 blue_(layer.GetBlueAsFloat()) |
254 { | 254 { |
255 // High-level reference: | 255 // High-level reference: |
416 if (antialiasing) | 416 if (antialiasing) |
417 { | 417 { |
418 double t1 = std::max(thickness, aliasingBorder); | 418 double t1 = std::max(thickness, aliasingBorder); |
419 double t0 = std::max(0.0, thickness - aliasingBorder); | 419 double t0 = std::max(0.0, thickness - aliasingBorder); |
420 | 420 |
421 glUniform1f(program_->GetUniformLocation("u_thickness"), t1 / zoom); | 421 glUniform1f(program_->GetUniformLocation("u_thickness"), |
422 glUniform1f(program_->GetUniformLocation("u_antialiasing_start"), t0 / t1); | 422 static_cast<GLfloat>(t1 / zoom)); |
423 glUniform1f(program_->GetUniformLocation("u_antialiasing_start"), | |
424 static_cast<GLfloat>(t0 / t1)); | |
423 } | 425 } |
424 else | 426 else |
425 { | 427 { |
426 glUniform1f(program_->GetUniformLocation("u_thickness"), thickness / zoom); | 428 glUniform1f(program_->GetUniformLocation("u_thickness"), |
429 static_cast<GLfloat>(thickness / zoom)); | |
427 } | 430 } |
428 } | 431 } |
429 else | 432 else |
430 { | 433 { |
431 if (antialiasing) | 434 if (antialiasing) |
432 { | 435 { |
433 double t1 = std::max(thickness, aliasingBorder / zoom); | 436 double t1 = std::max(thickness, aliasingBorder / zoom); |
434 double t0 = std::max(0.0, thickness - aliasingBorder / zoom); | 437 double t0 = std::max(0.0, thickness - aliasingBorder / zoom); |
435 | 438 |
436 glUniform1f(program_->GetUniformLocation("u_thickness"), t1); | 439 glUniform1f(program_->GetUniformLocation("u_thickness"), |
437 glUniform1f(program_->GetUniformLocation("u_antialiasing_start"), t0 / t1); | 440 static_cast<GLfloat>(t1)); |
441 glUniform1f(program_->GetUniformLocation("u_antialiasing_start"), | |
442 static_cast<GLfloat>(t0 / t1)); | |
438 } | 443 } |
439 else | 444 else |
440 { | 445 { |
441 glUniform1f(program_->GetUniformLocation("u_thickness"), thickness); | 446 glUniform1f(program_->GetUniformLocation("u_thickness"), |
447 static_cast<GLfloat>(thickness)); | |
442 } | 448 } |
443 } | 449 } |
444 | 450 |
445 if (antialiasing) | 451 if (antialiasing) |
446 { | 452 { |
447 glEnable(GL_BLEND); | 453 glEnable(GL_BLEND); |
448 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | 454 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
449 glDrawArrays(GL_TRIANGLES, 0, data.GetVerticesCount()); | 455 glDrawArrays(GL_TRIANGLES, 0, |
456 static_cast<GLsizei>(data.GetVerticesCount())); | |
450 glDisable(GL_BLEND); | 457 glDisable(GL_BLEND); |
451 } | 458 } |
452 else | 459 else |
453 { | 460 { |
454 glDrawArrays(GL_TRIANGLES, 0, data.GetVerticesCount()); | 461 glDrawArrays(GL_TRIANGLES, 0, |
462 static_cast<GLsizei>(data.GetVerticesCount())); | |
455 } | 463 } |
456 | 464 |
457 glDisableVertexAttribArray(locationPosition); | 465 glDisableVertexAttribArray(locationPosition); |
458 glDisableVertexAttribArray(locationMiterDirection); | 466 glDisableVertexAttribArray(locationMiterDirection); |
459 } | 467 } |