SDLU: RenderCacheState and RestoreCacheState on iOS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SDLU: RenderCacheState and RestoreCacheState on iOS

occular
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:








Code:
void
render(SDL_Renderer *renderer)
{
    Uint8 r, g, b;
    int renderW;
    int renderH;
   
    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.

Thanks!
Shocked

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SDLU: RenderCacheState and RestoreCacheState on iOS

neoaggelos-2
Hello and sorry for the terribly late reply,

First of all, does the code work properly on your desktop, or is it just iOS? Secondly, RenderCacheState() and
RenderRestoreState() have always been roots for problems (colors not showing up properly etc, with varying
success on different platforms).

For a while, I've been thinking that these are kinda hit-or-miss, because of the vast number of ways you can
render things with OpenGL. As in, I think there is little value in playing guess as to how they will be used, and
therefore what they should do in the background. Instead, would anyone benefit from a function like
SDLU_GL_PushGeometry() where you push many vertices-colors-texture at once?

Also, would you mind running the testrender2 program on your desktop? (It won't run on iOS, it uses OpenGL)

Thanks (and Merry Christmas),
Aggelos








occular wrote:
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:








Code:
void
render(SDL_Renderer *renderer)
{
    Uint8 r, g, b;
    int renderW;
    int renderH;
   
    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.

Thanks!
Shocked




C is the God's Programming Language

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SDLU: RenderCacheState and RestoreCacheState on iOS

neoaggelos-2
In reply to this post by occular
Hello and sorry for the terribly late reply,

First of all, does the code work properly on your desktop, or is just iOS? Secondly, RenderCacheState() and
RenderRestoreState() have always been roots for problems (colors not showing up properly etc, with varying
success on different platforms).

For a while, I've been thinking that these are kinda hit-or-miss, because of the vast number of ways you can
render things with OpenGL. As in, I think there is little value in playing guess as to how they will be used, and
therefore what they should do in the background. Instead, would anyone benefit from a function like
SDLU_GL_PushGeometry() where you push many vertices-colors-texture at once?

Also, would you mind running the testrender2 program on your desktop? (It won't run on iOS, it uses OpenGL)

Thanks (and Merry Christmas),
Aggelos








occular wrote:
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:








Code:
void
render(SDL_Renderer *renderer)
{
    Uint8 r, g, b;
    int renderW;
    int renderH;
   
    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.

Thanks!
Shocked




C is the God's Programming Language

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Loading...