SDL1.3: SDL_RenderCopy() with multiple windows

Hi,

I’m trying to get an application running which does output into
multiple windows. The output is done with SDL_RenderCopy() on X11.
The problem is that the output into one window works perfectly,
but if I use two windows, the second window remains black. I’m
doing something like this:

/* create window, texture, surface */
window[i] = SDL_CreateWindow(NULL, x, y, w, h, SDL_WINDOW_SHOWN);
rc = SDL_CreateRenderer(window[i], -1,
SDL_RENDERER_SINGLEBUFFER |
SDL_RENDERER_PRESENTDISCARD);
Assert(rc == 0);
SDL_GetRendererInfo(&renderInfo[i])
texture[i] = SDL_CreateTexture(desktop_mode.format,
SDL_TEXTUREACCESS_STREAMING, w, h);
rc = SDL_QueryTexturePixels(texture[i], &pixels, &pitch);
Assert(rc == 0);
surface[i] = SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch,
Rmask, Gmask, Bmask, Amask);
working[i] = SDL_CreateRGBSurfaceFrom(…);

/* render the working surface to the window */
SDL_BlitSurface(working[i], &srcRect, surface[i], &dstRect);
SDL_SelectRenderer(window[i]);
SDL_DirtyTexture(texture[i], 1, &dstRect);
Assert(renderInfo[i].flags & SDL_RENDERER_PRESENTCOPY);
SDL_RenderCopy(texture[i], &dstRect, &dstRect);
SDL_RenderPresent();

‘working’ is updated by the application and copied to ‘surface’ with
SDL_BlitSurface() which is then rendered to the window.

If I try to use two windows (i is 0 or 1), then only the first window
is updated and the second window remains black. The other window can
be changed with other means, for instance with SDL_RenderFill(), but
doing SDL_RenderCopy on two windows does not work.

Is there a principle problem with my code?

Thanks,

Frank–
Dr.-Ing. Frank Mehnert Sun Microsystems, Inc. www.sun.com
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090528/c032f98e/attachment.pgp

Sorry for replying myself. Just found the problem. In the example
below there was code missing for re-creation of a texture. The
problem was that I created the texture in the context of the wrong
renderer. After adding SDL_SelectRenderer(window) before I re-
create a texture, everything works as expected.

Thanks for listening :wink:

FrankOn Thursday 28 May 2009, Frank Mehnert wrote:

I’m trying to get an application running which does output into
multiple windows. The output is done with SDL_RenderCopy() on X11.
The problem is that the output into one window works perfectly,
but if I use two windows, the second window remains black. I’m
doing something like this:

/* create window, texture, surface */
window[i] = SDL_CreateWindow(NULL, x, y, w, h, SDL_WINDOW_SHOWN);
rc = SDL_CreateRenderer(window[i], -1,
SDL_RENDERER_SINGLEBUFFER |
SDL_RENDERER_PRESENTDISCARD);
Assert(rc == 0);
SDL_GetRendererInfo(&renderInfo[i])
texture[i] = SDL_CreateTexture(desktop_mode.format,
SDL_TEXTUREACCESS_STREAMING, w, h);
rc = SDL_QueryTexturePixels(texture[i], &pixels, &pitch);
Assert(rc == 0);
surface[i] = SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch,
Rmask, Gmask, Bmask, Amask);
working[i] = SDL_CreateRGBSurfaceFrom(…);

/* render the working surface to the window */
SDL_BlitSurface(working[i], &srcRect, surface[i], &dstRect);
SDL_SelectRenderer(window[i]);
SDL_DirtyTexture(texture[i], 1, &dstRect);
Assert(renderInfo[i].flags & SDL_RENDERER_PRESENTCOPY);
SDL_RenderCopy(texture[i], &dstRect, &dstRect);
SDL_RenderPresent();

‘working’ is updated by the application and copied to ‘surface’ with
SDL_BlitSurface() which is then rendered to the window.

If I try to use two windows (i is 0 or 1), then only the first window
is updated and the second window remains black. The other window can
be changed with other means, for instance with SDL_RenderFill(), but
doing SDL_RenderCopy on two windows does not work.

Is there a principle problem with my code?

Thanks,

Frank


Dr.-Ing. Frank Mehnert

Sitz der Gesellschaft:
Sun Microsystems GmbH, Sonnenallee 1, 85551 Kirchheim-Heimstetten
Amtsgericht M?nchen: HRB 161028
Gesch?ftsf?hrer: Thomas Schr?der, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin H?ring
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090528/141a54c5/attachment.pgp

I’m glad you figured it out! :slight_smile:

See ya,
–SamOn Thu, May 28, 2009 at 12:33 AM, Frank Mehnert <Frank.Mehnert at sun.com>wrote:

Sorry for replying myself. Just found the problem. In the example
below there was code missing for re-creation of a texture. The
problem was that I created the texture in the context of the wrong
renderer. After adding SDL_SelectRenderer(window) before I re-
create a texture, everything works as expected.

Thanks for listening :wink:

Frank

On Thursday 28 May 2009, Frank Mehnert wrote:

I’m trying to get an application running which does output into
multiple windows. The output is done with SDL_RenderCopy() on X11.
The problem is that the output into one window works perfectly,
but if I use two windows, the second window remains black. I’m
doing something like this:

/* create window, texture, surface */
window[i] = SDL_CreateWindow(NULL, x, y, w, h, SDL_WINDOW_SHOWN);
rc = SDL_CreateRenderer(window[i], -1,
SDL_RENDERER_SINGLEBUFFER |
SDL_RENDERER_PRESENTDISCARD);
Assert(rc == 0);
SDL_GetRendererInfo(&renderInfo[i])
texture[i] = SDL_CreateTexture(desktop_mode.format,
SDL_TEXTUREACCESS_STREAMING, w, h);
rc = SDL_QueryTexturePixels(texture[i], &pixels, &pitch);
Assert(rc == 0);
surface[i] = SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch,
Rmask, Gmask, Bmask, Amask);
working[i] = SDL_CreateRGBSurfaceFrom(…);

/* render the working surface to the window */
SDL_BlitSurface(working[i], &srcRect, surface[i], &dstRect);
SDL_SelectRenderer(window[i]);
SDL_DirtyTexture(texture[i], 1, &dstRect);
Assert(renderInfo[i].flags & SDL_RENDERER_PRESENTCOPY);
SDL_RenderCopy(texture[i], &dstRect, &dstRect);
SDL_RenderPresent();

‘working’ is updated by the application and copied to ‘surface’ with
SDL_BlitSurface() which is then rendered to the window.

If I try to use two windows (i is 0 or 1), then only the first window
is updated and the second window remains black. The other window can
be changed with other means, for instance with SDL_RenderFill(), but
doing SDL_RenderCopy on two windows does not work.

Is there a principle problem with my code?

Thanks,

Frank


Dr.-Ing. Frank Mehnert

Sitz der Gesellschaft:
Sun Microsystems GmbH, Sonnenallee 1, 85551 Kirchheim-Heimstetten
Amtsgericht M?nchen: HRB 161028
Gesch?ftsf?hrer: Thomas Schr?der, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin H?ring


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org