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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:31:31+00:00 2026-06-17T09:31:31+00:00

Recently my textures went crazy. Last 2 textures that I tried to map appeared

  • 0

Recently my textures went crazy. Last 2 textures that I tried to map appeared as in the picture below. I want it to appear as in the first picture but no matter what I did, it insists on appearing like in the latter one. Ignore the text please, it has nothing to do with texture.

enter image description here
enter image description here

I am using GLUT for my openGL windowing, and GLM obj loader’s tga reader. I used the reader many times before and there was no problem. It just stopped working for my last two attempts to load texture. The related code is below:

Texture onScreenTexture;


if (LoadTGA(&onScreenTexture, "back.tga")) 
    { 
        glGenTextures(1, &onScreenTexture.texID);
        glBindTexture(GL_TEXTURE_2D, onScreenTexture.texID);
        glTexImage2D(GL_TEXTURE_2D, 0, onScreenTexture.bpp / 8, onScreenTexture.width, onScreenTexture.height, 0, onScreenTexture.type, GL_UNSIGNED_BYTE, onScreenTexture.imageData);

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

        if (onScreenTexture.imageData) 
        {
            free(onScreenTexture.imageData);
        }
    }

glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, onScreenTexture.texID);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

    glBegin(GL_QUADS);
        glTexCoord2f(0,0); glVertex2f(10.0, 10.0);
        glTexCoord2f(0,1); glVertex2f(260, 10.0);
        glTexCoord2f(1,1); glVertex2f(260, 110);
        glTexCoord2f(1,0); glVertex2f(10.0, 110);
    glEnd();
    glDisable(GL_TEXTURE_2D);
  • 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-17T09:31:32+00:00Added an answer on June 17, 2026 at 9:31 am

    This is nothing to do with the ratio of width/height (though you do seem to be rendering it 90 degrees rotated, causing some additional stretching), but with the packing of rows of pixels. This is apparent from the diagonal pattern, indicating an progressive alignment issue, and also the coloured stripes, showing that the RGB data is unaligned differently on each line.

    In your case, you’re loading a TGA, which has no row-padding, but passing it to GL which by default expects rows of pixels to be padded to a multiple of 4 bytes.

    Your working textures probably are either 32-bit rather than 24-bit or are a multiple of 4 pixels wide, either of which gives a natural alignment.

    Possible fixes for this are:

    • Change the dimensions of your texture, such that there will be no padding.
    • Change the loading of your texture, such that the padding is consistent with what GL expects
    • Tell GL how your texture is packed, using (for example) glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been experimenting with three.js recently, but I've hit a show stopper that occurs
Recently one of our app servers went down, when it was rebooted the Python
Recently, I was writing a class in which I discovered that I could reduce
Recently I bumped into a problem where my OpenGL program would not render textures
recently I created a java class Custom Layout Manager , which I want to
I've recently been learning wxWidgets (version 2.9.4) and have been having trouble getting textures
I recently tried adding parallax occlusion mapping to my landscape renderer and it looks
This is my first post, and I've only recently started programming for Android and
I understand that this question may seem somewhat ungrounded, but if someone knows anything
My cocos2d-iphone project has tiled maps (.tmx files along with .png textures). Recently, I

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.