C++ (Qt)glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
void Positioner::paintGL(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); float* otlData = otlVertexes.data(); float* formData = formVertexes.data(); glPushMatrix(); glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); glRotatef(zRot, 0.0f, 0.0f, 1.0f); glTranslatef(-geomCenter[0], -geomCenter[1], -geomCenter[2]); glBegin(GL_TRIANGLES); if (showCastBtn->isChecked()) { glColor3f(1.0f, 0.0f, 0.0f); for (int i = 0; i < otlVertexes.size(); i += 3) glVertex3fv(otlData + i); } if (showMouldBtn->isChecked()) { glColor3f(0.0f, 0.0f, 1.0); for (int i = 0; i < formVertexes.size(); i += 3) glVertex3fv(formData + i); } glEnd(); glColor3f(0.0f, 0.0f, 0.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);// glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(-0.5f, -1.0f); glBegin(GL_TRIANGLES); if (showCastBtn->isChecked()) { for (int i = 0; i < otlVertexes.size(); i += 3) glVertex3fv(otlData + i); } if (showMouldBtn->isChecked()) { glColor3f(1.0f, 1.0f, 1.0f); for (int i = 0; i < formVertexes.size(); i += 3) glVertex3fv(formData + i); } glEnd(); glDisable(GL_POLYGON_OFFSET_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);// glPolygonOffset(0.0f, 0.0f); glPopMatrix();}
void Positioner::paintGL(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); float* otlData = otlVertexes.data(); float* formData = formVertexes.data(); glPushMatrix(); glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); glRotatef(zRot, 0.0f, 0.0f, 1.0f); glTranslatef(-geomCenter[0], -geomCenter[1], -geomCenter[2]); if (showCastBtn->isChecked()) { glColor3f(1.0f, 0.0f, 0.0f); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, otlData); glDrawArrays(GL_TRIANGLES, 0, otlVertexes.size() / 3); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glColor3f(0.0f, 0.0f, 0.0f); glDrawArrays(GL_TRIANGLES, 0, otlVertexes.size() / 3); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_POLYGON_OFFSET_LINE); glDisableClientState(GL_VERTEX_ARRAY); } if (showMouldBtn->isChecked()) { glColor3f(0.0f, 0.0f, 1.0f); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, formData); glDrawArrays(GL_TRIANGLES, 0, formVertexes.size() / 3); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glColor3f(1.0f, 1.0f, 1.0f); glDrawArrays(GL_TRIANGLES, 0, formVertexes.size() / 3); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_POLYGON_OFFSET_LINE); } glPopMatrix();}
// glEnable(GL_POLYGON_OFFSET_LINE);// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);// glColor3f(1.0f, 1.0f, 1.0f);// glDrawArrays(GL_TRIANGLES, 0, formVertexes.size() / 3);// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);// glDisableClientState(GL_VERTEX_ARRAY);// glDisable(GL_POLYGON_OFFSET_LINE); glColor3f(1.0f, 1.0f, 1.0f); float* pEnd = formData + formVertexes.size(); glBegin(GL_LINES); for (;formData < pEnd; formData += 3*3) { glVertex3fv(formData); glVertex3fv(formData+3); glVertex3fv(formData); glVertex3fv(formData+6); glVertex3fv(formData+3); glVertex3fv(formData+6); } glEnd();