Hi there,
i tried to get a simple OpenGL example up and running under Fedora but seem to fail. The code is compiling fine and also executing but there is no window opening. My main.cpp looks like this:
#include <iostream>
#define GLEW_STATIC
#include <GL/glew.h>
#define SDL_MAIN_HANDLED
#ifdef _WIN32
#include <SDL.h>
#pragma comment(lib, "SDL2.lib")
#pragma comment(lib, "glew32s.lib")
#pragma comment(lib, "opengl32.lib")
#else
#include <SDL2/SDL.h>
#endif
int main(int argc, char** argv){
SDL_Window* window;
SDL_Init(SDL_INIT_EVERYTHING);
/*SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);*/
window=SDL_CreateWindow("C++ OpenGL Tutorial", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL);
SDL_GLContext glContext = SDL_GL_CreateContext(window);
bool close= false;
while(!close){
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
SDL_Event event;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT){
close=true;
}
}
}
return 0;
}
for the setup i used this site: Wikibooks OpenGL installation
eg. this command:
sudo dnf install glew-devel SDL2-devel SDL2_image-devel glm-devel freetype-devel
finally i compile the code with g++ using:
g++ -fdiagnostics-color=always -g main.cpp -std=c++11 -o main -lGL -lSDL2 -lGLEW
to debug i use gdb and can see that the code is running “fine” but there is no window spawned.
I use Fedora 37 64bit with Gnome 43.2 and wayland. What am i missing?