[SFML/C++] Simple OpenGL Triangle
Hi!
I'm using SFML, which uses OpenGL, and have found that a simple OpenGL triangle will only display under weird circumstances. Here's the code for the triangle:
Code :
void drawGL() {
std::cout<<"GL\n";
glBegin(GL_TRIANGLES);
glVertex2f(0.0f,0.5);
glVertex2f(-0.5f,-0.5f);
glVertex2f(0.5f,-0.5f);
glEnd();
}
This is the part of my window loops that concerns the OpenGL portion of the window:
Code :
window.clear();
if(state==1) {
drawInterfaces();
}
else {
drawGL();
}
window.display();
drawInterfaces() is a function to display some 2D sprites. state is changed to 2 when I want the triangle to be displayed.
This will only work if I remove the state system all together and just allow drawGL() to display by its own. Example: the above window portion will NOT work. This, however, WILL work.
Code :
window.clear();
drawGL();
window.display();
I'm pretty sure this isn't SFML's fault because I can still initialize all of my sprites, load the images and put them into sprites before calling drawGL() and it works. :doh:
Thanks for reading!