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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:43:01+00:00 2026-06-07T17:43:01+00:00

SDL_LoadBMP loads the bitmap upside down and mirrored in OpenGL. What may be the

  • 0

SDL_LoadBMP loads the bitmap upside down and mirrored in OpenGL. What may be the problem ?

unsigned int loadTexture (const char * fileName)
{
    unsigned int texId;
    GLenum format;
    GLint colorCount;

    SDL_Surface * image = SDL_LoadBMP (fileName);

    colorCount = image->format->BytesPerPixel;
    if (colorCount == 4)
    {
         if (image->format->Rmask == 0x000000ff)
             format = GL_RGBA;
         else
             format = GL_BGRA;
    }
    else if (colorCount == 3)
    {
         if (image->format->Rmask == 0x000000ff)
             format = GL_RGB;
         else
             format = GL_BGR;
    }

    glGenTextures(1, &texId);
    glBindTexture(GL_TEXTURE_2D, texId);

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

    glTexImage2D(GL_TEXTURE_2D, 0, colorCount, image->w, image->h, 0, format, GL_UNSIGNED_BYTE, image->pixels);

    SDL_FreeSurface(image);
    return texId;
}

..This is how i draw a test quad..

glBegin(GL_QUADS);
    glTexCoord2i(0, 0); glVertex3f(-1.0, -1.0, 0.0);
    glTexCoord2i(1, 0); glVertex3f( 1.0, -1.0, 0.0);
    glTexCoord2i(1, 1); glVertex3f( 1.0,  1.0, 0.0);
    glTexCoord2i(0, 1); glVertex3f(-1.0,  1.0, 0.0);
glEnd();
  • 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-07T17:43:04+00:00Added an answer on June 7, 2026 at 5:43 pm

    OpenGL always assumes the origin of the texture image to be in the “lower left”.

    Strictly speaking, OpenGL assumes the data of the texture to start at the origin, and to progress with increasing texture coordinates. So if you draw a texture with projected texture coordinates to the right and up, the image origin will be in the lower left.

    There’s no way to change this behaviour on the OpenGL side, so you must take the proper adjustments on the loaded image data, or use some shader trickery to flip the directions there. Most image loading libraries however allow you to select the point of origin you expect, so I’d set this to lower left. The library then juggles around the data internally.

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

Sidebar

Related Questions

Here is the SDL program: #include <SDL/SDL.h> int main(int argc, char** argv){ SDL_Init(SDL_INIT_VIDEO); SDL_Surface*
I am using SDL for an OpenGL application, running on Linux. My problem is
This is an SDL problem, however I have the strong feeling that the problem
this is a code example from lazyfoo's SDL tutorials. SDL_Surface *load_image( std::string filename )
I'm making a game in SDL, and assigning objects with a bitmap, i wanted
SDL_Event is a union of an unsigned 8 bit type, and many structs whose
I have been using SDL with success to learn OpenGL, however I am following
I downloaded SDL 1.3 and tested it together with OpenGL ES on my android
I use SDL for my programs graphics and I have a problem with it
I'm working with SDL and OpenGL, creating a fairly simple application. I created a

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.