Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6148119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:13:25+00:00 2026-05-23T19:13:25+00:00

Im using OpenGL for an app that im trying to make. I’ve been learning

  • 0

Im using OpenGL for an app that im trying to make. I’ve been learning from the apress book Beggining iPhone Games Development.

The problem I have is that a texturedQuad which is a subclass of my mesh class doesn’t seem to be rendering properly. (Although it works in the simulator.) The quad renders as just a plain colors that I have set in the texturedQuad class and doesn’t seem to be rendering the texture.

This is in a class that is called MenuOptionObject.m which is the actual object that I’m trying to render which I feel is similar to the spaceShip.m file used in the examples. That file did work so I dont get why this wont when I’m using virtually the same ‘engine’ if you could call it that.

I have a feeling I’m missing something blatent. The examples I worked on worked. I also have a class called texturedButton that does work and also uses the texturedQuad.

Heres the mesh.m code:

 #import "Mesh.h"
#import "MaterialController.h"
#import "TexturedQuad.h"


@implementation Mesh

@synthesize vertexCount,vertexSize,colorSize,renderStyle,vertexes,colors;

- (id)initWithVertexes:(CGFloat*)verts 
           vertexCount:(NSInteger)vertCount 
            vertexSize:(NSInteger)vertSize
           renderStyle:(GLenum)style;
{
    self = [super init];
    if (self != nil) 
    {
        self.vertexes = verts;
        self.vertexCount = vertCount;
        self.vertexSize = vertSize;
        self.renderStyle = style;
    }
    return self;
}

// called once every frame
-(void)render
{
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisable(GL_TEXTURE_2D);
    // load arrays into the engine
    glVertexPointer(vertexSize, GL_FLOAT, 0, vertexes);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColorPointer(colorSize, GL_FLOAT, 0, colors); 
    glEnableClientState(GL_COLOR_ARRAY);

    //render
    glDrawArrays(renderStyle, 0, vertexCount);  
}


+(CGRect)meshBounds:(Mesh*)mesh scale:(BBPoint)scale
{
    if (mesh == nil) return CGRectZero;
    // need to run through my vertexes and find my extremes
    if (mesh.vertexCount < 2) return CGRectZero;
    CGFloat xMin,yMin,xMax,yMax;
    xMin = xMax = mesh.vertexes[0];
    yMin = yMax = mesh.vertexes[1];
    NSInteger index;
    for (index = 0; index < mesh.vertexCount; index++) {
        NSInteger position = index * mesh.vertexSize;
        if (xMin > mesh.vertexes[position] * scale.x) xMin = mesh.vertexes[position] * scale.x;
        if (xMax < mesh.vertexes[position] * scale.x) xMax = mesh.vertexes[position] * scale.x;
        if (yMin > mesh.vertexes[position + 1] * scale.y) yMin = mesh.vertexes[position + 1] * scale.y;
        if (yMax < mesh.vertexes[position + 1] * scale.y) yMax = mesh.vertexes[position + 1] * scale.y;
    }
    CGRect meshBounds = CGRectMake(xMin, yMin, xMax - xMin, yMax - yMin);
    if (CGRectGetWidth(meshBounds) < 1.0) meshBounds.size.width = 1.0;
    if (CGRectGetHeight(meshBounds) < 1.0) meshBounds.size.height = 1.0;
    return meshBounds;
}

- (void) dealloc
{
    [super dealloc];
}



@end

Heres the texturedQuad.m code:

    #import "TexturedQuad.h"

static CGFloat TexturedQuadVertexes[8] = 
{
    -0.5,-0.5, 0.5,-0.5, 
    -0.5,0.5, 0.5,0.5
};
static CGFloat TexturedQuadColorValues[16] = 
{
    1.0,1.0,1.0,1.0, 
    1.0,1.0,1.0,1.0, 
    1.0,1.0,1.0,1.0, 
    1.0,1.0,1.0,1.0
};

@implementation TexturedQuad

@synthesize uvCoordinates,materialKey;

- (id) init
{
    self = [super initWithVertexes:TexturedQuadVertexes vertexCount:4 vertexSize:2 renderStyle:GL_TRIANGLE_STRIP];
    if (self != nil) {
        // 4 vertexes
        uvCoordinates = (CGFloat *) malloc(8 * sizeof(CGFloat));
        colors = TexturedQuadColorValues;
        colorSize = 4;
    }
    return self;
}

// called once every frame
-(void)render
{
    glVertexPointer(vertexSize, GL_FLOAT, 0, vertexes);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColorPointer(colorSize, GL_FLOAT, 0, colors); 
    glEnableClientState(GL_COLOR_ARRAY);

    if (materialKey != nil) {
        [[MaterialController sharedController] bindMaterial:materialKey];

        glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
        glTexCoordPointer(2, GL_FLOAT, 0, uvCoordinates);
    } 
    //render
    glDrawArrays(renderStyle, 0, vertexCount);  
}


- (void) dealloc
{
    free(uvCoordinates);
    [super dealloc];
}

@end

And lastly for the MenuOptionObject.m:

#import "MenuOptionObject.h"
#import "MaterialController.h"
#import "MenuSceneController.h"

@implementation MenuOptionObject
@synthesize bounds, circleBouncePoint;

-(id)initWithQuad:(NSString *)quad
{
    self = [super init];
    if (self != nil)
    {
        self.mesh = [[MaterialController sharedController] quadFromAtlasKey:quad];
    }
    return self;
}

// called once when the object is first created.
-(void)awake
{   
    self.scale = BBPointMake(28.0, 28.0, 1.0);
    self.sceneController = (SceneController *)[MenuSceneController sharedController];
}

-(void)update
{
    [super update];
    //[self sideCollisionUpdates];
    //[self circleCollisionUpdates];
}


-(void)dealloc
{
    [sceneController release];
    [super dealloc];
}

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:13:26+00:00Added an answer on May 23, 2026 at 7:13 pm

    Answer turned out to be the even though my texture was called menuAtlas both in the file manager at the side and in the code it wouldn’t work so changing both to mA worked. I don’t understand why but I have a suspicion that it involves something to do with caching.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I'm trying to develop an app that uses opengl on android, and ideally make
I'm using an NSTimer to do some rendering in an OpenGL based iPhone app.
I'm using OpenGL ES 1.1 to render a large view in an iPhone app.
Good afternoon. I have been making a small openGL based app for android that
I'm trying to write an iPhone app that takes PNG tilesets and displays segments
I'm working on an iPhone app that uses OpenGL ES 2 for its drawing.
I've been writing programs using OpenGL. Recently, I started learning OpenGL Shading Language. I'm
I'd much rather code an app using pure C api such as OpenGL, rather
I've been using OpenGL extensions on Windows the painful way . Is GLEW the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.