glob3mobile / g3m

The multiplatform advanced visualization framework
http://www.glob3mobile.com/
Other
116 stars 56 forks source link

GLGlobalState bug #157

Closed Matyooo closed 8 years ago

Matyooo commented 8 years ago

The constructor of class GLGlobalState sets _cullFace to true (line in java source: 76). This causes an inconsistency with OpenGL state in the begining because OpenGL’s face culling is disabled by default.

This can cause a bug in the rendering mechanism (eg.: if there is only one DefaultRenderer descendant using Geometry2DGLFeature and flat colouring, because OpenGL’s culledFace is only set if _cullFace has changed (GLGlobalState:263)!

Geometry2DGLFeature:48 sets face culling to GL.front(), which is really strange in itself, but this setting only takes effect if face culling was disabled (_cullFace was false) before the call of state.enableCullFace().

DiegoGomezDeck commented 8 years ago

@amazingsmash, you there?

amazingsmash commented 8 years ago

@Matyooo is right. Cull facing is disabled by default on OpenGL ES. And in fact it provoques culling failures until something is drawn without culling. This will be changed soon in my next PR.

"Geometry2DGLFeature:48 sets face culling to GL.front()" seems reasonable to me, as 2D triangles should not be rendered backwards. It prevents failures in the composition of "HUD" elements.

Matyooo commented 8 years ago

Great news!

Regarding GL.front VS GL.back(): Geometry2DGLFeature:48 sets face culling to GL.front() which in fact forces OpenGL to cull all FRONT facing triangles! (look at glCullFace doc) In order to have only front facing triangles, you should specify it as GL.back() to force OpenGL to cull the BACK facing triangles.

amazingsmash commented 8 years ago

You are right @Matyooo I will correct that too.

Matyooo commented 8 years ago

Thank you for all that! When do you expect to roll out the fix?

amazingsmash commented 8 years ago

This PR will be my xmas gift for @DiegoGomezDeck .

DiegoGomezDeck commented 8 years ago

@Matyooo Did the PR #155 fixed this issue?

Matyooo commented 8 years ago

Sure! Looks like it is ok! Thanks