Hybrid View

GL_FLAT looks ugly - I see triangles instead of quads

Hi,

I'm writing my own library/engine based on OpenGL. I've just started implementing lighting. When I created a sphere or plane (my own models), placed them in [0, 0, 0], set lighting mode to GL_FLAT I got this:

The light position in sphere scene is [10, 0, 10 ,1], other parameters the same as before.

The plane is a square of size 20, it's composed of 20x20x2 triangles (2 triangles per small square). Normals of each vertex [0, 1, 0].

The sphere's radius is 2, it has 20 meridians and 18 latitude-lines (+ 2 poles), so 2x20 triangles at poles, and 20x17x2 triangles in the rest of it. Normals of each vertex are vectors, which would have connect this vertex with center of sphere, if they'd be longer.

I'm rendering using GL_TRIANGLES. So I thought that changing this to GL_QUADS will help. It did, but two new issues appeared:
- i heard that GL_QUADS are depraciated,
- when I look at a broken quad (not planar) from very close distance, it's inner (broken) edge suddenly flips (so it's broken the other way).

I thought it's a problem with normals, but then I made this plane from first image (at the beginning it was only the sphere), with all normals = [0, 1, 0], and you see what I got.

So I have no idea what can cause this problem. Maybe you have?

I would show my code, but for now my library has about 40 classes. It's really hard to show key fragments. I would have to introduce you to entire logic and way of thinking in my library, and it would take too much time and too much writing.

I'm writing my own library/engine based on OpenGL. I've just started implementing lighting. When I created a sphere or plane (my own models), placed them in [0, 0, 0], set lighting mode to GL_FLAT I got this ... I'm rendering using GL_TRIANGLES. So I thought that changing this to GL_QUADS will help. It did, but two new issues appeared:
- i heard that GL_QUADS are depraciated,
- when I look at a broken quad (not planar) from very close distance, it's inner (broken) edge suddenly flips (so it's broken the other way).

As to the first, QUADS are still there in the compatibility profile (the default). Deprecation/removal only affects you if you target the core profile. glShadeModel as well as fixed function lighting is also deprecated, but again, this only affects you in the core profile.

As to the second, what do you mean "broken"?

Also, GL_FLAT is shading thing, not a lighting thing (shading comes after lighting).