Hi, I am using MinGW on Win32 and when I compile the following code, it works as expected. But when I open the resulting executable, I get both a console window and the SDL window I created. Any reason why I get this console window?
Code:
gcc main.c -o main.exe -Wall -lSDL -lSDLmain
Code:
#include <windows.h>
#include <SDL/SDL.h>
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
SDL_Surface *screen;
SDL_Event event;
if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}
screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE);
if (screen == NULL)
{
fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError());
exit(1);
}
SDL_WaitEvent(&event);
while(1)
{
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
exit(0);
break;
}
}
}
SDL_Quit();
return 0;
}
Sorry, the codebox screwed up some of my indents.