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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:35:53+00:00 2026-06-18T19:35:53+00:00

I am now confused with the glDrawPixels() function. I know the function signature is

  • 0

I am now confused with the glDrawPixels() function.
I know the function signature is like:
gl.glDrawPixels(int width, int height, format, type, data);

I not not sure how to make format-type-data be consistent.
for instance, I have to use format as GL2.GL_RGB, I am asking
for type=GL2.GL_DOUBLE, GL2.GL_FLOAT, GL2.GL_BYTE, respectively,
What does data look like? how should I wrap and format my data in Java before invoke glDrawPixels() funciton.

  • 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-18T19:35:54+00:00Added an answer on June 18, 2026 at 7:35 pm

    First of all, you shouldn’t really use glDrawPixels. It’s a very slow function and in most OpenGL implementation not very optimized. You should use a textured quad instead. But your question also applies to the parameters of glTexImage2D.

    So what do these parameters mean. Let’s have a look at the signature of glTexImage2D

    C SPECIFICATION
       void glTexImage2D( GLenum target,
                          GLint level,
                          GLint internalformat,
                          GLsizei width,
                          GLsizei height,
                          GLint border,
                          GLenum format,
                          GLenum type,
                          const GLvoid *pixels )
    
    • internalformat designates the format the data will have internally in OpenGL.

    • format is the format the data in pixels has and has exactly the same meaning as the parameter of the same name in glDrawPixels. Essentially format tells OpenGL how many elements there are to a pixel of data in pixels

    • type tells OpenGL the type containing a single pixel. Now this is interesting, because its nontrivial.

    Let’s look at some combinations:

    format = GL_BGRA, type = GL_UNSIGNED_INT_8_8_8_8

    This tells OpenGL that a pixel consists of 4 elements in the order blue, green, red and alpha, and that all four elements are contained in a single unsigned integer of 32 bits, divided into 4 groups of 8 bits each. You maybe know that color notation of HTML e.g. #ffffffff for write. Well, this is essentially a 32 bit unsigned int in hexadecimal notation.

    You could have an array of 32 bit unsigned integers

    uint32_t pixels[] = {
     0xffffffff, 0x0000ffff, 0xffffffff,
     0x0000ffff, 0xffffffff, 0x0000ffff,
     0xffffffff, 0x0000ffff, 0xffffffff,
    };
    

    That would be a 3×3 sized image of a red diamond on white ground.

    format = GL_RGB, type = GL_UNSIGNED_BYTE

    In this case we tell OpenGL that there are 3 elements, red, green and blue, to a pixel and because the type has no explicit subsizes indicated, that each element of such type contains one color element of the pixel

    Our red diamond would look like this then

    uint8_t pixels[] = {
        0xff, 0xff, 0xff, /**/ 0xff, 0x00, 0x00, /**/ 0xff, 0xff, 0xff,
        0xff, 0x00, 0x00, /**/ 0xff, 0xff, 0xff, /**/ 0xff, 0x00, 0x00,
        0xff, 0xff, 0xff, /**/ 0xff, 0x00, 0x00, /**/ 0xff, 0xff, 0xff
    };
    

    format = GL_RGBA, type = GL_FLOAT (or GL_DOUBLE)

    In this case each element of a pixel is a individual float, in the range [0; 1]. The diamond would then look like

    float pixels[] = {
        0., 1., 0.,
        1., 0., 1.,
        0., 1., 0.
    };
    

    For GL_DOUBLE it looks exactly the same but with double instead of float.


    I hope you now get the basic gist

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

Sidebar

Related Questions

Pretty confused right now, while i feel i know a bit about vhosts this
I'm thoroughly confused now. Exclusively in IE7 my onclick function fails to execute. However,
I'm new to C++, and I'm now confused about the polymorphism concept and function
I am really confused now on how and which method to use to return
I am new to c# and now bit confused with Generics and Entity Framework.
Ok, I'm now very confused. After my last question had several people comment about
Ive been reading from several sources, and now Im more confused then ever. So
This is a bit confused question for those who don't now advanced SQL... However.
I have always been kind of confused by threads, and my class right now
We have been discussing this at work and now I am even more confused

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.