Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View mesh in OpenGL (lwjgl)

Tags:

java

opengl

lwjgl

I'm using LWJGL. I'm trying to create a simple 3D map using GL_TRIANGLE_STRIP and it works fine. But now OpenGL automatically fills up every triangle. I was wondering if it is possible for OpenGL to only draw the outlines of each triangle. This way I have a better view on what I'm doing.

like image 669
Daan Pape Avatar asked Jan 18 '12 16:01

Daan Pape


People also ask

What is a mesh class in OpenGL?

A mesh should also contain indices for indexed drawing, and material data in the form of textures (diffuse/specular maps). Now that we set the minimal requirements for a mesh class we can define a vertex in OpenGL:

How does the internal struct work in OpenGL?

The Internal struct is initialised with an instance of an ast::Mesh object. It will actually create two memory buffers through OpenGL - one for all the vertices in our mesh, and one for all the indices. Subsequently it will hold the OpenGL ID handles to these two memory buffers: bufferIdVertices and bufferIdIndices.

How do I render wireframe in OpenGL?

The proper way to render in wireframe mode is by changing the OpenGL render state: Hope this helps! :D Awesome that makes a lot of sense thank you! I have a question about the frag shader and the way the textures are identified.

How to define a vertex in OpenGL?

Now that we set the minimal requirements for a mesh class we can define a vertex in OpenGL: We store each of the required vertex attributes in a struct called Vertex. Next to a Vertex struct we also want to organize the texture data in a Texture struct: We store the id of the texture and its type e.g. a diffuse or specular texture.


1 Answers

You can use glPolygonMode() to disable fills on front and backward facing geometry:

// enable wireframe
glPolygonMode( GL_FRONT, GL_LINE );

// draw stuff to be wireframe'd
DrawStuff();

// restore regular rendering
glPolygonMode( GL_FRONT, GL_FILL );
like image 137
genpfault Avatar answered Oct 16 '22 17:10

genpfault