Font rendering problem

Member
Posts: 116
Joined: 2002.04
Post: #1
I'm embarrassed to post this question, but while I've worked around other's OpenGL code a lot, I'm a newbie to writing my own OpenGL code.

I'm trying to render a font to a texture. However, the rectangle is all black. I've tried absolutely everything I can think of and can't figure out what is assuredly a stupid error.

When I use OpenGL Profiler to pause the program, I can see that the texture exists in memory, looks correct and has the correct ID. In short, I don't think my problem is with rendering the text to the texture or binding the texture.

I've prepared a very small sample project illustrating the problem. The code is in GLView.m and there's a #define at the top of the file that allows you to toggle between a working image texture and the non-working font rendered to a texture.

If anyone would be willing to take a look, I'd be eternally grateful.


The code is at:
http://www.dogwatchsw.com/code/TextureTest.zip
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #2
Add:
Code:
[helv12Black setObject:[NSColor whiteColor] forKey:NSBackgroundColorAttributeName];

It's upside down, but I think you can figure it out from there. Wink

Also, you have a few other problems going on with your code. You need to pay attention to the warnings. In fact, I would suggest treating warnings as errors.
Quote this message in a reply
Member
Posts: 116
Joined: 2002.04
Post: #3
AnotherJake Wrote:Add:
Code:
[helv12Black setObject:[NSColor whiteColor] forKey:NSBackgroundColorAttributeName];

It's upside down, but I think you can figure it out from there. Wink

Also, you have a few other problems going on with your code. You need to pay attention to the warnings. In fact, I would suggest treating warnings as errors.

Jake,

Thanks....that got me on the right track. The texture was being drawn in black because GL_BEND hadn't been enabled.

As for the other problems - I'm aware - it's just test code and the problems don't affect the issue at hand.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #4
Don't know why you're seeing white on black. I see black on white on my machine. Perhaps this is an endian issue? I'm on an Intel.

Don't know how to fix the transparency thing off-hand. I assumed you'd search through other Quartz drawing options for that, I just tried to get you seeing something to work with. If you can't find anything soon or someone else doesn't offer up a solution soon, then bump the thread and I'll be happy to dig into it a little more. Wink
Quote this message in a reply
Member
Posts: 116
Joined: 2002.04
Post: #5
You replied while I was editing my post. I've got it now. Thanks for the idea.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #6
Great, that's good news! Grin
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Fast font rendering with per-character transformations moridinbg 5 4,707 Oct 22, 2009 12:56 PM
Last Post: moridinbg
  Text rendering problem with VBOs on myfeng 9 6,257 Feb 29, 2008 04:54 PM
Last Post: OneSadCookie
  Rendering on a Bitmap (Small Problem) person23 2 2,578 Mar 28, 2003 06:48 PM
Last Post: Mars_999