I've been working on a 3D application using SFML for context creation and OpenGL 3.0. For some reason when I attempt to create the context using OpenGL 3.0 it seems to draw the image slightly narrowed and doubled with a black bar in between, and the screen seems to be cleared with green instead of red for some reason. If I change the context to 2.1 it draws normally. Originally I was having this problem using modern OpenGL code but I've provided a sample using the fixed function pipeline so that the problem is clearer.
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
int main()
{
// create the window
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.antialiasingLevel = 4;
settings.majorVersion = 3;
settings.minorVersion = 0;
sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, settings);
// load resources, initialize the OpenGL states, ...
glClearColor(1.0, 0.0, 0.0, 1.0);
// run the main loop
bool running = true;
while (running)
{
// handle events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
// end the program
running = false;
}
}
// clear the buffers
glClear(GL_COLOR_BUFFER_BIT);
// draw...
glBegin(GL_TRIANGLES);
glVertex3f( 0.0, 1.0, 0.0);
glVertex3f(-1.0,-1.0, 0.0);
glVertex3f( 1.0,-1.0, 0.0);
glEnd();
// end the current frame (internally swaps the front and back buffers)
window.display();
}
return 0;
}
If I Change these two lines:
settings.majorVersion = 3;
settings.minorVersion = 0;
To these:
settings.majorVersion = 2;
settings.minorVersion = 1;
The window draws normally.
Here are screenshots of what is happening.
The second image is a little messed up because my computer lagged. It shouldn't have that orange tone.
My setup is:
Ubuntu 12.10 Intel i7-3630QM Intel HD Graphics 4000
From glxinfo: OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile OpenGL version string: 3.0 Mesa 9.0.2 OpenGL shading language version string: 1.30
From lspci: Kernel driver in use: i915
I thought this might be a driver issue but I've had success running OpenGL 3.0 programs using GLUT and no deprecated functionality so it must have been creating a valid OpenGL 3.0 context and working.
I'm very confused as to why this is happening.