Almost got it working. Got very many dots instead now spread over the image in rectangles or something. Kinda like spray in paint. Ow yeah, may be nothing but just now when I pressed the close button my X-Server crashed and I failed back to the login screen.
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
sf::RenderWindow window;
const unsigned int MAX_FPS = 20;
void SetupWindow();
void SetupGL();
void ResizeGLScene(unsigned int width, unsigned int height);
void HandleEvents();
int main() {
SetupWindow();
sf::Image img;
sf::Sprite sprite;
img.LoadFromFile("ubuntu-tan2.jpg");
sprite.SetImage(img);
while(window.IsOpened()) {
window.Clear();
glLoadIdentity();
window.Draw(sprite);
window.Display();
HandleEvents();
}
return 0;
}
void SetupWindow() {
sf::WindowSettings settings;
settings.DepthBits = 24;
settings.StencilBits = 8;
settings.AntialiasingLevel = 2;
window.Create(sf::VideoMode(800, 600, 32), "Groogy App", sf::Style::Close, settings);
window.SetFramerateLimit(MAX_FPS);
window.SetActive(true);
SetupGL();
}
void SetupGL() {
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
void ResizeGLScene(unsigned int width, unsigned int height) {
if(height == 0)
{
height = 1;
}
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height,0.1f,100.0f);
}
void HandleEvents() {
sf::Event event;
while(window.GetEvent(event)) {
switch(event.Type) {
case sf::Event::Closed:
window.Close();
break;
case sf::Event::Resized:
ResizeGLScene(event.Size.Width, event.Size.Height);
break;
default:
break;
}
}
}