#### Archived

This topic is now archived and is closed to further replies.

# OGL Problem?

This topic is 5317 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I wonder if you guys can help - i just can''t understand what the hell is wrong with this.. i''m not a newbie here, but for some reason the following just doesn''t work -> glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0f,(float)m_ScreenRes.x, (float)m_ScreenRes.y, 0.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glClearColor(1,0,0,0); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); { glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(0.0f, 0.0f); glVertex2f(156.0f, 256.0f); glVertex2f(0.0f, 256.0f); } glEnd(); The triangle will always draw black, but is not limited to triangles; lines, points and quads all do this too.. even though i''ve specified the vertex color. The GL context is being created through SDL if that helps. I''ve had this working without changing any setup code, and basically set up this small drawing test to try and get this to work properly. Just wondering really if you guys can spot anything i''m missing.. Thanks for any help..

##### Share on other sites
is lighting enabled or disabled? try putting this somewhere before you render:

 glDisable(GL_LIGHTING);

[edited by - postalbruhman99 on August 6, 2003 7:50:31 PM]

##### Share on other sites
Yeah, that was the first thing that I tried, but it didn''t work. I have now figured out what''s causing the problem, but not sure how to fix it..

Before hand in an initialization function I am creating a couple of blank textures; if I don''t create these textures, the colours on the polys display fine, but return to black if the textures are created. Bear in mind that I don''t bind the textures before drawing the polygon (apart from when actually creating them) and don''t supply any texture coordinates for the poly.. so basically i''m now at a loss as to why creating those textures is causing such an effect. Is there any way to ''unbind'' the texture, or am I just missing something?

##### Share on other sites
right, ok - glBindTexture(GL_TEXTURE_2D, 0) and glDisable(GL_TEXTURE_2D) both worked.. i''m sure I haven''t had to deal with that before..

oh well.. thats why we all love programming, right?

Cheers anyway

##### Share on other sites
Why do you have a "{" after glBegin and a "}" before glEnd?!

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

##### Share on other sites
quote:
Original post by ShlomiSteinberg
Why do you have a "{" after glBegin and a "}" before glEnd?!

I do that, too. I also do it with glPushMatrix/glPopMatrix. It helps to visually see the logical nesting of gl commands.

##### Share on other sites
Yeah, to help with readability, I suppose - looks better when everythings indented properly. I just couldn''t remember the tags to insert code on here