Java OpenGL - Wireframe and Solid mode

3.3k views Asked by At

I have an .OBJ loader that load an object and renders it. I can render it as wireframe or solid, like this:

Solid

enter image description here

Wireframe

enter image description here

So now i would like to render both modes at the same time like - Wireframe render over the Solid render (both with different colors). Is that possible?

Can anyone help please? Thank you.

1

There are 1 answers

0
Snox On BEST ANSWER

I figured it out! Here's the code if anyone has the same doubt i had :-)

// draw the filled polygons
   glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL );
   glEnable( GL.GL_POLYGON_OFFSET_FILL );
   glPolygonOffset( 1, 1 );
   glColor3f( 0.0f, 0.0f, 0.0f );
   renderData();
   gl.glDisable( GL.GL_POLYGON_OFFSET_FILL );

   // draw the wireframe
   glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_LINE );
   glColor4fv( colour );
   renderData();