1
General / Re: Integrating SFML with Modern OpenGL
« on: July 28, 2016, 07:43:41 pm »#define GLEW_STATIC
#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
int main() {
sf::RenderWindow app(sf::VideoMode(640, 480), "OpenGL");
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK) {
std::cout << "Failed to initialize GLEW!";
return -1;
}
while (app.isOpen()) {
sf::Event e;
while (app.pollEvent(e)) {
if (e.type == sf::Event::Closed) {
app.close();
}
}
static const GLfloat red[] = {1.0f, 0.0f, 0.0f, 1.0f};
glClearBufferfv(GL_COLOR, 0, red);
app.display();
}
return 0;
}
#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
int main() {
sf::RenderWindow app(sf::VideoMode(640, 480), "OpenGL");
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK) {
std::cout << "Failed to initialize GLEW!";
return -1;
}
while (app.isOpen()) {
sf::Event e;
while (app.pollEvent(e)) {
if (e.type == sf::Event::Closed) {
app.close();
}
}
static const GLfloat red[] = {1.0f, 0.0f, 0.0f, 1.0f};
glClearBufferfv(GL_COLOR, 0, red);
app.display();
}
return 0;
}
The code is basically the same as before, but with your proposed changes and the GLEW_STATIC stuff. This example does work perfectly well on my Windows machine; the glClearBufferfv is a newer function than glClear and glClearColor. Those two I'm already familiar with, and they work on my Mac without the GLEW stuff.