OpenGL wireframes

glPolygoneMode(GL_FRONT_AND_BACK, GL_FILL)included, and how can I get the wireframe in this situation? Is there a way to get the wireframe rendering without switching Polygone mode to GL_LINE?

+3
source share
3 answers
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

Fill fills it ... you need a string.

EDIT: Remember, you can always return it to fill when you finish, like this

glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
 // add polygons here
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
+17
source

From your question, I assume that you have huge middleware and I only have access to the shaders, am I right?

In this case, create a changing call in your vertex shader, for example, vertexID:

varying float vertexID; # in GLSL <= 3, or
out float vertexID;     # in GLSL 4

and assign it the built-in gl_VertexID:

vertexID = (float)gl_VertexID;

, gl_VertexID , ! , , , 2 , 3 2,5 .

, , vertexID 2 ( 3): , . .

in float vertexID; # or
varying float vertexID;

// blabla

if (fract(vertexID) < 0.1){
    outcolor = vec4(1,0,0,0); # in glsl 4
}

, 2 . , , ( ID 2, 1000, 0,1 ).

+3

, , , . , . :

glPolygonMode( ... GL_FILL);
draw();
glPolygonOffset( param1, param2 );
glPolygonMode( ... GL_LINE );
draw();

, , glPolygonOffset ..

+2

Source: https://habr.com/ru/post/1792878/


All Articles