Font rendering problem
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
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
Add:
It's upside down, but I think you can figure it out from there.
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.
Code:
[helv12Black setObject:[NSColor whiteColor] forKey:NSBackgroundColorAttributeName];It's upside down, but I think you can figure it out from there.

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.
AnotherJake Wrote:Add:
Code:
[helv12Black setObject:[NSColor whiteColor] forKey:NSBackgroundColorAttributeName];
It's upside down, but I think you can figure it out from there.
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.
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.
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.
You replied while I was editing my post. I've got it now. Thanks for the idea.
Great, that's good news!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Fast font rendering with per-character transformations | moridinbg | 5 | 3,520 |
Oct 22, 2009 12:56 PM Last Post: moridinbg |
|
| Text rendering problem with VBOs on | myfeng | 9 | 4,921 |
Feb 29, 2008 04:54 PM Last Post: OneSadCookie |
|
| Rendering on a Bitmap (Small Problem) | person23 | 2 | 2,300 |
Mar 28, 2003 06:48 PM Last Post: Mars_999 |
|

