Individual vertex coloring is somehow disabled.

Started by
1 comment, last by JoakimNordstrandStien 11 years, 7 months ago
Edit:

The fix is in:

I had called glShadeModel(GL_FLAT) at some point in my code, because I was trying to derp while herping whilst writing it.

The fix was to change GL_FLAT with GL_SMOOTH. Thanks to Sponji for pointing that out.

---

Good day!

I've been struggling to draw primitives correctly in my engine for quite a few hours, and I've managed to narrow it down to the fact that each vertex I'm passing along isn't colored individually.

The following snippet and screenshot demonstrates my issue.


glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glColor3f(0.f,1.f,0.f); // Green
glVertex2f(-50.f, -50.f);
glVertex2f(50.f, -50.f);
glVertex2f(50.f, 50.f);


glColor3f(1.f, 0.f, 0.f); // Red
glVertex2f(-50.f, 50.f);
glEnd();
glEnable(GL_TEXTURE_2D);


This snippet should render a square where the top left vertex is red and the other three are green. However, as can be seen in this screenshot, this is not the case.

7iB7p.png

Disregard the purple sprites. Whenever I try to draw a primitive of any kind, all vertices get the last color called.

Apart from disabling/enabling GL_TEXTURE_2D, I'm not doing anything unusual.

This issue occurs both when rendering to a texture, and when I'm not.

Hope someone has experienced this issue before and can give me an aiding hand.

Best regards, Pimms.
Advertisement
Try calling glShadeModel(GL_SMOOTH) before glBegin.

Derp

That worked! Thank you so much!

I just hate it when I run into these speed bumps, which quite frankly is caused by my own lack of attention.

Best regards, Pimms.

This topic is closed to new replies.

Advertisement