I am just trying to launch a simple SDL2 example. Compiling is ok, but in time of executing, in this code:
int main(){
if(SDL_Init(SDL_INIT_EVERYTHING) != 0){ std::cout << "SDL init error: " << SDL_GetError() << std::endl; return false; }
}
I get SDL init error:
without any output from SDL_GetError(). Can you tell me, what is the problem?
IDE: Eclipse, OS: Ubuntu.
If I add some more code:
int main(){
if(SDL_Init(SDL_INIT_EVERYTHING) != 0){
std::cout << “SDL init error: " << SDL_GetError() << " |” << std::endl;
// return false;
}
SDL_Window* window = SDL_CreateWindow(“Hello World”, 200, 200, 460, 200, SDL_WINDOW_SHOWN);
if(window == nullptr){
std::cout << "SDL create window error: " << SDL_GetError() << std::endl;
// return false;
}
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if(renderer == nullptr){
std::cout << "SDL create renderer error: " << SDL_GetError() << std::endl;
// return false;
}
If I add more code to the project, I get the same error. That is, during initialization on the first check. Further execution occurs without errors, a window and a renderer are created. But the renderer cannot draw anything, the window is always black and no drawing commands are executed:
SDL_SetRenderDrawColor(renderer, 0xFF, 0xAA, 0xFF, 0xFF);
SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_Rect actor1 = {10, 10, 550, 50};
SDL_RenderFillRect(renderer, &actor1);