PDA

View Full Version : glGetActiveUniformARB and sampler2DRect (nvidia)



grisha
11-23-2004, 11:59 PM
glGetActiveUniformARB returns incorrect type for sampler2DRect uniforms - instead of SAMPLER_2D_RECT_ARB I get GL_TEXTURE_RECTANGLE_ARB.

nvidia, driver version: 67.02

here is test program to demonstrate this:

#include <iostream>
#include <GL/glut.h>
#include <GL/glext.h>

PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = 0;
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = 0;
PFNGLSHADERSOURCEARBPROC glShaderSourceARB = 0;
PFNGLCOMPILESHADERARBPROC glCompileShaderARB = 0;
PFNGLGETACTIVEATTRIBARBPROC glGetActiveUniformARB = 0;
PFNGLATTACHOBJECTARBPROC glAttachObjectARB = 0;
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = 0;
PFNGLLINKPROGRAMARBPROC glLinkProgramARB = 0;

const GLcharARB * shaderSrc =
"uniform sampler2DRect tex;\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2DRect( tex, gl_TexCoord[0].xy );\n"
"}\n";

int main( int argc, char * argv[] )
{
glutInit( &amp;argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB );
glutCreateWindow( "test" );

glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)wglGetProcAddress ( "glCreateProgramObjectARB" );
glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress( "glCreateShaderObjectARB" );
glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress( "glShaderSourceARB" );
glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress( "glCompileShaderARB" );
glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)wglGetProcAddress( "glAttachObjectARB" );
glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress( "glDeleteObjectARB" );
glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)wglGetProcAddress( "glLinkProgramARB" );
glGetActiveUniformARB = (PFNGLGETACTIVEATTRIBARBPROC)wglGetProcAddress( "glGetActiveUniformARB" );

GLhandleARB po = glCreateProgramObjectARB();
GLhandleARB so = glCreateShaderObjectARB( GL_FRAGMENT_SHADER_ARB );
glShaderSourceARB( so, 1, &amp;shaderSrc, 0 );
glCompileShaderARB( so );
glAttachObjectARB( po, so );
glDeleteObjectARB( so );
glLinkProgramARB( po );

GLsizei length;
GLint size;
GLenum type;
GLcharARB name[256];
glGetActiveUniformARB( po, 0, sizeof(name), &amp;length, &amp;size, &amp;type, name );

if( type == GL_TEXTURE_RECTANGLE_ARB )
std::cout << "type == GL_TEXTURE_RECTANGLE_ARB\n";

return 0;
}

Relic
11-24-2004, 01:15 AM
You're funny. Returning GL_SAMPLER_2D_RECT_ARB isn't possible because it doesn't exist, yet, because sampler2DRect is reserved for future use.
Returning GL_TEXTURE_RECTANGLE seems just a placeholder until GLSL specs rectangle textures.

grisha
11-24-2004, 01:51 AM
Originally posted by Relic:
Returning GL_SAMPLER_2D_RECT_ARB isn't possible because it doesn't exist.GL_SAMPLER_2D_RECT_ARB exists, from ARB_shader_objects spec (http://oss.sgi.com/projects/ogl-sample/registry/ARB/shader_objects.txt):


Returned by the <type> parameter of GetActiveUniformARB:
...
SAMPLER_2D_RECT_ARB 0x8B63
...

Relic
11-24-2004, 02:40 AM
Hehe, thanks, that teaches me to not only look into the GL 2.0 spec.

jra101
11-24-2004, 09:47 AM
A fix for this will be available in a future NVIDIA driver update.