Question

I'm following this tutorial on SDL. I tried translating the code to C, which can be viewed here. As you can guess, I want to use this code in an implementation of Conway's Game of Life. The code compiles and runs, and a white screen is drawn. But I am not getting any pixels drawn to the screen when I click around, and the program does not quit when I press the red OSX quit button or select quit from the menu.

If you look at the comments section of the tutorial, you can see that I asked the author of the tutorial the same question. He replied saying that the code works for him and that my problem may be due to a bug with OSX. I tried asking the forum that he recommended, but posting to the forum requires special user privileges that I haven't yet been granted. Sticking SDL_GetError() in various places in my program doesn't change the behavior of the program either.

Was it helpful?

Solution

A more widely known (but incomplete) tutorial is located here. I don't know if that helps.

Use SDL_PollEvent() instead of SDL_WaitEvent(). The reason for this is that WaitEvent waits untill an event happens (pausing the program) while PollEvent does not. Second the events should be handled in a loop ie: while(SDL_PollEvent(&e) {...} not SDL_WaitEvent(&e);...

The best thing for you do do is follow the other tutorials that I linked to since the tutorial you are using does not seem to be very well written. (you can just quickly reed through the stuff you already know)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top