SDL_PollEvent(&event)

hi

i m having problems with it.

yes unless i make an input game waits for an input which sucks. i made many researches but neither i find how to fix it nor how to make mine.

dont know what to do. what should i do?

thx in advance

EDIT: thats how i use

1
2
3
4
5
6
7
8
9
    bool quit = false;
    while(!quit)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            ///* funcs
        }
    }
Last edited on
1
2
3
4
5
6
7
8
9
10
    bool quit = false;
    while(!quit)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            ///* funcs
        }
    //i just added drawing funcs here and it is fine now
    }


nope the problem still goes on without an input it moves to next frame. how can i fix it
Last edited on
Inside "while(SDL_PollEvent(&event)" put:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
switch(event.type)
{
    case SDL_QUIT:
        quit = true;
    break;

    case SDL_KEYDOWN:
        switch(event.key.keysym.sym)
        {
            case SDLK_KEYUP:
                std::cout << "The up key was pressed!\n";
            break;
        }
    break;
}


Just add more cases with keys and continue on. The computer does not magically know what key you want to be pressed without telling it what. It's an idiot, really.
Last edited on
well thx for the help

but i already m doing it. and it doesnt moves to the next frame without an input.

i guess the problem is SDL_PollEvent uses SDL_WaitEvent. so i think maybe i should make my own?
Last edited on
According to this: http://sdl.beuc.net/sdl.wiki/SDL_PollEvent SDL_PollEvent does the opposite and actually calls SDL_PumpEvent.

My guess is that you have your game logic inside of the while (SDL_PollEvent(&event)) block; you should move it out of there since that block will only execute when there is input in the stream\stack. In fact the ONLY stuff that should be inside of that while loop is your input handling code.
wow thx. it fixed the prob. but i wonder why is that a problem
I'm sorry I couldn't be of much help. That code I posted usually works for me...

I guess we learn something new everyday.
haha yeah.
Topic archived. No new replies allowed.