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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:52:07+00:00 2026-06-13T08:52:07+00:00

Look at the following OpenGL function: void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei

  • 0

Look at the following OpenGL function:

void glTexImage2D(GLenum    target,
                  GLint     level,
                  GLint     internalFormat,
                  GLsizei   width,
                  GLsizei   height,
                  GLint     border,
                  GLenum    format,
                  GLenum    type,
                  const GLvoid * data);

I know the parameter format and type describe the format and type of the image data,but I don’t understand the prameter internalFormat.How should I set its value in my application?

For example,I create a texture like this:

glTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE8,size,size,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,buffer);

When I aceess the texture in it in my GLSL shader,it seems that the value that I get is between [0,1].WHy?Shouldn’t it between [0,255]?

Part of My shader code is :

vec = EntryPoint + delta_dir * texture(noiseTex,EntryPoint.xy * 32).x;

Part of my C++ Code :

for (int i = 0;i < temp;++i)
    {
        buffer[i] = 255.0 * rand() / (float)RAND_MAX;
    }
    glGenTextures(1,&noiseTex);
    glActiveTexture(GL_TEXTURE0 + activeTexUnit);
    glBindTexture(GL_TEXTURE_2D,noiseTex);
    glTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE8,size,size,
                            0,GL_LUMINANCE,GL_UNSIGNED_BYTE,buffer);
    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_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  • 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-13T08:52:08+00:00Added an answer on June 13, 2026 at 8:52 am

    The format and type parameters describe the data you are passing to OpenGL as part of a pixel transfer operation. The internalformat describes the format of the texture. You’re telling OpenGL that you’re giving it takes that looks like X, and OpenGL is to store it in a texture where the data is Y. The internalformat is “Y”.

    The GL_LUMINANCE8 internal format represents a normalized unsigned integer format. This means that the data is conceptually floating-point, but stored in a normalized integer form as a means of compression.

    For that matter, the format of GL_LUMINANCE says that you’re passing either floating-point data or normalized integer data (the type says that it’s normalized integer data). Of course, since there’s no GL_LUMINANCE_INTEGER (which is how you say that you’re passing integer data, to be used with integer internal formats), you can’t really use luminance data like this.

    Use GL_RED_INTEGER for the format and GL_R8UI for the internal format if you really want 8-bit unsigned integers in your texture. Note that integer texture support requires OpenGL 3.x-class hardware.

    That being said, you cannot use sampler2D with an integer texture. If you are using a texture that uses an unsigned integer texture format, you must use usampler2D.

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

Sidebar

Related Questions

Pls look at following code <select name=VideoType id=VideoType style=width:60px> <option value=All>All</option> <option value=Movie>Movie</option> <option
I have the following macro: #define IF_TRACE_ENABLED(level) if (IsTraceEnabled(level)) The user code should look
Have a look at following code: @Local public interface MyService { void printMessage(); }
The finfo function is returning crazy mime types. Look the following code, what is
Please look the following query: SELECT ID, START, END FROM TABLEA the result is:
Have a look at following scenario: public class ParentClass { private Integer testVar =
I have HttpClient 4.1. Please have a look at following program: import org.apache.http.client.methods.*; import
I am doing image Read/Copy operations in WPF application. Please look at following piece
I have some difficulties with understanding BindingSource's behaviour. Let's look at following example: Creating
Look at the following picture, which is showing a smart tag for DataGridView. DataGridView

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.