I’m using SDL2 and want to use SDLU’s RenderCacheState and RestoreCacheState on iOS.
It’s not working - I’ve altered the rectangles SDL example to add a call to RenderCacheState, then RestoreCacheState, as follows:
Uint8 r, g, b;
SDL_RenderGetLogicalSize(renderer, &renderW, &renderH); /* Come up with a random rectangle */ SDL_Rect rect; rect.w = randomInt(64, 128); rect.h = randomInt(64, 128); rect.x = randomInt(0, renderW); rect.y = randomInt(0, renderH); /* Come up with a random color */ r = randomInt(50, 255); g = randomInt(50, 255); b = randomInt(50, 255); /* Fill the rectangle in the color */ SDL_SetRenderDrawColor(renderer, r, g, b, 255); SDL_RenderFillRect(renderer, &rect); SDLU_GL_RenderCacheState(renderer); // <------------ trying out this functionality SDLU_GL_RenderRestoreState(renderer); // <------------ trying out this functionality /* update screen */ SDL_RenderPresent(renderer);
When I run this in simulator and on an actual device, I see only one rectangle painted, then no more.
Firstly, is my code above a legal way and place to call these two functions? This should work, right?
I found a comment in the SDLU headers saying that this RenderCacheState functionality has been tested as working on MacOS and Linux, but other platforms may vary. So it may just not work on iOS, but I want to be sure my example code isn’t illegal in some way.