Drawing text onto the screen

Discussion in 'iOS Programming' started by RPGamerL99, Oct 3, 2008.

  1. RPGamerL99 macrumors newbie

    Joined:
    Mar 10, 2008
    #1
    Hi, I am having trouble doing very basic things for an iPhone program. I started with an OpenGL ES Game template when selecting new project. I want to just display text on the top left corner of the screen along with the spinning square, or better yet, instead of it. Where does the program draw things to the screen and how would i be able to dynamically change what is displayed on screen from within the AppDelegate class.
     
  2. SqueegyX macrumors regular

    Joined:
    Mar 24, 2008
    #2
    The code would go in EAGLView class, if you are using the OpenGLES template. The drawView method gets called 60 times per second. THis is where the magic happens.

    And I don't think OpenGL has any native support for text, but I could be wrong about that.
     
  3. chrisesposito macrumors member

    Joined:
    Mar 23, 2008
    #3
    I think the GLUT ES library has what you need for this. A common approach for doing this in full OGL is texture-mapped quads, 1 quad per letter. The GLUT ES library can be found at http://glutes.sourceforge.net/

    Chris
     
  4. gruddlebug macrumors newbie

    Joined:
    Sep 13, 2008
    #4
    Hello,

    The Apple Crash Landing example does it.

    You could use the Texture2D class from that

    cheers

    evs
     
  5. SqueegyX macrumors regular

    Joined:
    Mar 24, 2008
    #5
    Does this work on the iPhone really? If so, thats pretty awesome.
     
  6. RPGamerL99 thread starter macrumors newbie

    Joined:
    Mar 10, 2008
    #6
    Thanks for the help, I will try the advice and see what happens.
     
  7. RPGamerL99 thread starter macrumors newbie

    Joined:
    Mar 10, 2008
    #7
    The animation happens 60 times a second, but I'm trying to get the animation to happen only when I want it to happen based on user action/game rules. I'm building the game rules in the App Delegate, so how do I stop the animation from automatically continue on its own, to controlling it within my gameLogic method in App Delegate?
     
  8. RPGamerL99 thread starter macrumors newbie

    Joined:
    Mar 10, 2008
    #8
    wouldn't this work for displaying text?

    Code:
    [myText drawAtPoint:CGPointMake(0.0,0.0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]];
     
  9. RPGamerL99 thread starter macrumors newbie

    Joined:
    Mar 10, 2008
    #9
    should i just put my game code in with the drawView?
     
  10. fat phil macrumors 6502

    Joined:
    Jul 11, 2008
    #10
    You'd have to draw the text into a texture.

    The crashlanding example mentioned by gruddlebug does this by creating a CGBitmap context and writing on this, then pushing it out as a texture.

    Note this isn't something you want to do for realtime text updates, so you'll want to write your own routines to work with a bitmap font (tpage) if you're thinking of anything that will liable to change every frame.
     

Share This Page