refactoring

wireframe display
worked on 3d-model display
This commit is contained in:
2018-02-08 21:38:51 +01:00
parent bce771d6d6
commit 839401edb7
16 changed files with 395 additions and 236 deletions

View File

@@ -27,25 +27,34 @@ public:
}
/** render the given grid using GL commands */
void renderSolid(const RenderSettings& rs, const RenderTriangle& rt) {
void renderSolid(const RenderSettings& rs, const RenderTriangle& rt, bool wireframe) {
rs.shader->bind();
rs.shader->setModelMatrix(QMatrix4x4());
rs.shader->setVertices(rt.getVertices().data());
rs.shader->setNormals(rt.getNormals().data());
rs.shader->setVertexColor(rt.getRGBA().data());
glDrawArrays(GL_TRIANGLES, 0, rt.getVertices().size()/3);
rs.shader->setVertices(rt.getVertices());
rs.shader->setNormals(rt.getNormals());
rs.shader->setVertexColor(rt.getRGBA());
glDrawArrays(GL_TRIANGLES, 0, rt.count());
rs.shader->unsetVertices();
rs.shader->unsetNormals();
rs.shader->unsetVertexColor();
if (wireframe) {
RenderTriangle rt2 = rt.toWireframe(false);
rs.shader->setColor(0,0,0,128);
rs.shader->setVertices(rt2.getVertices());
//rs.shader->setVertexColor(rt2.getRGBA());
glDrawArrays(GL_LINES, 0, rt2.count());
rs.shader->unsetVertices();
//rs.shader->unsetVertexColor();
}
rs.shader->release();
}
/** render the given grid using GL commands */
void renderTransp(const RenderSettings& rs, const RenderTriangle& rt) {
void renderTransp(const RenderSettings& rs, const RenderTriangle& rt, bool wireframe) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -53,14 +62,24 @@ public:
rs.shader->bind();
rs.shader->setModelMatrix(QMatrix4x4());
rs.shader->setVertices(rt.getVertices().data());
rs.shader->setNormals(rt.getNormals().data());
rs.shader->setVertexColor(rt.getRGBA().data());
glDrawArrays(GL_TRIANGLES, 0, rt.getVertices().size()/3);
rs.shader->setVertices(rt.getVertices());
rs.shader->setNormals(rt.getNormals());
rs.shader->setVertexColor(rt.getRGBA());
glDrawArrays(GL_TRIANGLES, 0, rt.count());
rs.shader->unsetVertices();
rs.shader->unsetNormals();
rs.shader->unsetVertexColor();
if (wireframe) {
RenderTriangle rt2 = rt.toWireframe(false);
rs.shader->setColor(0,0,0,128);
rs.shader->setVertices(rt2.getVertices());
//rs.shader->setVertexColor(rt2.getRGBA());
glDrawArrays(GL_LINES, 0, rt2.count());
rs.shader->unsetVertices();
//rs.shader->unsetVertexColor();
}
rs.shader->release();
glDisable(GL_BLEND);