Jump to content

Font rendering


Patrik
 Share

Recommended Posts

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

Link to comment
Share on other sites

Use DrawText() with SetBlend().

 

SetBlend(1)
DrawText("hello",0,50)
SetBlend(0)

 

as for the other fonts, i just use bitmap fonts created with fontstudio (which used to be posted here but was lost due to the forum data loss)

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...