Archived

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

Terren

OGL Problem?

Recommended Posts

Terren    122
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 this post


Link to post
Share on other sites
Terren    122
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 this post


Link to post
Share on other sites
Terren    122
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 this post


Link to post
Share on other sites
Dave Hunt    4872
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 this post


Link to post
Share on other sites
Terren    122
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

Share this post


Link to post
Share on other sites