Results 1 to 5 of 5

Thread: texture bit depth query

  1. #1
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    texture bit depth query

    Am I just being an idiot, or why do I get zero?

    Code :
    	glGenTextures(1,&tex0);
    	glBindTexture(GL_TEXTURE_2D,tex0);
    	glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,shtuff);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
     
    	GLint red_bits=0,green_bits=0,blue_bits=0,alpha_bits=0;
     
    	glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_RED_SIZE,&red_bits);
    	glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_GREEN_SIZE,&green_bits);
    	glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_BLUE_SIZE,&blue_bits);
    	glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_ALPHA_SIZE,?_bits);
     
    [B]	tex0_size=((red_bits+green_bits+blue_bits+alpha_bits)*256*256)>>3;[/B]
    (R300, Cat3.6)


    Oh yeah, I should add that the texture renders as expected. That has never been a problem.

    [This message has been edited by zeckensack (edited 07-20-2003).]

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: texture bit depth query

    Reading through the spec quickly, I can't see GL_TEXTURE_*_SIZE as a valid parameter to glGetTexParameter. And when I try your code, glGetError returns GL_INVALID_ENUM after the first glGetTexParameter.

    And you get zero because you initialize your variables to zero, and glGetTexParameter does not modify them because of the error. Change them and you will get another result

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: texture bit depth query

    Thanks Bob

    Oh joy ... I've found it.

    In case anyone's interested in the solution, it's

    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_RED_SIZE,&r ed_bits);

    Seems somewhat illogical to me. Can a texture have different internal formats per mipmap level? I don't think so ...

    Ho hum.

    [This message has been edited by zeckensack (edited 07-20-2003).]

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: texture bit depth query

    Well, since you must upload each mipmap level separately, then maybe you CAN specify different internal formats for each level. If so, then it makes sense to use glGetTexLevelParameter. Just tried and it reported no errors at least (tried it in a debugger only, no visual tests to see if it actually renders correct, I do that when I got more time).

    Gee, you really do learn something every day, even basic stuff when you've known OpenGL for several years.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    340

    Re: texture bit depth query

    OpenGL 1.4 spec, section 3.8.10 : Texture completeness
    A texture is said to be complete if all the image arrays and texture parameters required to utilize the texture for texture application is consistently defined. The definition of completeness varies depending on the texture dimensionality.
    For one-, two-, or three-dimensional textures, a texture is complete if the following conditions all hold true:
    The set of mipmap arrays levelbase through q (where q is defined in the
    Mipmapping discussion of section 3.8. were each specified with the same internal format.

    (...)
    Effects of Completeness on Texture Application
    If one-, two-, or three-dimensional texturing (but not cube map texturing) is enabled for a texture unit at the time a primitive is rasterized, if TEXTURE MIN FILTER is one that requires a mipmap, and if the texture image bound to the enabled texture target is not complete, then it is as if texture mapping were disabled for that texture unit.

Similar Threads

  1. Replies: 2
    Last Post: 01-04-2016, 04:31 AM
  2. Replies: 1
    Last Post: 11-25-2015, 04:22 AM
  3. FBO render depth to texture, cause depth texture to equal diffuse.
    By RobertBerg in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 04-05-2015, 06:48 AM
  4. Occlusion query with depth disabled pass
    By _NK47 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-08-2009, 09:56 AM
  5. Query texture memory
    By OpenGHell in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-31-2003, 01:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean