[SDL] SDL_RenderCopy android

Dimitris Zenios dimitris.zenios at gmail.com
Fri Mar 8 01:03:11 PST 2013


Ok in order for everyone to be more clear.Attached you will find the simple
application.It doesn matter if i use two textures or just one which at
first i blit with NULL rects and then i pass a rect.


Below is the more important part.

    SDL_Rect rect;

    rect.x = 0;
    rect.y = 0;
    rect.w = 128;
    rect.h = 128;


SDL_LockTexture(MooseTexture,NULL,&texture_surface->pixels,&texture_surface->pitch);
    SDL_BlitSurface((SDL_Surface*)surface, NULL, texture_surface,NULL);
    SDL_UnlockTexture(MooseTexture);

    SDL_RenderClear(renderer);
    SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);
    SDL_RenderPresent(renderer);

    /* Loop, waiting for QUIT or the escape key */
    while (!done) {
        while (SDL_PollEvent(&event)) {
            switch (event.type) {
            case SDL_KEYDOWN:
                if (event.key.keysym.sym == SDLK_ESCAPE) {
                    done = SDL_TRUE;
                }
                break;
            case SDL_QUIT:
                done = SDL_TRUE;
                break;
            }
        }


        SDL_RenderCopy(renderer, MooseTexture, &rect, &rect);
        SDL_RenderPresent(renderer);
    }

I first draw the whole texture and present and then in a loop i only draw a
portion of a texture and present.I end up seeing only the portion.You can
see than i dont call anywhere in the loop RenderClear.Only copy and present.

I have also tried with a static texture instead of streaming with the same
results.

I am using GLES2.

Please tell me if you need anything else

P.S:I could not upload bg.jpeg cause of size limits.Its an empty white
background with some text in it


On Fri, Mar 8, 2013 at 10:57 AM, Dimitris Zenios
<dimitris.zenios at gmail.com>wrote:

> Ok in order for everyone to be more clear.Attached you will find the
> simple application.It doesn matter if i use two textures or just one which
> at first i blit with NULL rects and then i pass a rect.
>
>
> Below is the more important part.
>
>     SDL_Rect rect;
>
>     rect.x = 0;
>     rect.y = 0;
>     rect.w = 128;
>     rect.h = 128;
>
>
> SDL_LockTexture(MooseTexture,NULL,&texture_surface->pixels,&texture_surface->pitch);
>     SDL_BlitSurface((SDL_Surface*)surface, NULL, texture_surface,NULL);
>     SDL_UnlockTexture(MooseTexture);
>
>     SDL_RenderClear(renderer);
>     SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);
>     SDL_RenderPresent(renderer);
>
>     /* Loop, waiting for QUIT or the escape key */
>     while (!done) {
>         while (SDL_PollEvent(&event)) {
>             switch (event.type) {
>             case SDL_KEYDOWN:
>                 if (event.key.keysym.sym == SDLK_ESCAPE) {
>                     done = SDL_TRUE;
>                 }
>                 break;
>             case SDL_QUIT:
>                 done = SDL_TRUE;
>                 break;
>             }
>         }
>
>
>         SDL_RenderCopy(renderer, MooseTexture, &rect, &rect);
>         SDL_RenderPresent(renderer);
>     }
>
> I first draw the whole texture and present and then in a loop i only draw
> a portion of a texture and present.I end up seeing only the portion.You can
> see than i dont call anywhere in the loop RenderClear.Only copy and present.
>
> I have also tried with a static texture instead of streaming with the same
> results.
>
> I am using GLES2.
>
> Please tell me if you need anything else
>
>
>
>
> On Fri, Mar 8, 2013 at 6:55 AM, Sik the hedgehog <
> sik.the.hedgehog at gmail.com> wrote:
>
>> No idea, unless texture A is broken it should work... What device is
>> it? It could be useful to know whether it's OpenGL ES 1 or 2.
>>
>> Also: did you try drawing more textures besides the second one? Maybe
>> it would help us to get more hindsight on the issue (to see if only
>> the first texture is skipped or all but the last).
>>
>> 2013/3/7, Dimitris Zenios <dimitris.zenios at gmail.com>:
>> > Hello guys i have a problem on android
>> >
>> > i have two textures for now lets call them textureA and textureB.I am
>> doing
>> > these operations
>> >
>> > SDL_RenderClear(renderer);
>> > SDL_RenderCopy(renderer,texrureA,NULL,NULL);
>> > SDL_RenderCopy(renderer,textureB,srcrect,dstrect);
>> > SDL_RenderPresent(renderer);
>> >
>> > I end up with the first texture not beeing drawn and only the second on
>> a
>> > black background.
>> >
>> > It seems that somebody else had the same problem
>> >
>> http://forums.libsdl.org/viewtopic.php?t=7412&sid=664cf34c6d37a355564cf5c04bb0859a
>> >
>> > Any idea?
>> >
>> > Best Regards
>> > Dimitris Zenios
>> >
>> _______________________________________________
>> SDL mailing list
>> SDL at lists.libsdl.org
>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130308/0c1cf7be/attachment-0009.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 2775 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130308/0c1cf7be/attachment-0009.c>


More information about the SDL mailing list