Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-09-2009, 02:09 PM   #1 (permalink)
krisix
Registered Member
 
Join Date: Sep 2009
Location: Poland
Age: 30
Posts: 6
krisix is on a distinguished road
Question Text with OpenGL

Hi,

I've created a project from default iPhone OpenGL project template. I'd like to place text on the view, so I'm trying to use Texture2D class provided by Apple.

In initWithCoder method I've added line:

Code:
testText = [[Texture2D alloc] initWithString:@"Test" dimensions:CGSizeMake(100, 100) alignment:UITextAlignmentLeft fontName:@"Helvetica" fontSize:30];
I've modified drawView method - it looks like this:

Code:
- (void)drawView {
    // Replace the implementation of this method to do your own custom drawing
    const GLfloat squareVertices[] = {
        -0.5f, -0.5f,
        0.5f,  -0.5f,
        -0.5f,  0.5f,
        0.5f,   0.5f,
    };
    const GLubyte squareColors[] = {
        255, 255,   0, 255,
        0,   255, 255, 255,
        0,     0,   0,   0,
        255,   0, 255, 255,
    };

    [EAGLContext setCurrentContext:context];

    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);

/*    
    glViewport(0, 0, backingWidth, backingHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);

    glMatrixMode(GL_MODELVIEW);
    glRotatef(3.0f, 0.0f, 0.0f, 1.0f);

    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    glVertexPointer(2, GL_FLOAT, 0, squareVertices);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
    glEnableClientState(GL_COLOR_ARRAY);

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

*/

    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    [testText drawAtPoint:CGPointMake(0.0f, 0.0f)];
         glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);


    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];

}
Could you help? I'm developing with OS 3.0. I've searched this forum for solution but everything I've found doesn't work for me. What am I doing wrong?

Thx

Krzychu
krisix is offline   Reply With Quote
 

» Advertisements
» Online Users: 694
21 members and 673 guests
Absentia, ADY, Ammad, ayesha25, Bertrand21, BrianSlick, coreyb, dacapo, Gaz, GHuebner, givensur, jeewan, kapps11, kosicki123, msovani, mutantskin, nobre84, pipposanta, rivers123, trunglee, wynonarr69
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,181
Threads: 93,920
Posts: 402,154
Top Poster: BrianSlick (7,968)
Welcome to our newest member, ayesha25
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:26 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.