I had to borrow some of the the opengl example from sfml and use it in the code, as it would of taken way too long to get the original code together, but the result/error is still the same.
#ifndef windowo
#define windowo
#include <SFML/OpenGL.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
void welcomescreen()
{
// Request a 32-bits depth buffer when creating the window
sf::ContextSettings contextSettings;
contextSettings.depthBits = 48;
// Create the main window
sf::RenderWindow windowo(sf::VideoMode(640, 480), "gameTest", sf::Style::Default, contextSettings);
windowo.resetGLStates();
windowo.setVerticalSyncEnabled(true);
sf::Font txt;
if (!txt.loadFromFile("resources/armyfont.ttf"))
{
cout << "An error has occured loading the font.";
}
sf::Text wlcmtxt;
wlcmtxt.setFont(txt);
wlcmtxt.setScale(1.4, 1.4);
wlcmtxt.setString("gameTest");
wlcmtxt.setOrigin(-130, -0);
// Make it the active window for OpenGL calls
windowo.setActive();
// Set the color and depth clear values
glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 1.f);
// Enable Z-buffer read and write
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
// Disable lighting and texturing
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glViewport(0, 0, windowo.getSize().x, windowo.getSize().y);
// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLfloat ratio = static_cast<float>(windowo.getSize().x) / windowo.getSize().y;
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 800.f);
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
GLfloat cube[] =
{
// positions // colors (r, g, b, a)
-50, -50, -50, 0, 0, 1, 1,
-50, 50, -50, 0, 0, 1, 1,
-50, -50, 50, 0, 0, 1, 1, // blue
-50, -50, 50, 0, 0, 1, 1,
-50, 50, -50, 0, 0, 1, 1,
-50, 50, 50, 0, 0, 1, 1,
50, -50, -50, 0, 1, 0, 1, //green
50, 50, -50, 0, 1, 0, 1,
50, -50, 50, 0, 1, 0, 1,
50, -50, 50, 0, 1, 0, 1,
50, 50, -50, 0, 1, 0, 1,
50, 50, 50, 0, 1, 0, 1,
-50, -50, -50, 1, 0, 0, 1, //red
50, -50, -50, 1, 0, 0, 1,
-50, -50, 50, 1, 0, 0, 1,
-50, -50, 50, 1, 0, 0, 1,
50, -50, -50, 1, 0, 0, 1,
50, -50, 50, 1, 0, 0, 1,
-50, 50, -50, 0, 1, 1, 1,
50, 50, -50, 0, 1, 1, 1,
-50, 50, 50, 0, 1, 1, 1, //cyan
-50, 50, 50, 0, 1, 1, 1,
50, 50, -50, 0, 1, 1, 1,
50, 50, 50, 0, 1, 1, 1,
-50, -50, -50, 1, 0, 1, 1,
50, -50, -50, 1, 0, 1, 1,
-50, 50, -50, 1, 0, 1, 1, //purple
-50, 50, -50, 1, 0, 1, 1,
50, -50, -50, 1, 0, 1, 1,
50, 50, -50, 1, 0, 1, 1,
-50, -50, 50, 1, 1, 0, 1,
50, -50, 50, 1, 1, 0, 1,
-50, 50, 50, 1, 1, 0, 1,
-50, 50, 50, 1, 1, 0, 1, //yellow
50, -50, 50, 1, 1, 0, 1,
50, 50, 50, 1, 1, 0, 1,
};
// Enable position and color vertex components
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(3, GL_FLOAT, 7 * sizeof(GLfloat), cube);
glColorPointer(4, GL_FLOAT, 7 * sizeof(GLfloat), cube + 3);
// Disable normal and texture coordinates vertex components
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
// Create a clock for measuring the time elapsed
sf::Clock clock;
// Start the game loop
while (windowo.isOpen())
{
// Process events
sf::Event event;
while (windowo.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
windowo.close();
// Escape key: exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
windowo.close();
// Resize event: adjust the viewport
if (event.type == sf::Event::Resized)
glViewport(0, 0, event.size.width, event.size.height);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
{
windowo.close();
}
// Clear the color and depth buffers
glClearColor(1.0, 1.0, 1.0, 1.0); // add this
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 0.0f, 0.0f);
// Apply some transformations to rotate the cube
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.f, 0.f, -200.f);
glRotatef(clock.getElapsedTime().asSeconds() * 50, 1.f, 0.f, 0.f);
glRotatef(clock.getElapsedTime().asSeconds() * 30, 0.f, 1.f, 0.f);
glRotatef(clock.getElapsedTime().asSeconds() * 90, 0.f, 0.f, 1.f);
// Draw the cube
glDrawArrays(GL_TRIANGLE_STRIP, 0, 36);
windowo.pushGLStates();
// windowo.draw(wlcmtxt);
windowo.popGLStates();
windowo.pushGLStates();
windowo.popGLStates();
// Finally, display the rendered frame on screen
windowo.display();
}
}
#endif
I have the latest Nvidia drivers, I don't think that's the problem. I'm also using SFML 2.2 if that helps.