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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:28:44+00:00 2026-05-23T13:28:44+00:00

Texturing headache… I can’t understand where i go wrong here. My problem is that

  • 0

Texturing headache…

I can’t understand where i go wrong here. My problem is that the texture is not aligned. The image on the left is the OpenGl textured quad, and the right is the original. Notice how the columns are offset in the textured quad.

Mis-aligned texture

I don’t know if i am not loading the texture properly, or make a mistake during uploading it to videomemory, or simply use the wrong texCoords…

The image is a bmp (R8 G8 B8 A8) and the mistake lies somewhere in here:

(Loading of bitmap and uploading of texture)

        Bitmap fontBmp = new Bitmap("font2.bmp");
        MemoryStream ms = new MemoryStream();

        fontBmp.Save(ms, ImageFormat.Bmp);
        int imageWidth = fontBmp.Width;
        int imageHeight = fontBmp.Height;
        byte[] fontBytes = ms.GetBuffer();
        fontBmp.Dispose();
        ms.Dispose();

        Gl.glBindTexture(Gl.GL_TEXTURE_2D, (int)TexId.font);
        Gl.glPixelStorei(Gl.GL_UNPACK_ALIGNMENT, 1);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);
        Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE); // Try GL_DECAL...
        Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, imageWidth, imageHeight, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, fontBytes);

(The quad…)

        Gl.glTexCoord2f(0f + (0.5f / 128f), (127f / 128f) + (0.5f / 128f));
        Gl.glVertex2i(50, 50);

        Gl.glTexCoord2f(0f + (0.5f / 128f), 0f + (0.5f / 128f)); 
        Gl.glVertex2i(50, this.Height - 50);

        Gl.glTexCoord2f((127f / 128f) + (0.5f / 128f), 0f + (0.5f / 128f)); 
        Gl.glVertex2i(this.Width - 50, this.Height - 50);

        Gl.glTexCoord2f((127f / 128f) + (0.5f / 128f), (127f / 128f) + (0.5f / 128f)); 
        Gl.glVertex2i(this.Width - 50, 50);

Does anyone spot anything causing this?

  • 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-23T13:28:45+00:00Added an answer on May 23, 2026 at 1:28 pm

    The problem is NOT your texture coordinates.

    The problem is that you’re loading the texture wrong. You’re forgetting to remove the bitmap header, so all the real data is shifted over, and the end of each line is shifted onto the beginning of the next line.

    Texture wrapping would wrap pixels from the right back onto the same line, but the out-of-place region is shifted down one row. Texture wrapping also wouldn’t occur with the “clamp to edge” mode you’ve enabled.

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

Sidebar

Related Questions

I have a problem with texturing – it loads the image correctly, but renders
I am drawing one object using multi-texturing. That comes fine but when I draw
Hy I have a little problem in openGL-ES texturing. I created a modell in
I have a an odd problem with some texturing in opengl: This scene is
Simple task: draw a fullscreen quad with texture, nothing more, so we can be
I have an OSG application that I want to texture map a full screen
Hey guys can anybody help me with texture mapping in Direct3D C++. I have
I'm having a problem with my shader loading code. The bizarre thing that's confusing
I am helping re-code a website that allows teachers to text message/email their students
I have a CoreData NSManagedObject subclass, TextNarration, that has an attribute of type NSString,

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.