Closed BrunoLevy closed 9 months ago
Is there any workaround ?
glupSetMeshWidth()
works well to display mesh wireframes of variable width in Vorpaview, but I didn't manage to use it on custom lines. Is this related ?
I guess yes, what do you mean by "custom lines" ? The problem is that glLineWidth() is now deprecated in OpenGL, so if we want thick line primitives, we need to write a special shader that transforms each little segment into a GL_QUAD, transform the vertices and fill-in the GL_QUAD. It will require a geometry shader, and geometry shaders are not available on all plaforms, it is really a pain, this is why I have not implemented yet. We do not have the problem for drawing the mesh in surfacic primitives, because we are cheating (the fragment shader draws the mesh by changing pixel color in surfacic primitives).
I naively added this function in my MeshGfx, by looking at how mesh wireframes were drawn:
void CustomMeshGfx::draw_custom_edges() {
for(/* each group of edges */) {
glupSetMeshWidth(/* width */);
glupSetColor4fv(GLUP_FRONT_COLOR, /* color of this group */);
glupBegin(GLUP_LINES);
for(/* each edge in this group */) {
glupPrivateVertex3dv(/* 1st point coordinates */);
glupPrivateVertex3dv(/* 2nd point coordinates */);
}
glupEnd();
}
}
Thank you for the answer, I do not know anything about OpenGL and did not notice the cheat for surfacic primitives!
Yes, I confirm, it corresponds to what I mentioned. One day I may implement it (but it is a big amount of work, so I cannot promise when).
As a workaround, you may draw the same edges several times, and shift the transform matrix a little bit each time.
Congratulations on making it happen! :star_struck: I tested it separately on the last commit of the main branch.
Be able to use it on my work project would be awesome! Do you think the main branch is stable enough? Is a new release in preparation?
Next release will be published soon, but I have a couple of things to finish in the mesh intersection / boolean ops before shipping it (cannot say exactly when it will be done)
If you are impatient, I keep the main branch quite stable, you can check the status of the continuous builds and the nighty builds (if it is all green, there are good chances you won't have too many problem updating).
Reopened issue because it does not work very well under Windows as observed by Nicolas Ray.
On Windows, with GLUP_140 and GLUP_440 I get an error:
gl_ClipDistance different type between shaders
Googling around, it seems that the size of the gl_ClipDistance is inferred, deduced by how it is accessed in the shader, and maybe the inferred value is different in different stages ?
Fixed problem under windows:
The problem was that both the vertex and geometry shader were writing to gl_ClipDistance
, which is supposed to be an error (the error was not detected by the NVidia Linux driver).
Pushed the fix plus some code that save all the generated shaders to files when gfx:gl_Debug
is set (it is how I figured out what happened, using also glslangValidator to analyze them).
It is because thick lines are both line primitives and surfacic primitives, and the code that writes gl_ClipDistance
in the vertex shader does it if it is a line primitive, so I needed also to check that primitive is not GL_THICK_LINES explicitly.
-> pushing a new v1.8.8 release with the fix.
I miss glLineWidth() ... Need to write a geometry shader or something to be able to draw thick lines.