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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:32:33+00:00 2026-06-06T14:32:33+00:00

I have a strange problem with opengl es(Android) .Some textures doesn’t drawing correct ,its

  • 0

I have a strange problem with opengl es(Android) .Some textures doesn’t drawing correct ,its like the texture cordinates are changed , but other textures are rendering normal .For example i have this :
enter image description here

i get this:

enter image description here

(the resume and the circle are other textures that drawning fine with the same texture coordinates /vertices)

I load the textures like this:

 GLuint texture;
  glGenTextures(1, &texture);
  glBindTexture(GL_TEXTURE_2D, texture);

  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_MODULATE);

  if(alpha)glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) image_data);
  else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) image_data);

and rendering like this:

//int to fixed point
#define iX(x) (x<<16)
//float ti fixed point
#define fX(x) ((int)(x * (1  << 16)))

int square[12] = {
    fX(-0.5), fX(-0.5), 0,
    fX(0.5), fX(-0.5), 0,
    fX(-0.5), fX(0.5), 0,
    fX(0.5), fX(0.5), 0
};

int texCoords[8] = {
    fX(0), fX(0),
    fX(1), fX(0),
    fX(0),fX(1),
    fX(1),fX(1)
};

void Render(int type)
{

    if(type==RENDER_2D)gltviewOrtho();

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D, id);
    glVertexPointer(3, GL_FIXED, 0, square);
    glTexCoordPointer(2, GL_FIXED, 0, texCoords);
    /////////////////////////////////////////////////////
    glPushMatrix();

    if(align==ALIGN_CENTER)glTranslatef(x,y,z);

    if(align==ALIGN_LEFT)glTranslatef(x-scalex/2,y,z);
    if(align==ALIGN_LEFT+ALIGN_TOP)glTranslatef(x-scalex/2,y+scaley/2,z);
    if(align==ALIGN_LEFT+ALIGN_BOTTOM)glTranslatef(x-scalex/2,y-scaley/2,z);

    if(align==ALIGN_RIGHT)glTranslatef(x+scalex/2,y,z);
    if(align==ALIGN_RIGHT+ALIGN_TOP)glTranslatef(x+scalex/2,y+scaley/2,z);
    if(align==ALIGN_RIGHT+ALIGN_BOTTOM)glTranslatef(x+scalex/2,y-scaley/2,z);

    if(align==ALIGN_BOTTOM)glTranslatef(x,y-scaley/2,z);
    if(align==ALIGN_TOP)glTranslatef(x,y+scaley/2,z);

    glScalef(scalex,scaley,0);
    glColor4f(r,g,b,a);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glPopMatrix();
    ////////////////////////////////////////////////////
    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);

    if(type==RENDER_2D)gltviewPerspective();


}
  • 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-06T14:32:34+00:00Added an answer on June 6, 2026 at 2:32 pm

    The pixel unpack alignment while uploading textures is 4: this mean that each texture line shall start with a byte-alignment of 4.

    If your data is tighly packed, using a 250 pixel-wide RGB bitmap requires a 2 byte alignment: infact each bitmap line is defined by 750 bytes, that are not multiple of 4.

    Essentially, the texture uploader ignore 2 bytes at each line, because it thinks that the bitmap line is long 752 bytes.

    To resolve your issue, set the pixel alignment before uploading texture:

        glPixelStorei(GL_UNPACK_ALIGNMENT, 2)
    

    Don’t waste memory if you are able to use NPOT textures.

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

Sidebar

Related Questions

I have a strange problem with some documents on my webpage. My data is
I have got a very, very strange problem in my C++ OpenGL application. I
I have a strange problem using a MapView in Android. It works fine until
I have a strange problem regarding suggestion items for an AutocompleteView on Android 2.2.
I have a strange problem. I have a jQuery document.ready function executing some script
I have strange problem with XUL layouts. My current code: <xul:vbox> <xul:hbox> .. some
I have strange problem when using at() method of std::string. I'd like to calculate
I have some strange problem. I have a solution with the following structure http://i33.tinypic.com/10fbzbq.jpg
i have strange problem doing reporting: i have numerous clients with different issued invoices.
I have strange problem with receiving data from socket. On client im using air

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.