Jump to content

Recommended Posts

Posted

Hello

 

I'm having some trouble rendering text on my screen. Using the default font rendering DrawText() command I can get the text to show but when rendering the text on top of the content of the screen i get an blackbox around the the text (see picture) is it possible to render the text with an transparent background somehow? I've tried rendering it in my buffer and in the backbuffer.

 

my buffer is currently configured as this CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);

 

 

i've also implemented the FTGL font library in my attempts to get text rendering to work as I want. It supports several rendering styles Pixmap, polygon and texture rendering.

When rendering as pixmaps it works as expected but it's way to slow. When rendering as Textures there is no performance issues. But for some reason the text gets rendered upside-down, very annoying (see picture). I've gathered as much as you can scale textures with a negative value to flip them using glScalef(1.0, -1.0, 1.0) but I can't get that to work either, maybe I need to switch the opengl matrix?

 

My attempt to flip the text

glPushMatrix();
glLoadIdentity();
glScalef(1.0, -1.0, 1.0);
m_font->Render(text, -1, p);  // renders the texture
glPopMatrix();

 

I'd appreciate if some could point me in the right direction to help me solve these problems.

 

fonts.jpg

Posted

Call this:

glSetMatrixMode(GL_MODELVIEW_MATRIX)

 

Before your code and see if that helps.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted
Use DrawText() with SetBlend().

 

Aah of course :) , thanks!

 

 

Call this:

glSetMatrixMode(GL_MODELVIEW_MATRIX)

 

Before your code and see if that helps.

 

I tested that but no difference. My problem is that the scaling actually sort of works I can scale it from 1.0 -> 0.0 and it works as expected but I can't scale it to the negative side if I do the text disappears.

 

I need to read up on opengl's transformations :D

Posted

Reverse the polygon order or disable backface culling

 

glDisable(GL_CULL_FACE);

 

or

 

glFrontFace(GL_FILL,GL_CLOCKWISE/COUNTERCLOCKWISE) //something like that, off the top of my head

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Ok, I got it to work. After scaling the text I just needed to change the y position to it's negative. Instead of position it at y = 400 I need to position it at y = -400.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...