|
Size: 1576
Comment: minor change
|
Size: 2256
Comment: add content from old wiki
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 16: | Line 16: |
| ||'''event'''||If not NULL, the next event is removed from the queue and stored in that area ,,'''event''',,.|| <<Color2(green,Prior to header updates this said "in event" but now reads "in that area" which matches a few other functions w/ the same parameter.)>> |
||'''event'''||,,if not NULL, the next event is removed from the queue and stored in that area,, ''-or-'' ^NULL, or^??? ^a pointer to the [[SDL_Event]] structure to store the next event^|| |
| Line 20: | Line 19: |
| Returns 1 if there are any pending events, or 0 if there are none available; call [[SDL_GetError]]() for more information. <<Color2(green,The previous author did not include any provision for an error RV. Can this function produce an error or only 0? Would you still call the error function?)>> | Returns 1 if there are any pending events, or 0 if there are none available; call [[SDL_GetError]]() for more information. <<Color2(green,Can this function produce an error or only 0? Would you still call the error function?)>> |
| Line 32: | Line 31: |
| * {{{ SDL_Event event; /* Event structure */ . . . /* Check for events */ while(SDL_PollEvent(&event)) { /* Loop until there are no events left on the queue */ switch(event.type) { /* Process the appropriate event type */ case SDL_KEYDOWN: /* Handle a KEYDOWN event */ printf("Oh! Key press\n"); break; case SDL_MOUSEMOTION: . . . default: /* Report an unhandled event */ printf("I don't know what this event is!\n"); } } }}} * |
|
| Line 34: | Line 56: |
| [[SDL_PollEvent]] is the favored way of receiving system events since it can be done from the main loop and does not suspend the main loop while waiting on an event to be posted. | *If '''event''' is not NULL, the next event is removed from the queue and stored in the [[SDL_Event]] structure pointed to by '''event'''. As this function implicitly calls [[SDL_PumpEvents]](), you can only call this function in the thread that set the video mode. * <<Color2(green,Is this true in 1.3?)>> [[SDL_PollEvent]]() is the favored way of receiving system events since it can be done from the main loop and does not suspend the main loop while waiting on an event to be posted. |
DRAFT |
SDL_PollEvent
Use this function to poll for currently pending events.
Contents
Syntax
int SDL_PollEvent(SDL_Event* event)
Function Parameters
event |
if not NULL, the next event is removed from the queue and stored in that area -or- NULL, or??? a pointer to the [[SDL_Event]] structure to store the next event |
Return Value
Returns 1 if there are any pending events, or 0 if there are none available; call SDL_GetError() for more information. green
Code Examples
while(1){
SDL_Event event;
if(SDL_PollEvent(&event)){
// handle your event here
}
// do some other stuff here -- draw your app, play your music, perform other operations...
}
*
SDL_Event event; /* Event structure */
.
.
.
/* Check for events */
while(SDL_PollEvent(&event)) { /* Loop until there are no events left on the queue */
switch(event.type) { /* Process the appropriate event type */
case SDL_KEYDOWN: /* Handle a KEYDOWN event */
printf("Oh! Key press\n");
break;
case SDL_MOUSEMOTION:
.
.
.
default: /* Report an unhandled event */
printf("I don't know what this event is!\n");
}
}*
Remarks
*If event is not NULL, the next event is removed from the queue and stored in the SDL_Event structure pointed to by event.
As this function implicitly calls SDL_PumpEvents(), you can only call this function in the thread that set the video mode. * green
SDL_PollEvent() is the favored way of receiving system events since it can be done from the main loop and does not suspend the main loop while waiting on an event to be posted.
