SDL 1.3 and rendering API state management

[…]

The problem is that the SDL_TextureID returned from
SDL_CreateTextureFromSurface() is just an internal identifier, and
there is no API to get an OpenGL texture name or a Direct3D
texture interface object pointer from that.

That sounds like a minor API bug. You just need an API to let you
get at the texture id that SDL has hidden away somewhere else. Just
like the window id hack that is used to get Windows window ids for
people who want to tweak them directly.

That is easy enough to add and does not add complexity to the over
all design.

Yeah, that’s what I’m thinking. There is a minor issue though; OpenGL
uses an integer ID, whereas Direct3D uses a pointer to a texture
interface object. I suppose one could typedef something that will
work for both, on a platform by platform basis.

I wouldn’t even bother with a typedef. Just have one function for OpenGL
and one for Direct3D. If there are others then add specific functions
for them. This is not cross platform functionality and it should not
look like cross platform functionality.

	Bob PendletonOn Tue, 2006-09-05 at 17:14 +0200, David Olofson wrote:

On Tuesday 05 September 2006 16:46, Bob Pendleton wrote:

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --’


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

[…]

Yeah, that’s what I’m thinking. There is a minor issue though;
OpenGL uses an integer ID, whereas Direct3D uses a pointer to a
texture interface object. I suppose one could typedef something
that will work for both, on a platform by platform basis.

I wouldn’t even bother with a typedef. Just have one function for
OpenGL and one for Direct3D. If there are others then add specific
functions for them. This is not cross platform functionality and it
should not look like cross platform functionality.

Yeah, you’re right, of course. Unless you code for OpenGL or Direct3D,
you don’t even care if these calls exist. (Though it’s probably nice
if there are dummies even if you build SDL without OpenGL and/or
Direct3D renderers, just so add-on libs will still compile.)

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Tuesday 05 September 2006 17:31, Bob Pendleton wrote:

All that said, I still think runtime plugin renderers is a good idea.
It can be used to solve the “extended renderer” problem in an
efficient and rock solid way (by simply not having multiple renderers
on one context) - but it can also be used to implement support for
new targets and other things that you otherwise cannot do without
modifying SDL.

FYI, I am planning to make it possible for you to register your own
renderers, but first I want to finish the core set of renderers and
finalize the API.

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Le Lundi 4 Septembre 2006 23:41, Bob Pendleton a ?crit?:
[…]

OK, here I see we have two very different ways of looking at things.
Remember that I have spent several full time months each of the last 2
years working on adding multiple windows to SDL. I got it working the
way I want it on X11. Right now I am just sitting here biting my tongue
hoping SDL 1.3 will not undo all the work I have done.

The right way to do GUI tool kits is to have multiple windows and
windows within windows. The way I implemented it some windows can be
normal SDL 2D windows and some can be 3D OpenGL windows with each OpenGL
window having its own context. This way you can have any mixture of 2D
and 3D on the screen that you want. You can have 3D pop ups over 2D and
2D pop ups over 3D. You can have a 3D window as part of your screen with
a nice tree widget in a 2D window next to the 3D window.

No, you are kidding, right?
Mixing different graphic libraries or 2D and 3D windows messes things up
rather quickly …
And what if you want a GUI on top of your 3D environment?

Honestly, the best way is to choose one graphics lib (OpenGL, whatever) and
get your toolkit to use this for all of your drawings.

It took me just a few hours to get a basic OpenGL backend for Cairo, another
1.5h to get alpha blending and higher level stuff (patterns, gradients) right
(and I haven’t used cairo before).

You can strip off most of cairo to get a small vector graphics lib for every
graphics backend you want. OpenGL wasn’t that hard, D3D should work as
well …
(and with Mozilla and GTK going for cairo, it should be possible to render
those components in your window …)

Btw, I’d really appreciate if there would be a possibility to have just one
OpenGL context for all SDL windows (a context switch is rather expensive).

Best regards,
Johannes

Le Lundi 4 Septembre 2006 23:41, Bob Pendleton a ?crit :
[…]

OK, here I see we have two very different ways of looking at things.
Remember that I have spent several full time months each of the last 2
years working on adding multiple windows to SDL. I got it working the
way I want it on X11. Right now I am just sitting here biting my tongue
hoping SDL 1.3 will not undo all the work I have done.

The right way to do GUI tool kits is to have multiple windows and
windows within windows. The way I implemented it some windows can be
normal SDL 2D windows and some can be 3D OpenGL windows with each OpenGL
window having its own context. This way you can have any mixture of 2D
and 3D on the screen that you want. You can have 3D pop ups over 2D and
2D pop ups over 3D. You can have a 3D window as part of your screen with
a nice tree widget in a 2D window next to the 3D window.

No, you are kidding, right?

What part do you think I was kidding about. I have everything I
described working based on the SDL 1.2 code base.

Mixing different graphic libraries or 2D and 3D windows messes things up
rather quickly …

Yep, you can use the 2D API on 2D windows and the 3D API on the 3D
windows.

And what if you want a GUI on top of your 3D environment?

In the same window? Then you use the 3D API and build a GUI from scratch
or find one that works that way.

Honestly, the best way is to choose one graphics lib (OpenGL, whatever) and
get your toolkit to use this for all of your drawings.

That is not always the case. It makes perfect sense to implement a drop
down menu as a 2D window that is drawn on top of all other windows. Not
even hard to do using any modern windowing system.

It took me just a few hours to get a basic OpenGL backend for Cairo, another
1.5h to get alpha blending and higher level stuff (patterns, gradients) right
(and I haven’t used cairo before).

That is great, good for you. Does that have anything to do with SDL?

Bob PendletonOn Wed, 2006-09-06 at 01:02 +0200, Johannes Schmidt wrote:

You can strip off most of cairo to get a small vector graphics lib for every
graphics backend you want. OpenGL wasn’t that hard, D3D should work as
well …
(and with Mozilla and GTK going for cairo, it should be possible to render
those components in your window …)

Btw, I’d really appreciate if there would be a possibility to have just one
OpenGL context for all SDL windows (a context switch is rather expensive).

Best regards,
Johannes


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

Dear Bob,

sorry, shouldn’t be an offense!
I highly appreciate your contributions to SDL and the mailing list.

Le Mercredi 6 Septembre 2006 23:01, Bob Pendleton a ?crit?:
[…]

This way you can have any mixture
of 2D and 3D on the screen that you want.
[…]

No, you are kidding, right?

What part do you think I was kidding about. I have everything I
described working based on the SDL 1.2 code base.

Just the part of mixing 2D and 3D.
(I don’t like out of context replies, so I snipped probably too less. I tried
to make it clearer).
All the other parts are great.

[…]

Honestly, the best way is to choose one graphics lib (OpenGL, whatever)
and get your toolkit to use this for all of your drawings.

That is not always the case. It makes perfect sense to implement a drop
down menu as a 2D window that is drawn on top of all other windows. Not
even hard to do using any modern windowing system.

Perfectly true.
It’s just that I have seen too many apps starting with this concept, but
getting more and more cluttered with exceptions when extending the UI to
other parts of the screen.

It took me just a few hours to get a basic OpenGL backend for Cairo,
another 1.5h to get alpha blending and higher level stuff (patterns,
gradients) right (and I haven’t used cairo before).

That is great, good for you. Does that have anything to do with SDL?

Of course, if one reads just this sentence, this seems to be very arrogant.
But keep cool, the only purpose is to say that the above (using only one
graphics target) may be/is easier, e.g. with Cairo (see below) than taking
care of mixing 2D and 3D. And this even if you don’t know too much about 2D
rendering techniques (the given phrase), like, for example, me.

You can strip off most of cairo to get a small vector graphics lib for
every
graphics backend you want. OpenGL wasn’t that hard, D3D should work as
well …
(and with Mozilla and GTK going for cairo, it should be possible to render
those components in your window …)

Johannes

The right way to do GUI tool kits is to have multiple windows and
windows within windows. The way I implemented it some windows can be
normal SDL 2D windows and some can be 3D OpenGL windows with each
OpenGL window having its own context. This way you can have any mixture
of 2D and 3D on the screen that you want. You can have 3D pop ups over
2D and 2D pop ups over 3D. You can have a 3D window as part of your
screen with a nice tree widget in a 2D window next to the 3D window.

No, you are kidding, right?

What part do you think I was kidding about. I have everything I
described working based on the SDL 1.2 code base.

Is that available for download?

JeffOn Wed September 6 2006 14:01, Bob Pendleton wrote:

Well, I wouldn’t use that little trick if I hoped my program to work
well with some weird window managers in Linux (like Ion, wmi, etc)
that manage the window positions as they see fit, and not as the app
asks them to.

Just my 2 cents…

see yaOn 9/6/06, Bob Pendleton wrote:

And what if you want a GUI on top of your 3D environment?

In the same window? Then you use the 3D API and build a GUI from scratch
or find one that works that way.

Honestly, the best way is to choose one graphics lib (OpenGL, whatever) and
get your toolkit to use this for all of your drawings.

That is not always the case. It makes perfect sense to implement a drop
down menu as a 2D window that is drawn on top of all other windows. Not
even hard to do using any modern windowing system.

Dear Bob,

sorry, shouldn’t be an offense!

If no offense was meant then I will take no offense. Thank you for
noticing my reaction and taking action. I really do appreciate people,
such as you, who are sensitive to situations like this one.

I highly appreciate your contributions to SDL and the mailing list.

Le Mercredi 6 Septembre 2006 23:01, Bob Pendleton a ?crit :
[…]

This way you can have any mixture
of 2D and 3D on the screen that you want.
[…]

No, you are kidding, right?

Just for your information, in the culture I grew up in and live in, when
someone says they have put in a major amount of effort to accomplish
something you do not respond “No, you are kidding, right?”. It is an
extreme insult. I have seen a comment like that one end life long
friendships and result in violent fights.

What part do you think I was kidding about. I have everything I
described working based on the SDL 1.2 code base.

Just the part of mixing 2D and 3D.
(I don’t like out of context replies, so I snipped probably too less. I tried
to make it clearer).

We are going to have to disagree on this. I see no reason why I
shouldn’t use 2D and 3D windows (panes if you please) in the same
application and I have yet to write a 3D application where I didn’t need
to put 2D text and other features on top of 3D in the same pane.

And, I was not kidding I have implement what I described. I love what it
lets you do with SDL.

All the other parts are great.

[…]

Honestly, the best way is to choose one graphics lib (OpenGL, whatever)
and get your toolkit to use this for all of your drawings.

That is not always the case. It makes perfect sense to implement a drop
down menu as a 2D window that is drawn on top of all other windows. Not
even hard to do using any modern windowing system.

Perfectly true.
It’s just that I have seen too many apps starting with this concept, but
getting more and more cluttered with exceptions when extending the UI to
other parts of the screen.

Yes, when you do not have the tools to do it right you will find
yourself adding one kludge after the other to try to make it work, and
it never really does. To do GUIs right you need the concept of multiple
overlapping windows built into the tool kit. The windowing API should
handle windows and the graphics APIs should handle drawing.

It took me just a few hours to get a basic OpenGL backend for Cairo,
another 1.5h to get alpha blending and higher level stuff (patterns,
gradients) right (and I haven’t used cairo before).

That is great, good for you. Does that have anything to do with SDL?

Of course, if one reads just this sentence, this seems to be very arrogant.

I admit it isn’t very polite, I was very pissed off when I wrote it.
But, I do not see what this point has to do with SDL?

But keep cool, the only purpose is to say that the above (using only one
graphics target) may be/is easier, e.g. with Cairo (see below) than taking
care of mixing 2D and 3D. And this even if you don’t know too much about 2D
rendering techniques (the given phrase), like, for example, me.

This whole thread has been about adding functionality like the cairo
renderer to SDL as an extension to the existing SDL 2D API. I’m sorry
you are inexperienced in this subject. I have been doing graphics off
and on, mostly on, for 30 years and I feel inexperienced. And that is no
bull, just keeping up in this field is a full time job.

You can strip off most of cairo to get a small vector graphics lib for
every
graphics backend you want. OpenGL wasn’t that hard, D3D should work as
well …
(and with Mozilla and GTK going for cairo, it should be possible to render
those components in your window …)

Yes, if you are using GTK, not it you are using SDL. Those components
need to some porting effort if they are going to be useful in SDL. Are
you saying you have done that? What is the license on cairo? Can it be
integrated with SDL?

	Bob PendletonOn Thu, 2006-09-07 at 01:11 +0200, Johannes Schmidt wrote:

Johannes


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±-------------------------------------+

The right way to do GUI tool kits is to have multiple windows and
windows within windows. The way I implemented it some windows can be
normal SDL 2D windows and some can be 3D OpenGL windows with each
OpenGL window having its own context. This way you can have any mixture
of 2D and 3D on the screen that you want. You can have 3D pop ups over
2D and 2D pop ups over 3D. You can have a 3D window as part of your
screen with a nice tree widget in a 2D window next to the 3D window.

No, you are kidding, right?

What part do you think I was kidding about. I have everything I
described working based on the SDL 1.2 code base.

Is that available for download?

I haven’t made it available. Are you on Linux? It currently only works
on Linux.
Bob PendletonOn Wed, 2006-09-06 at 21:07 -0700, Jeff wrote:

On Wed September 6 2006 14:01, Bob Pendleton wrote:

Jeff


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

And what if you want a GUI on top of your 3D environment?

In the same window? Then you use the 3D API and build a GUI from scratch
or find one that works that way.

Honestly, the best way is to choose one graphics lib (OpenGL, whatever) and
get your toolkit to use this for all of your drawings.

That is not always the case. It makes perfect sense to implement a drop
down menu as a 2D window that is drawn on top of all other windows. Not
even hard to do using any modern windowing system.

Well, I wouldn’t use that little trick if I hoped my program to work
well with some weird window managers in Linux (like Ion, wmi, etc)
that manage the window positions as they see fit, and not as the app
asks them to.

To the best of my knowledge it always works on X11 when the drop down is
a subwindow of the application window. The window manager is supposed to
let you manage those by it self. On the other hand, using weird window
managers is its own reward, you get what you asked for.

Bob PendletonOn Thu, 2006-09-07 at 09:05 +0200, Juanval wrote:

On 9/6/06, Bob Pendleton <@Bob_Pendleton> wrote:

Just my 2 cents…

see ya


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

Linux (CentOS 4.3 and Red Hat 7.2). I have some Linux only projects that sure
could use some of the features you describe :slight_smile:

I’d be much obliged if you could send me a tarball or a URL to download.

Thanks,
JeffOn Thu September 7 2006 06:49, Bob Pendleton wrote:

I haven’t made it available. Are you on Linux? It currently only works
on Linux.

Another option in this direction is to just use cairo and SDL
together. I wrote a blurb on this on the cairo web site:

http://www.cairographics.org/SDL

ChrisOn 9/7/06, Bob Pendleton wrote:

This whole thread has been about adding functionality like the cairo
renderer to SDL as an extension to the existing SDL 2D API.


E-Mail: Chris Nystrom <@Chris_Nystrom>
http://www.newio.org/
AIM: nystromchris