"OpenGL Text" && "SDL_Surface ok?"

I ran across this page
(http://gameprogrammer.com/polyfonts/polyfonts.html) talking about this
guy’s library for font writing in SDL, and one of his functions for
drawing the text (int pfDrawChar(SDL_Surface *s, wchar_t c); – okay,
all are somewhat similar) requires the use of an SDL_Surface. My
problem is that I was under the impression that the SDL_Surface created
by “SDL_SetVideoMode( width, height, bpp, SDL_OPENGL );” was rather
unusable for anything, including drawing to it or otherwise using it for
things. The example in the docs doesn’t even keep TRACK of this
SDL_Surface…

So, is it okay to draw to this surface or not, as I couldn’t find
anything stating one way or the other. Also, is this an acceptable
means of doing text in OpenGL (this guy’s library) or should I simply
just resort to using a texture on quads, and my own code for that?

Thanks,
–Scott

Umm. How do you usually draw things on the screen in SDL? You have
to know the screen’s SDL_Surface in order to do that. So I guess
the answer is YES, it’s OK to draw to this surface, but make
sure you SDL_LockSurface() it first (and unlock after…) See
sdldoc…

/Olof

Scott Harper: “[SDL] “OpenGL Text” && “SDL_Surface ok?”” (2004-05-28…

#I ran across this page
#(http://gameprogrammer.com/polyfonts/polyfonts.html) talking about this
#guy’s library for font writing in SDL, and one of his functions for
#drawing the text (int pfDrawChar(SDL_Surface *s, wchar_t c); – okay,
#all are somewhat similar) requires the use of an SDL_Surface. My
#problem is that I was under the impression that the SDL_Surface created
#by “SDL_SetVideoMode( width, height, bpp, SDL_OPENGL );” was rather
#unusable for anything, including drawing to it or otherwise using it for
#things. The example in the docs doesn’t even keep TRACK of this
#SDL_Surface…#
#So, is it okay to draw to this surface or not, as I couldn’t find
#anything stating one way or the other. Also, is this an acceptable
#means of doing text in OpenGL (this guy’s library) or should I simply
#just resort to using a texture on quads, and my own code for that?

#Thanks,
#–Scott

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

i don’t believe you can draw to an openGL buffer with anything but openGL
calls. i’m sure the polyfonts library calls openGL to actually draw to the
surface. my guess is the SDL_Surface pointer is there for the non-openGL
surface support (since polyfonts works with or without openGL).

bob can certainly answer this more clearly…> ----- Original Message -----

From: lareon@comcast.net (Scott Harper)
To: "A list for developers using the SDL library. (includes SDL-announce)"

Sent: Friday, May 28, 2004 2:22 PM
Subject: [SDL] “OpenGL Text” && “SDL_Surface ok?”

I ran across this page
(http://gameprogrammer.com/polyfonts/polyfonts.html) talking about this
guy’s library for font writing in SDL, and one of his functions for
drawing the text (int pfDrawChar(SDL_Surface *s, wchar_t c); – okay,
all are somewhat similar) requires the use of an SDL_Surface. My
problem is that I was under the impression that the SDL_Surface created
by “SDL_SetVideoMode( width, height, bpp, SDL_OPENGL );” was rather
unusable for anything, including drawing to it or otherwise using it for
things. The example in the docs doesn’t even keep TRACK of this
SDL_Surface…

So, is it okay to draw to this surface or not, as I couldn’t find
anything stating one way or the other. Also, is this an acceptable
means of doing text in OpenGL (this guy’s library) or should I simply
just resort to using a texture on quads, and my own code for that?

Thanks,
–Scott


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

— Miles Vignol wrote:

i don’t believe you can draw to an openGL buffer
with anything but openGL
calls.

There is the SDL_OPENGLBLIT flag, but you really
shouldn’t use it. Pretty much the only reason it
hasn’t been taken out is to preserve backwards
compatibility.> i’m sure the polyfonts library calls openGL

to actually draw to the
surface. my guess is the SDL_Surface pointer is
there for the non-openGL
surface support (since polyfonts works with or
without openGL).

bob can certainly answer this more clearly…

----- Original Message -----
From: “Scott Harper”
To: "A list for developers using the SDL library.
(includes SDL-announce)"

Sent: Friday, May 28, 2004 2:22 PM
Subject: [SDL] “OpenGL Text” && “SDL_Surface ok?”

I ran across this page

(http://gameprogrammer.com/polyfonts/polyfonts.html)
talking about this

guy’s library for font writing in SDL, and one of
his functions for
drawing the text (int pfDrawChar(SDL_Surface *s,
wchar_t c); – okay,
all are somewhat similar) requires the use of an
SDL_Surface. My
problem is that I was under the impression that
the SDL_Surface created
by “SDL_SetVideoMode( width, height, bpp,
SDL_OPENGL );” was rather
unusable for anything, including drawing to it or
otherwise using it for
things. The example in the docs doesn’t even keep
TRACK of this
SDL_Surface…

So, is it okay to draw to this surface or not, as
I couldn’t find
anything stating one way or the other. Also, is
this an acceptable
means of doing text in OpenGL (this guy’s library)
or should I simply
just resort to using a texture on quads, and my
own code for that?

Thanks,
–Scott


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


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


Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.

I ran across this page
(http://gameprogrammer.com/polyfonts/polyfonts.html) talking about this
guy’s library for font writing in SDL, and one of his functions for
drawing the text (int pfDrawChar(SDL_Surface *s, wchar_t c); – okay,
all are somewhat similar) requires the use of an SDL_Surface. My
problem is that I was under the impression that the SDL_Surface created
by “SDL_SetVideoMode( width, height, bpp, SDL_OPENGL );” was rather
unusable for anything, including drawing to it or otherwise using it for
things. The example in the docs doesn’t even keep TRACK of this
SDL_Surface…

Hi! I’m “that guy” who wrote that library. You are right in that you can
only use OpenGL to draw on an OpenGL surface.

The thing is that every SDL surface has a set of flags that you can
check to find out what kind of surface it is. In polyfonts I check that
flag all over the place. If you hand me a software surface, or even a
hardware surface, I use my own little library of software graphics
functions to draw the polygons and/or lines needed to draw the text. If
you hand me an OpenGL surface I use OpenGL to do the same thing. Hidden
inside of polyfonts is a tiny little library called sgl that implements
a tiny 2D almost subset of OpenGL that does everything I need to draw a
character.

So, yes, you can use polyfonts to draw text in an SDL/OpenGL program.
That is pretty much what I wrote it for. I just happened to have some
old graphics code floating around so I added the ability to use it with
all SDL surfaces. For my own personal use I have a version where I
stripped out the sgl library and only support OpenGL.

	Bob PendletonOn Fri, 2004-05-28 at 16:22, Scott Harper wrote:

So, is it okay to draw to this surface or not, as I couldn’t find
anything stating one way or the other. Also, is this an acceptable
means of doing text in OpenGL (this guy’s library) or should I simply
just resort to using a texture on quads, and my own code for that?

Thanks,
–Scott


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

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