The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Two renderers for the same window
techtonik


Joined: 04 Jan 2014
Posts: 16
Why can't I have two renderers for the same window? I am not sure if it is SDL2
limitation, but it allows me to create two, but when I try to draw on the second,
it fails with sdl2.ext.common.SDLError: 'Invalid renderer'
Two renderers for the same window
Ivan Rubinson
Guest

Are you trying to render split-screen, one half with OpenGL and the other half with Direct3D?

If not, then I don't see any point to doing what you are doing.


I don't think that it makes sense to have multiple renderers associated with the same window. I don't know for sure, but doesn't something prevent one from owning two contexts?
Also, it would make sense if OpenGL and Direct3D contexts conflict.

However, I don't know. This is all speculation on my part.



On Thu, Mar 27, 2014 at 1:36 PM, techtonik wrote:
Quote:
Why can't I have two renderers for the same window? I am not sure if it is SDL2
limitation, but it allows me to create two, but when I try to draw on the second,
it fails with sdl2.ext.common.SDLError: 'Invalid renderer'


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

mr_tawan


Joined: 13 Jan 2014
Posts: 161
What about having two renderers for a window, but using only one at a time ? I can't think of the benefits of this method, by the way.
techtonik


Joined: 04 Jan 2014
Posts: 16
Sorry. Missed my notification. I guess I wanted to do some pixel graphics in some separate renderer, because those 3D renderers were slow.

But perhaps the question comes from misunderstanding why SDL2 allow to create multiple renderer at all if you can only have one window?

Why have separate step for creating renderer?
Two renderers for the same window
Mason Wheeler
Guest

Who says you can only have one window? That hasn't been true since the SDL 1.2 days.



From: techtonik
To:
Sent: Thursday, February 11, 2016 2:51 AM
Subject: Re: [SDL] Two renderers for the same window


Sorry. Missed my notification. I guess I wanted to do some pixel graphics in some separate renderer, because those 3D renderers were slow.

But perhaps the question comes from misunderstanding why SDL2 allow to create multiple renderer at all if you can only have one window?

Why have separate step for creating renderer?



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
techtonik


Joined: 04 Jan 2014
Posts: 16
Ok, it is possible to have two windows. But what's the point in separating renderers from windows if they are 1:1 bound?
techtonik


Joined: 04 Jan 2014
Posts: 16
Ok, it is possible to have two windows. But what's the point in separating renderers from windows if they are 1:1 bound?
Two renderers for the same window
Mason Wheeler
Guest

The point is that a window is a window, and it's always done the same way on your OS, but there can be multiple different types of renderers supporting different backends.


Also, basic separation of concerns. The renderer doesn't need to care about stuff like the window title or whether it has Minimize and Maximize buttons, and the window doesn't need to know how to talk to OpenGL or D3D.


Mason



From: techtonik
Subject: Re: [SDL] Two renderers for the same window


Ok, it is possible to have two windows. But what's the point in separating renderers from windows if they are 1:1 bound?
Two renderers for the same window
Mason Wheeler
Guest

Also, they're not necessarily 1:1 bound. The default is to create a window that's fully filled up by a single renderer, but if you use SDL_CreateRendererFrom() you can bind a renderer to a native window handle and place it inside a window (aka form). I've used this before to have two renderers in the same form doing two different things.

Mason


From: techtonik
Subject: Re: [SDL] Two renderers for the same window


Ok, it is possible to have two windows. But what's the point in separating renderers from windows if they are 1:1 bound?
Two renderers for the same window
David Olofson
Guest

I'm not quite sure I understand the problem, or the question, but
another reason to separate them is that you may not even want to
render into an actual window. See SDL_CreateSoftwareRenderer().

And, there is SDL_CreateWindowAndRenderer(), if you want simpler code
and fewer options.

What's the big deal, anyway? One interface more or less... :-)


On Sat, Feb 13, 2016 at 7:11 PM, Mason Wheeler wrote:
Quote:
Also, they're not necessarily 1:1 bound. The default is to create a window
that's fully filled up by a single renderer, but if you use
SDL_CreateRendererFrom() you can bind a renderer to a native window handle
and place it inside a window (aka form). I've used this before to have two
renderers in the same form doing two different things.
Mason

________________________________
From: techtonik
Subject: Re: [SDL] Two renderers for the same window

Ok, it is possible to have two windows. But what's the point in separating
renderers from windows if they are 1:1 bound?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
| http://consulting.olofson.net http://olofsonarcade.com |
'---------------------------------------------------------------------'
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
techtonik


Joined: 04 Jan 2014
Posts: 16
> What's the big deal, anyway? One interface more or less... Smile

SDL2 became much more complicated and still doesn't have any diagrams or pictures that explain that stuff at all, so one interface more is like a headshot to for my tired brain which only dealt with plain x,y drawing planes in the past.
mr_tawan


Joined: 13 Jan 2014
Posts: 161
I think render can become invalid occasionally (context loses, driver crashes, etc.). If it's a part of the window, then you'd need to create a new window. By separating it, a new render could be created to replace the invalid one.
mr_tawan


Joined: 13 Jan 2014
Posts: 161
One more thing is, you don't even have to use renderer (with the Windows), in the case that you're using OpenGL or OpenGL ES (or may be Direct3D too, if I'm not mistaken). Separating the renderer out of the Windows implementation make more sense than combining them and let half of the functionality unused.
Two renderers for the same window
Ryan C. Gordon
Guest

On 02/13/2016 11:20 AM, techtonik wrote:
Quote:
Ok, it is possible to have two windows. But what's the point in
separating renderers from windows if they are 1:1 bound?

Because windows don't necessarily have renderers at all (you can use
Direct3D or OpenGL or Vulkan or Metal directly in an SDL window without
using SDL's rendering API), so it's not "you have 1 renderer per window"
it's "you have 0-1 renderers per window."

--ryan.



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Two renderers for the same window
Mason Wheeler
Guest

If you use SDL_CreateRendererFrom, you can actually have "0 or more renderers per window". (Yes, really. I've done it for a real-world use case.)


Mason



From: Ryan C. Gordon
Subject: Re: [SDL] Two renderers for the same window


On 02/13/2016 11:20 AM, techtonik wrote:
Quote:
Ok, it is possible to have two windows. But what's the point in
separating renderers from windows if they are 1:1 bound?

Because windows don't necessarily have renderers at all (you can use
Direct3D or OpenGL or Vulkan or Metal directly in an SDL window without
using SDL's rendering API), so it's not "you have 1 renderer per window"
it's "you have 0-1 renderers per window."

--ryan.
techtonik


Joined: 04 Jan 2014
Posts: 16
Having a window that does direct OpenGL rendering without SDL. Interesting option. I guess that explains it then.
Two renderers for the same window
Ryan C. Gordon
Guest

Quote:
If you use SDL_CreateRendererFrom, you can actually have "0 or more
renderers per window". (Yes, really. I've done it for a real-world use
case.)

o_O



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Two renderers for the same window
Mason Wheeler
Guest

Why is that so shocking? I created a form in a widget set and put two different SDL Frame controls on it. It was very useful!


Mason



From: Ryan C. Gordon
Subject: Re: [SDL] Two renderers for the same window

Quote:
If you use SDL_CreateRendererFrom, you can actually have "0 or more> renderers per window". (Yes, really. I've done it for a real-world use> case.)
o_O