SDL problem at run
Hi all, i'm new on this community and I'd like to ask you some questions:
I try a lot to use SDL on windows, and today with your old thread on this forum I can compile and link a program which use SDL without error.
Now when i run the program it start end end immediately, i don't know why the program do this. i put a getchar() at the end of file, before SDL_Quit() to stop the flow of program, but this is useless..
can be intersting that I am running windows on a virtual machine under vmware?
Thanks for all
This is my basic setup:
I use a while(true) loop, which repeats indefinitely, until the escape key is pressed- the loop then breaks and the program returns. All your program's "running" part goes inside the loop- drawing, input handling, etc. Getchar wont work, because SDL doesn't take input in this way- so it wont stop and wait for it.
BTW if you have that kind of setup already, and you know your program shouldnt be exiting straight away, look at the stderr file generated in your programs folder for an error message.
Hope that helped.
Edit: Minor error fix...
[Edited by - The Rug on October 24, 2004 9:26:41 AM]
#ifndef SDL_H#define SDL_H#include "SDL.h"#endifint main(int argc, char* argv[]) { SDL_Surface *screen; /* Initialize the SDL library */ if( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return -1; } /* * Initialize the display * requesting a software surface */ screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE | SDL_FULLSCREEN | SDL_DOUBLEBUF); // if ( screen == NULL ) { fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError()); return -1; } Uint8 *keys; // for capturing keyboard strokes while(true) { SDL_PumpEvents(); keys = SDL_GetKeyState(NULL); if (keys[SDLK_ESCAPE]) break; SDL_Flip(screen); // Buffer flip } return 0;}
I use a while(true) loop, which repeats indefinitely, until the escape key is pressed- the loop then breaks and the program returns. All your program's "running" part goes inside the loop- drawing, input handling, etc. Getchar wont work, because SDL doesn't take input in this way- so it wont stop and wait for it.
BTW if you have that kind of setup already, and you know your program shouldnt be exiting straight away, look at the stderr file generated in your programs folder for an error message.
Hope that helped.
Edit: Minor error fix...
[Edited by - The Rug on October 24, 2004 9:26:41 AM]
the rug - funpowered.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement