Problems with text rendering using TTF

Hi,

I’m trying to use text rendering supported by SDL_ttf

I based myself on the glfont example and ported it to my application

i have a main file and another file to and opengl specfic issues:

so i have the code divided. i use extern variables to access
information that reside in the main.

My problem is that the area where the text is supposed to appear, has
a texture that i’m using in my 3D part. I don’t understand why this
happens, since the name for the text texture is “texture” and the
other textures are call by Display Lists…

There are no problems opening the font or even rendering the text.
Everything seems just fine…

Font is generally 46 big, and string is 46 big
w:217 h:46

x:100 y:100 w:217 h:46

Can anybody give some lights here?

Thx

Nuno Santos wrote:

My problem is that the area where the text is supposed to appear, has
a texture that i’m using in my 3D part. I don’t understand why this
happens, since the name for the text texture is “texture” and the
other textures are call by Display Lists…

OpenGL texture names are integers, not strings. There’s nothing
preventing you from using the same texture in a display list and outside
of it. So, I can’t make much sense of what you’re saying. Can you show
us your code?

-Christian

Here it goes, a little bit in the render function;

glCallList(images[0]);	
drawCubeFace(1.024,0.768,6);

SDL_GL_Enter2DMode();

int x,y,w,h;
x = 100;
y = 100;
w = text->w;
h = text->h;

printf("x:%d y:%d w:%d h:%d\n",x,y,w,h);
glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(texMinX, texMinY);
glVertex2i(x,   y  );
glTexCoord2f(texMaxX, texMinY);
glVertex2i(x+w, y  );
glTexCoord2f(texMinX, texMaxY);
glVertex2i(x,   y+h);
glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
glEnd();

SDL_GL_Leave2DMode();Em Dec 3, 2006, ?s 8:43 AM, Christian Walther escreveu:

Nuno Santos wrote:

My problem is that the area where the text is supposed to appear, has
a texture that i’m using in my 3D part. I don’t understand why this
happens, since the name for the text texture is “texture” and the
other textures are call by Display Lists…

OpenGL texture names are integers, not strings. There’s nothing
preventing you from using the same texture in a display list and
outside
of it. So, I can’t make much sense of what you’re saying. Can you show
us your code?

-Christian


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

Nuno Santos wrote:

Here it goes, a little bit in the render function;

I can’t see anything wrong with that, but that’s not your whole code.
How are you generating the textures, and what’s in that display list?

-Christin

Hi,

This is how i define the list:

	glNewList(images[i] = glGenLists(1), GL_COMPILE);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

		glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
		glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
		glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
		glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
	
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w,h, 0, GL_RGB,  

GL_UNSIGNED_BYTE,imageData);
glEndList();

I cant put to much in just one email because it gets blocked,
awaiting for admin permission.

If you need more information please just tell me.

Thx,

Best regards,

NunoEm Dec 3, 2006, ?s 7:41 PM, Christian Walther escreveu:

Nuno Santos wrote:

Here it goes, a little bit in the render function;

I can’t see anything wrong with that, but that’s not your whole code.
How are you generating the textures, and what’s in that display list?

-Christin


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

Hello Nuno,

Sunday, December 3, 2006, 9:20:45 PM, you wrote:

Hi,

This is how i define the list:

glNewList(images[i] = glGenLists(1), GL_COMPILE);

Very bad. What if glGenLists() fails ? You will cause a crash.

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);

You aren’t doing any polygon rendering here - this is what display
lists are for. The GL driver will most likely see that you have done
no rendering work, and won’t have compiled anything.–
Best regards,
Peter mailto:@Peter_Mulholland

Hi,

I’m not very inside of the OpenGL api details but i tought i could
get some extra performance using display list to store textures…

I took this example from OpenGL superbible.

Well, they are working and i don’t any problem with compilation with
my program so far.

But, can this explain why i have textures being applied to the are
that i’m using to create text with SDL_ttf?

Cheers,

NunoEm Dec 3, 2006, ?s 10:32 PM, Peter Mulholland escreveu:

Hello Nuno,

Sunday, December 3, 2006, 9:20:45 PM, you wrote:

Hi,

This is how i define the list:

glNewList(images[i] = glGenLists(1), GL_COMPILE);

Very bad. What if glGenLists() fails ? You will cause a crash.

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);

You aren’t doing any polygon rendering here - this is what display
lists are for. The GL driver will most likely see that you have done
no rendering work, and won’t have compiled anything.


Best regards,
Peter mailto:darkmatter at freeuk.com


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

Hi everyone,

I’m trying a different approach.

I disabled all the 3D render and i’m doing only the 2D thing.

It doest work. It appears only a with rectangle…

Any tips?

Thx,

Nuno