I'm not understanding why I can't get anything rendered to the screen. I have code very similar to this in another program which renders fine, but this program just gives me a blank screen.
Here's my initialization code:
void GRAPHICS::InitGraphics(SDL_Surface* screen, bool fullscreen, int width, int height)
{
SDL_Init(SDL_INIT_EVERYTHING);
glClearColor(0.0, 0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(35.0, width / height, 0.2, 500.0);
//SetScreenAttributes(screen, fullscreen, width, height);
SDL_SetVideoMode(width, height, 32, SDL_OPENGL);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
And here's my render function:
void GAME::Render()
{
// ** Clear the screen and translations for a new render ** //
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glOrtho(0, header.scrWidth, header.scrHeight, 0.0, -1.0, 1.0);
glColor3f(1.0f, 1.0f, 1.0f);
// 2D drawings here
// ** Put all Drawing data here ** //
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
gluPerspective(35.0, (float)header.scrWidth / (float)header.scrHeight, 0.2, 500.0);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.5f, 0.0f);
glEnd();
SDL_GL_SwapBuffers();
}
I'm sure the fault lies somewhere in one of these functions. I have other code, but for now a simple triangle on the screen would be nice, but I can't even get that. the clear color is black by the way.
Help is greatly appreciated!