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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:25:47+00:00 2026-05-28T05:25:47+00:00

I’ll keep it simple: The code listed at the end of this post is

  • 0

I’ll keep it simple: The code listed at the end of this post is in top-to-bottom order within my project. I have an OGLES2.0 framework in place which renders everything except textures perfectly. When rendering a single texture all I see is a black box of the correct dimensions.

Here’s what I’ve verified:

  • Having output the texture bytes (it’s format GL_ALPHA) it’s plain to see there are zero and none-zero values, so the data looks correct (or at least not all black!).

  • The texture ids are correct, verified by using the following in the vertex shader:
    gl_FragColor=vec4(v_texCoord.xy,0.0,1.0);
    ..and observing the expected black->green->yellow->red colour flow moving from (0,0)->(0,1)->(1,1)->(1,0) is seen.

  • My texture has power of two dimensions: 256 x 64, correctly reflected in the data array.

I’d be tremendously grateful for help in determining what’s wrong, as after several hours of googling and prodding I’m stumped!

glGenTextures(1, &_textureId);
GLint savedId;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &savedId);
glBindTexture(GL_TEXTURE_2D, _textureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLenum datatype = -1;
GLenum format = -1;
switch([self pixelFormat]) {
    case kGLTexturePixelFormat_RGBA8888:
        format=GL_RGBA;
        datatype=GL_UNSIGNED_BYTE;
        break;
    case kGLTexturePixelFormat_RGB565:
        format=GL_RGB;
        datatype=GL_UNSIGNED_SHORT_5_6_5;
        break;
    case kGLTexturePixelFormat_A8: // * This is current format, used for testing.
        format=GL_ALPHA;
        datatype=GL_UNSIGNED_BYTE;
        break;
    default:
        [NSException raise:NSInternalInconsistencyException format:@""];

}
glTexImage2D(GL_TEXTURE_2D, 0, format, [self pixelsWide], [self pixelsHigh], 0, format, datatype, [self data]);
glBindTexture(GL_TEXTURE_2D, savedId);
//...
GLint s_textureId = glGetUniformLocation(program, "s_texture");
//...
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, [_textureAtlas textureId]);
glUniform1i(s_textureId, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// In vertex shader:
attribute vec2 a_texCoord;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main() {
    // ...
    v_texCoord = a_texCoord;
}

// In fragment shader:
varying vec2 v_texCoord;
uniform sampler2D s_texture;
void main() {
    // ...
    gl_FragColor = texture2D(s_texture, v_texCoord);
}
  • 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-28T05:25:48+00:00Added an answer on May 28, 2026 at 5:25 am

    Your code looks fine, and I must say that I expect the output color to be black : as your texture is of GL_ALPHA format, the documentation of GL ES says :

    GL_ALPHA Each element is a single alpha component. The GL converts it
    to floating point and assembles it into an RGBA element by attaching 0
    for red, green, and blue.

    So if you want to display your alpha value as a greyscale color, you’ll need to instruct your fragment shader to do so :

    gl_FragColor = texture2D(s_texture, v_texCoord).aaaa;
    

    This will duplicate the alpha value in all red, green, red and alpha channels.

    If you want your output alpha channel to remain 1.0 (opaque), then you’ll want :

    gl_FragColor = vec4( texture2D(s_texture, v_texCoord).aaa, 1.0 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is 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.