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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:33:52+00:00 2026-05-23T21:33:52+00:00

I’m using QImage to load images which then used as textures in OpenGL. The

  • 0

I’m using QImage to load images which then used as textures in OpenGL.
The problem is that color components have different order in QImage and OpenGL.
Currently I’m using GL_RGBA format in OpenGL and QImage::Format_ARGB32 in Qt.
Because of that, I have to manually swap bytes for each pixel of loaded image, before creating a texture in OpenGL. Moreover, to swap bytes correctly I need to know endianness of a machine.

Does anyone know a better solution for this? At least, is there any way to make this conversion endianness-independent?

Thanks.

  • 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-23T21:33:52+00:00Added an answer on May 23, 2026 at 9:33 pm

    The last three parameters to glTex(Sub)Image define how the pixel transfer to OpenGL takes place. If you have 4 8-bit values, sequentially, in the ARGB order, then I would suggest the following:

    glTexImage2D(..., GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, *);
    

    To deal with endian conversion issues, use glPixelStore parameters. Specifically, GL_UNPACK_SWAP_BYTES. The above is designed for little-endian machines, so if you’re on a big-endian machine you should call glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE); before calling this function, and then set it back to GL_FALSE afterwards.


    Note: I know you didn’t mention it, but in case you’re considering mobile platforms, remember that OpenGL ES is not OpenGL. Desktop OpenGL requires implementations to be able to handle a wide variety of pixel arrangements in transfer operations. GL ES mandates almost the opposite. The pixel transfer formats must exactly match the internal format of the texture. So if you were doing GL ES development, you would have to do the byte swapping on your own.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have an array which has BIG numbers and small numbers in it. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.