Ok, another question on this, the following is the function that I use
to build my texture of strings and try to generate it. I seem to keep
getting a Segment Fault error when I run the program from this function
though.
void CFontManager::Update()
{
SDL_Surface *pScreen = 0;
SDL_Surface *pFinal = 0;
for (m_pit = m_PrintList.begin(); m_pit != m_PrintList.end();
++m_pit)
{
SDL_BlitSurface(m_pit->pSurface, 0, pFinal,
&(m_pit->pRect));
}
m_PrintList.clear();
glBindTexture(GL_TEXTURE_2D, m_uTextTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
// this is where I’m getting the error
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, pFinal->w, pFinal->h, 0,
GL_RGB, GL_UNSIGNED_BYTE, pFinal->pixels);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, m_uTextTexture);
glBegin(GL_QUADS);
// top left
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-100.0f, 100.0f, -1.0f);
// bottom left
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-100.0f, -100.0f, -1.0f);
// bottom right
glTexCoord2f(1.0f, 1.0f);
glVertex3f(100.0f, -100.0f, -1.0f);
// top right
glTexCoord2f(1.0f, 0.0f);
glVertex3f(100.0f, 100.0f, -1.0f);
glEnd();
glEnable(GL_DEPTH_TEST);
}
Alan> -----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Wolfe
Sent: Wednesday, April 28, 2004 5:45 PM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_ttf and OpenGL
up to you…gl is really flexible so it depends if thats what you want
to
do
or not
another way to do it would just be to draw a quad to the screen that
was
paralel to the screen (maybe turning off depth testing for this).
----- Original Message -----
From: “Kevin”
To:
Sent: Wednesday, April 28, 2004 1:25 PM
Subject: RE: [SDL] SDL_ttf and OpenGL
Ok, so after I convert the SDL_Surface to a gl texture, before I
draw
it, I’d have to switch to Ortho view, wouldn’t I?
-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf
Of
Alan
Wolfe
Sent: Wednesday, April 28, 2004 4:56 PM
To: sdl at libsdl.org
Subject: Re: [SDL] SDL_ttf and OpenGL
probably what you want to do is render the text to a surface,
convert
the
sdl surface to a gl texture and then use that texture.
for static text like “Score:” you could render it once and use it
many
times, while dynamic text like the actual score of a player, youd
have
to
re-render whenever that number changed.
----- Original Message -----
From: “Kevin”
To: “SDL Mailing List”
Sent: Wednesday, April 28, 2004 10:39 AM
Subject: [SDL] SDL_ttf and OpenGL
Just like the subject says, this is about using SDL_ttf with
OpenGL.
Does anyone know how I can get the text to show up on screen
with
the 3d
environment?
Do I need to update the main video surface as well as call
SDL_GL_SwapBuffers()? If so, what order do I call them in?
I can get SDL_ttf to work on a 2D screen, but it doesn’t display
anything when OpenGL is enabled.
Kevin Fields
kevin at thedorvo.net
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
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