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 536835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:51:49+00:00 2026-05-13T09:51:49+00:00

I have been at this for quite some time now, reading tutorials and so

  • 0

I have been at this for quite some time now, reading tutorials and so on, and I can’t work out what the heck is wrong with this, is anyone else able to help me understand what is going wrong?

// Sets up an array of values to use as the sprite vertices.
const GLfloat spriteVertices[] = {
    20.0f, 50.5f,
    305.0f, 50.0f,
    10.5f,  200.5f,
    300.5f,  300.5f,
};

// Sets up an array of values for the texture coordinates.
const GLshort spriteTexcoords[] = {
    0, 0,
    100, 0,
    0, 100,
    100, 100,
};

-(void)setupView:(GLView*)view {
    glMatrixMode(GL_PROJECTION); 
    CGRect rect = view.bounds; 

    glOrthof(0, rect.size.width, rect.size.height, 0, -1, 1);
    glViewport(0, 0, rect.size.width, rect.size.height);  
    glMatrixMode(GL_MODELVIEW);
    glDepthMask(GL_FALSE);
    glLoadIdentity();

    CGImageRef spriteImage = [UIImage imageNamed:@"rss_icon.png"].CGImage;
    size_t width = CGImageGetWidth(spriteImage);
    size_t height = CGImageGetHeight(spriteImage);  

    GLubyte *spriteData = 
      (GLubyte *) calloc(width * height * 4, sizeof(GLubyte));

    CGContextRef spriteContext = CGBitmapContextCreate(
      spriteData, width, height, 8, width * 4,
      CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast
    );

    CGContextDrawImage(
      spriteContext, 
      CGRectMake( 0.0, 0.0, (CGFloat)width, (CGFloat)height), 
      spriteImage
    );

    CGContextRelease(spriteContext);

    glGenTextures(1, &texture[0]);
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 
    glTexImage2D(
      GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, 
      GL_RGBA, GL_UNSIGNED_BYTE, spriteData
    );
    free(spriteData);

    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
}

Draw code:

- (void)drawView:(UIView *)theView {
    glLoadIdentity();
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);

    glVertexPointer(2, GL_FLOAT, 0, spriteVertices);
    glEnableClientState(GL_VERTEX_ARRAY);
    glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glClear(GL_COLOR_BUFFER_BIT);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
  • 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-13T09:51:49+00:00Added an answer on May 13, 2026 at 9:51 am

    The obvious problem might be that your texture has dimensions that are not a power of two. There’s a hardware restriction on iphone that requires them to be that way

    From Apple’s iPhone OpenGL ESProgramming Guide:

    The following are known limitations as
    of iPhone OS 3.0: The PowerVR SGX does
    not support non–power of two cube
    mapped or mipmapped textures

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

Sidebar

Related Questions

I have been asking myself this question for a long time now. Thought of
I have been hearing this term quite a lot. I have a bunch of
I have been reading up on this, and it seems that if you use
I have been trying to get around this error for a day now and
I have been playing with this for a while, but the closest I have
I have been working on this for the greater part of the day and
I have been trying to tackle this problem , but I am having difficulty
I have been using code similar to this MessageDlg('', mtWarning, [mbOK], 0); throughout my
I have been banging my head on this one all day. The C++ project
I have been searching for info on this to no avail. The context of

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.