TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
LIBS += -lGLEW -lGLU -lglut -lGL
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
/**
* analyse the version
*/
string makeMeString(GLint versionRaw) {
stringstream ss;
string str = "\0";
ss << versionRaw;
str = ss.str();
return str;
}
/**
* Format the string as expected
*/
void formatMe(string *text) {
string dot = ".";
text->insert(1, dot);
text->insert(4, dot);
}
/**
* Message
*/
void consoleMessage() {
char *versionGL = "\0";
GLint versionFreeGlutInt = 0;
versionGL = (char *)(glGetString(GL_VERSION));
versionFreeGlutInt = (glutGet(GLUT_VERSION));
string versionFreeGlutString = makeMeString(versionFreeGlutInt);
formatMe(&versionFreeGlutString);
cout << endl;
cout << "OpenGL version: " << versionGL << endl << endl;
cout << "FreeGLUT version: " << versionFreeGlutString << endl << endl;
cout << "GLEW version: " <<
GLEW_VERSION << "." << GLEW_VERSION_MAJOR << "." <<
GLEW_VERSION_MINOR << "." << GLEW_VERSION_MICRO << endl;
}
/**
* Manager error
*/
void managerError() {
if (glewInit()) {
cerr << "Unable to initialize GLEW." << endl;
while (1);
exit(EXIT_FAILURE);
}
}
/**
* Manage display (to be implemented)
*/
void managerDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
}
/**
* Initialize FREEGLUT
*/
void initFreeGlut(int ac, char *av[]) {
glutInit(&ac, av);
glutInitDisplayString("");
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(600, 600);
glutInitContextVersion(3, 3);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInitWindowPosition(500, 500);
glutCreateWindow("BadproG - Hello world :D");
}
/**
* Manage keyboard
*/
void managerKeyboard(unsigned char key, int x, int y) {
if (key == 27) {
exit(0);
}
}
/**
* Main, what else?
*/
int main(int argc, char** argv) {
initFreeGlut(argc, argv);
managerError();
consoleMessage();
glutDisplayFunc(managerDisplay);
glutKeyboardFunc(managerKeyboard);
glutMainLoop();
return 0;
}