2
I wanted to understand why the console also opens when a program is made using the SDL2 library. I am using codeblocks in windows 10.
How do not appear the console and only appear the window generated through SDL2?
#include <iostream>
#include <SDL.h>
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window = SDL_CreateWindow(
"Funcionou!",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
800, 600,
SDL_WINDOW_SHOWN
);
SDL_Renderer *renderer = SDL_CreateRenderer(window,-1,0);
SDL_SetRenderDrawColor(renderer, 255,0,0,255);
SDL_RenderClear(renderer);
SDL_RenderPresent( renderer );
SDL_Delay(3000);
return (0);
}


I never used SDL and so I may be mistaken, but it seems that this application was made for console and not for Windows. Among other things they should use the
WinMain()https://docs.microsoft.com/en-us/windows/win32/learnwin32/winmain--the-application-entry-point. But she may already have that, but she would have to compile it in a certain way to do this..– Maniero
In fact, in the SDL2 version for Windows, the
WinMain()is initialized "under the hood", themainthat appears is not the functionmainthat would be expected in a C++ program- for example, if you remove the argumentsint argc, char** argvyou have a compilation error - but yes adefineor something worth it from a function calledSDL_main().– user142154
If you were using msvc just set Subsystem as windows
– Samuel Ives