I am new to graphical programming and following a simple tutorial on SDL. Hereby, I am facing a problem which I cant find an answer to: Whenever I open a Window, it just copies whatever is underneath it, and is not white like in the tutorial. I think this may be due to some hidden render buffer (?).
I am running the following code:
SDL_Init(SDL_INIT_EVERYTHING);
_window = SDL_CreateWindow("EvolutionEngine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
_screenwidht, _screenheight, SDL_WINDOW_OPENGL);
SDL_Event evnt;
while(SDL_PollEvent(&evnt) == true)
{
switch (evnt.type)
{
case SDL_QUIT:
_gameState = GameState::EXIT;
break;
case SDL_MOUSEMOTION:
std::cout << "(" << evnt.motion.x << "," << evnt.motion.y << ")\n";
break;
}
}
(These are in different functions, but the only relevant code to the problem). My qmake file looks like this:
QT += core
QT -= gui
TARGET = Evolution
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CONFIG += link_pkgconfig
PKGCONFIG += sdl2
QMAKE_CXXFLAGS += -std=c++11
SOURCES += \
...
HEADERS += \
...
Has anybody got an idea on what might cause this an how I can fix it?
You are requesting a window with an opengl context form SDL. But you never draw anything to it (including clearing the buffer). I don't know why you would expect a white image from that. The contents of your frame buffer will just be completely undefined. And what you get is one of the many possibilities of how such undefined content might look.