On Thu, Sep 3, 2009 at 2:05 PM,
PierreLafrance1@xxxxxxxxxxxx <PierreLafrance1@xxxxxxxxxxxx> wrote:
#include <stdio.h>
#include <stdlib.h>
#include "/usr/include/SDL/SDL.h"
int MySDL_WaitEvent()
{
printf("About to call SDL_WaitEvent(&event)\n");
SDL_Event event;
SDL_WaitEvent(&event);
switch (event.type)
{
printf("In switch/case of SDL_WaitEvent(&event)\n");
case SDL_KEYDOWN:
printf("The %s key was pressed!\n",
SDL_GetKeyName(event.key.keysym.sym));
break;
case SDL_QUIT:
exit(0);
}
}
int MySDL_PollEvent()
{
printf("About to call SDL_PollEvent(&event)\n");
SDL_Event event;
while ( SDL_PollEvent(&event) )
{
switch (event.type)
{
printf("In switch/case of SDL_PollEvent(&event)\n");
case SDL_MOUSEMOTION:
printf("Mouse moved by %d,%d to (%d,%d)\n",
event.motion.xrel, event.motion.yrel,
event.motion.x, event.motion.y);
break;
case SDL_MOUSEBUTTONDOWN:
printf("Mouse button %d pressed at (%d,%d)\n",
event.button.button, event.button.x, event.button.y);
break;
case SDL_QUIT:
exit(0);
}
}
}
int main(int argc, char *argv[])
{
printf("About to call SDL_Init()\n");
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
//fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
printf("Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}
while(1)
{
printf("About to call MySDL_PollEvent()\n");
MySDL_PollEvent();
printf("About to call MySDL_WaitEvent()\n");
MySDL_WaitEvent();
} // while
printf("About to call atexit()\n");
atexit(SDL_Quit);
}
--
Pierre Lafrance
--