OpenGL Text Rendering (in Cocoa)

Member
Posts: 35
Joined: 2009.01
Post: #1
Hello,

I'm curious as to how you guys generally go about rendering text in an OpenGL context. There are glut methods which in my experience are very limited, and the only other method I am aware of is using NSTextView subclasses as OpenGLView subviews and NSOpenGLCPSurfaceOrder.

The latter method is not resolution-independent, and (perhaps it is my fault due to some code-ordering issue, but) when moving these subviews around in response to the dynamic scrolling game world, they seem to lag behind - that is, they are not redrawn at the same time as the open gl content.

Has anyone experimented with using a characters texture and characters of varying widths? Is it possible for the widths of characters to vary as a result of those next to them? Would anyone be interested in helping me optimize an open source Cocoa Class that supports sizable text? I'm going to work on such a class and upload it here; perhaps it will be of use.

Maybe once static text drawing is implemented, I will implement the option to make this text editable.
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #2
I've got a class which generates OpenGL textures using FreeType. OneSadCookie posted some code that creates textures from NSView and its subclasses, which is pretty cool. There are a couple of other font libraries out there, or of course there's always the tried and trusted method of pre-rendering your character set into a PNG.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #3
The Cocoa OpenGL example shows how to do it. Look for GLString.m
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #4
DoG Wrote:The Cocoa OpenGL example shows how to do it. Look for GLString.m

Where's this demo? I'd like to check it out.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
I must admit, it is mighty hard to find. If you type it into google, it is inconveniently placed at the top of the page Rasp

Incidentally, GLString has a few weaknesses, I have a by now much more flexible and only slightly more complex code based on it that allows simple drawing of all kinds of Quartz stuff into textures. I'll post it as udg08 wraps up.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
You bastard.

(thanks)
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Fast rendering with OpenGL 1.1 dotbianry 4 3,756 Dec 18, 2012 03:58 AM
Last Post: dotbianry
  Opengl/Cocoa text rendering tesil 15 17,696 Mar 20, 2012 11:16 AM
Last Post: OneSadCookie
  SDL/OpenGL fullscreen text rendering StealthyCoin 2 6,580 Mar 26, 2009 09:47 AM
Last Post: StealthyCoin
  OpenGL & Cocoa - Improving frame rate daveh84 4 5,599 Feb 2, 2009 06:53 AM
Last Post: backslash
  bad depth sorting in Cocoa OpenGL aldermoore 2 4,687 Dec 30, 2008 03:07 PM
Last Post: ThemsAllTook