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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:36:47+00:00 2026-06-13T18:36:47+00:00

I’m trying to apply a texture to an object in opengl es from the

  • 0

I’m trying to apply a texture to an object in opengl es from the native side and I have no idea why it isn’t showing up. I have a couple random objects drawn on the screen, and they’re all visible and everything. I applied color to some shapes using glColor4f and that works fine. I’m trying to use a texture on the last object that gets drawn but it ends up being the same color as the one previous.

I was originally loading the texture from a png, but I decided to simplify things by loading it from a file that contains raw RGB data. It’s 16 pixels x 16 pixels, and I’ve tried sizes up to 512 by 512 with the same result.

Here’s how I’m initializing everything:

bool Activity::_initGL () {
  const EGLint attribs[] = {
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
    EGL_BLUE_SIZE, 8,
    EGL_GREEN_SIZE, 8,
    EGL_RED_SIZE, 8,
    EGL_NONE
  };
  EGLint dummy, format;
  EGLint numConfigs;
  EGLConfig config;

  display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  eglInitialize(display, 0, 0);
  eglChooseConfig(display, attribs, &config, 1, &numConfigs);
  eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
  ANativeWindow_setBuffersGeometry(app->window, 0, 0, format);
  surface = eglCreateWindowSurface(display, config, app->window, NULL);
  context = eglCreateContext(display, config, NULL, NULL);

  if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
    LOGE("Unable to eglMakeCurrent");
    return false;
  }

  eglQuerySurface(display, surface, EGL_WIDTH, &width);
  eglQuerySurface(display, surface, EGL_HEIGHT, &height);
  glViewport(0,0, width, height);
}

And then I enable the necessary things and try to create the texture:

void postInit () {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
  glDisable( GL_BLEND );
  glDisable( GL_LIGHTING );
//   glEnable(GL_CULL_FACE);
  glEnable( GL_TEXTURE_2D );

  glShadeModel(GL_SMOOTH);
  glDisable(GL_DEPTH_TEST);

  glClearColor(0,0,0,1);
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);

//   glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
  glMatrixMode( GL_MODELVIEW );

  GLuint texIDarray[1];
  glGenTextures( 1, texIDarray );
  glActiveTexture( GL_TEXTURE0 );
  glBindTexture( GL_TEXTURE_2D, texIDarray[0] );
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)16, (GLsizei)16, 0, GL_RGB, GL_UNSIGNED_BYTE, protData);

}

And here’s where the texture gets drawn, someday:

void drawImpl () {
  glClear(GL_COLOR_BUFFER_BIT); 
  glLoadIdentity();
//  glDisable(GL_TEXTURE_2D);
//  glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
//  glEnableClientState(GL_VERTEX_ARRAY);
//  glViewport(0, 0, wid, hei);

#define fX(x) ((int)(x * (1  << 16)))
  static int verts[6] = {
    0,0,
    65536,0,
    0,30000
  };
  glVertexPointer(2, GL_FIXED, 0, verts);
//   glColor4f(1,0,1,1);
  glDrawArrays(GL_TRIANGLES, 0, 3);

  static int poo[12] = {
    40000,-5000,
    40000,-30000,
    60000,-5000,

60000,-5000,
40000,-30000,
60000,-30000    
  };
  glVertexPointer(2, GL_FIXED, 0, poo);
 // glColor4f(1,1,1,1);
  glDrawArrays(GL_TRIANGLES, 0, 6);

  static int pee[12] = {
    40000, 5000,
    60000, 5000,
    60000,30000,

40000, 5000,
60000,30000,
40000,30000 
  };
  glVertexPointer(2, GL_FIXED, 0, pee);
//    glColor4f(1,0,1,1);
  glDrawArrays(GL_TRIANGLES, 0, 6);

  glEnable(GL_TEXTURE_2D);
  static int squareVerts[12] = {
0,0,
fX(1),0,
0,fX(1),

0,fX(1),
fX(1),0,
fX(1),fX(1)
  };

  static int texCoords[12] = {
0,0,
fX(1),0,
0,fX(1),

0,fX(1),
fX(1),0,
fX(1),fX(1)
  };

  //glTranslatef( (float)-.25, (float)-.5, (float)0);

 // glColor4f(0,0,0,0);
//  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glActiveTexture( GL_TEXTURE0 );
//  glBindTexture(GL_TEXTURE_2D, texID);
  glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
  glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
  glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
  glVertexPointer(2, GL_FIXED, 0, squareVerts);

  glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
 // glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glEnable( GL_TEXTURE_2D );
  glDrawArrays(GL_TRIANGLES, 0, 6);

//    glDisableClientState(GL_VERTEX_ARRAY);
//    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

I deliberately left some of the commented out things to show the other things I have tried doing.
I am totally at a dead end with this right now. If anyone has any suggestions or anything it would make me super happy, and that is good.

  • 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-13T18:36:48+00:00Added an answer on June 13, 2026 at 6:36 pm

    Seems like you messed up your texture coordinates.. They should be between 0 and 1, not between 0 and 1<<16. Another thing is your “glColor4f” will also affect your texture by modulating it and for normal texture draw it needs to be set to (1,1,1,1).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.