LWJGL Forum

Programming => OpenGL => Topic started by: DeadRabbit on October 14, 2015, 14:20:45

Title: Blender winding order
Post by: DeadRabbit on October 14, 2015, 14:20:45
Not sure if this is the right forum for this but can anyone point me in the right direction on how to import .obj triangles in a winding order? or is it something i gotta do manually, how, and is it worth it efficient wise? I rendered an imported model i have, used glPolygonMode to see how it was with/without cull facing and it just loses triangles so it isnt winding ordered :( what do i do?

Using an element buffer object, but not doing anything with the normals, if that could be relevant.
Title: Re: Blender winding order
Post by: DeadRabbit on October 14, 2015, 14:27:52
update: inserting the face indexes in the opposite order and using CCW seems to have some effect, but I'm not entirely sure if that was the solution,was it? Nevermind it's still removing triangles that are in front :(
Title: Re: Blender winding order
Post by: Kai on October 14, 2015, 14:46:28
When I export something from Blender as Wavefront OBJ, it consistently has counter-clockwise winding order (OpenGL default).
The problem is maybe that your model itself has inconsistent face orientations.
What do you see in Blender when you enable "Backface Culling" there?
(In 2.76 enabling backface culling can be done on the Properties view (hotkey 'N' in the 3D view) under section "Shading.")
Title: Re: Blender winding order
Post by: DeadRabbit on October 14, 2015, 14:55:19
it was unchecked, hmm was i supposed to check that? gonna try with a new export with that checked.
Title: Re: Blender winding order
Post by: Kai on October 14, 2015, 15:00:39
No, what I mean is: Does your model also look inconsistent in the view in Blender itself (with some faces being hidden when they are not supposed to) when enabling that option.
Enabling this option has nothing to do with how the faces will be exported.
It is only an option for viewing the model, like when you import it and then render the model in your own OpenGL application yourself with backface culling enabled.
Also what is interesting is that Blender seems to generate the winding order depending on the direction of the normal of a face. So maybe check your normals.
Title: Re: Blender winding order
Post by: DeadRabbit on October 14, 2015, 15:06:56
Oh wait i thought it was eating triangles but i think it wasn't i think its working +/- CW

CW and no cull facing:

http://imgur.com/a/nAOJL

when i go inside with CW the triangles seem the same size as without cull facing, nvm i can't see them if i go inside but they seem the same size idk

hah sorry i was paranoid for a second it was working CW+back and CCW+front ^.^ I'm a newbie at this, thanks for the help though.
Title: Re: Blender winding order
Post by: mohcenHafidi on January 04, 2022, 12:38:40
First make sure you are enabling Zbuffer :
   glEnable(GL_DEPTH_TEST); // put this outside the rendering loop

And make sure you are updating it :
glClear(GL_DEPTH_BUFFER_BIT); // put this inside the rendering loop

If that does not fix your issue try :
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glFrontFace(GL_CW); // or GL_CCW