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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:53:37+00:00 2026-06-11T09:53:37+00:00

I am using the RayWenderlich OpenGL tutorial found here as a starting point for

  • 0

I am using the RayWenderlich OpenGL tutorial found here as a starting point for an app.
Upon adding my own textures though, I ran into some difficulty. No matter what any image I add to the project will just come up black. I’ve tried different settings of png’s (which are used in the sample) and JPEG’s. I’ve tried just changing the file name that is loaded and drawn by default and making a different texture instance and both just come up black.

I tried opening the floor texture in Photoshop and just resaving it, and it just came up invisible in the game.

But I tried duplicating the projects original tile_floor.png file with a different name which worked perfectly, so I’m assuming opengl requires a very specific format.

What do I have to do to get this working?

EDIT:

This is the method used to load the images:

static GLuint setupTexture(NSString *fileName) {

// 1
CGImageRef spriteImage = [UIImage imageNamed:fileName].CGImage;
if (!spriteImage) {
    NSLog(@"Failed to load image %@", fileName);
    exit(1);
}

// 2
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);    

// 3
CGContextDrawImage(spriteContext, CGRectMake(0, 0, width, height), spriteImage);

CGContextRelease(spriteContext);

// 4
GLuint texName;
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_2D, texName);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, spriteData);

free(spriteData);        
return texName;

}
  • 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-06-11T09:53:38+00:00Added an answer on June 11, 2026 at 9:53 am

    For non-power-of-two textures you need to set parameter GL_CLAMP_TO_EDGE for texture before glTexImage2D.

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading a tutorial http://www.raywenderlich.com/1914/how-to-save-your-app-data-with-nscoding-and-nsfilemanager about using NSCoding so that I can save
I have followed all the steps for implementing pushnotification using the raywenderlich tutorial but
I tested remote push notification using developemnt certificate as explained in below tutorial. http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
New developer here,Im using the Custom Image Picker by ray wenderlich. But what I
I am trying to follow a tutorial on Dynamic Textures in iOS by Ray
I am making a tile game. Was following http://www.raywenderlich.com/1163/how-to-make-a-tile-based-game-with-cocos2d . Using the whole screen
I followed this tutorial on raywenderlich.com and I came into a stop on the
I want to import an csv file in my app. I search but found
I am having a go at using RestKit by following this tutorial - RestKit
I downloaded Ray Wenderlich's simple contact listener from this tutorial: http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone Currently I am

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.