You can't expect SFML to set OpenGL up for you. It will only do so if it has to, i.e. if it has to draw something.
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
int main(int argc, char* argv[])
{
sf::RenderWindow window(sf::VideoMode(800, 600), sf::String("SFML noShapeGL"), sf::Style::Default, sf::ContextSettings(32,0,8,4,2));
window.setFramerateLimit(60);
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
window.clear(sf::Color(0, 0, 0));
// SFML rendering
//window.resetGLStates();
// draw your SFML stuff here
// set up GL
glViewport(0, 0, 800, 600);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
// custom GL-Rendering
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_CURRENT_BIT | GL_LINE_BIT);
glColor4f(1.0, 0, 0, 1.0);
glLineWidth(5);
glBegin(GL_LINES);
{
glVertex2d(10, 50);
glVertex2d(50, 10);
}
glEnd();
glPopAttrib();
glPopMatrix();
window.display();
}
}
If you want to program using OpenGL, you should have basic knowledge about how to set up the viewport and the required matrices. If you don't understand any of these concepts, I strongly suggest you read up about them somewhere on the internet. Your usage of GL_TRANSFORM_BIT is also incorrect. It doesn't push the transformation matrices as you might expect. The matrix stack has its own push and pop functions. This is also explained in beginner OpenGL tutorials.