I am following this guide: http://davidgow.net/handmadepenguin/ch2.html
I am trying to get the screen to flip between black and white when it is redrawn. According to this guide, it is saying for now to put the render code when the SDL_WINDOWEVENT_EXPOSED event occurs. However, this event never seems to occur (confirmed through LLDB). According to the SDL documentation, it seems that the event occurs when part of the window is covered by another window. I have tried doing this to no avail. The window stays black at all times.
I can't seem to find anything on Google.
The difference between me and this guide is that I am doing this on OS X. Could this be the reason?
Here is my code:
void render(SDL_Window* window) {
SDL_Renderer* renderer = SDL_GetRenderer(window);
static bool isBlack = true;
if (isBlack) {
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
isBlack = false;
}
else {
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
isBlack = true;
}
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
void processWindowEvent(SDL_WindowEvent* we){
switch (we->event) {
case SDL_WINDOWEVENT_RESIZED: //this occurs at the proper time (when the window is resized)
printf("SDL_WINDOWEVENT_RESIZED (%d, %d)\n", we->data1, we->data2);
break;
case SDL_WINDOWEVENT_EXPOSED: //this is never hit
render(SDL_GetWindowFromID(we->windowID));
break;
}
}
void processEvent(SDL_Event* e) {
switch (e->type) {
case SDL_QUIT:
running = false;
break;
case SDL_WINDOWEVENT:
processWindowEvent(&e->window);
break;
}
}
Thanks very much!