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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:20:52+00:00 2026-05-14T00:20:52+00:00

I have a very basic texture map problem in GL on iPhone, and I’m

  • 0

I have a very basic texture map problem in GL on iPhone, and I’m wondering what strategies there are for debugging this kind of thing.

(Frankly, just staring at state machine calls and wondering if any of them is wrong or misordered is no way to live– are there tools for this?)

I have a 512×512 PNG file that I’m loading up from disk (not specially packed), creating a CGBitmapContext, then calling CGContextDrawImage to get bytes out of it. (This code is essentially stolen from an Apple sample.) I’m trying to map the texture to a “quad”, with code that looks essentially like this– all flat 2D stuff, nothing fancy:

glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);    
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

GLfloat vertices[8] = {
    viewRect.origin.x, viewRect.size.height,
    viewRect.origin.x, viewRect.origin.y,
    viewRect.size.width, viewRect.origin.y,
    viewRect.size.width, viewRect.size.height        
};    
GLfloat texCoords[8] = {
    0, 1.0,
    0, 0,
    1.0, 0,
    1.0, 1.0
};

glBindTexture(GL_TEXTURE_2D, myTextureRef); // This was previously bound to 
glVertexPointer(2, GL_FLOAT , 0, vertices); 
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);    

glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
  • My supposedly textured area comes out just black.
  • I see no debug output from the CG calls to set up the texture.
  • glGetError reports nothing.
  • If I simplify this code block to just draw the verts, but set up a pure color, the quad area lights up exactly as expected.
  • If I clear the whole context immediately beforehand to red, I don’t see the red– which means something is being rendered there, but not the contents of my PNG.

What could I be doing wrong? And more importantly, what are the right tools and techniques for debugging this sort of thing, because running into this kind of problem and not being able to “step through it” in a debugger in any meaningful way is a bummer.

Thanks!

  • 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-14T00:20:53+00:00Added an answer on May 14, 2026 at 12:20 am

    What’s the result if you just draw the
    quad without texture and without
    setting a color? If it’s black try
    using GL_REPLACE instead of
    GL_MODULATE. – Maurice Gilden Mar 11
    at 16:15

    This did it. MODULATE wasn’t working. REPLACE did.
    Thanks Maurice.

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

Sidebar

Ask A Question

Stats

  • Questions 436k
  • Answers 436k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer <add name="defaultCache" duration="900" varyByParam="*" varyByCustom="membership" location="Any"/> Global.asax: public override string… May 15, 2026 at 3:56 pm
  • Editorial Team
    Editorial Team added an answer I got steadily decreasing times from 2.5, 2.6, 2.7 and… May 15, 2026 at 3:56 pm
  • Editorial Team
    Editorial Team added an answer Why just not check the date returned from formatter and… May 15, 2026 at 3:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.