binding texture in NV_fragment_program

Hello!

I am writing renderer that use NV_fragment_program. but INVALID_OPERATION is occured when binding texture to unit GL_TEXTURE4_ARB. GL_MAX_TEXTURE_COORDS_NV is 8, GL_MAX_TEXTURE_IMAGE_UNITS_NV is 16,
GL_MAX_TEXTURE_UNITS_ARB is 4.
how can’t it bind textures anymore?
I have a GeforceFX 5900.
any reply will help me.

regards

You should have no problem binding textures to units 0-15 with the geforcefx. Maybe the error you are receiving is not from the bind call? You do have a valid context, don’t you?

all I did are like this:

glGenProgramsNV( 1, &handle );
glBindProgramNV( GL_FRAGMENT_PROGRAM_NV, handle );
glLoadProgramNV( GL_FRAGMENT_PROGRAM_NV, handle, strlen(fptest), fptest );

int error;

glEnable( GL_FRAGMENT_PROGRAM_NV );

glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
error = glGetError();

glActiveTextureARB( GL_TEXTURE1_ARB );
glEnable( GL_TEXTURE_2D );
error = glGetError();

glActiveTextureARB( GL_TEXTURE2_ARB );
glEnable( GL_TEXTURE_2D );
error = glGetError();

glActiveTextureARB( GL_TEXTURE3_ARB );
glEnable( GL_TEXTURE_2D );
error = glGetError();

glActiveTextureARB( GL_TEXTURE4_ARB );
glEnable( GL_TEXTURE_2D );
error = glGetError(); <= 1282: INVALID_OPERATION occured

glDisable( GL_FRAGMENT_PROGRAM_NV );

what’s the problem in above?

[This message has been edited by pangde (edited 03-12-2004).]

First off, the good thing about using fragment programs is that ALL texture units are enabled by default when(I think) you have a valid fragment program bound and GL_FRAGMENT_PROGRAM_NV is enabled.

Second, you are trying to enable a texture unit that is not available if you want use the fixed-funtion pipeline(GeforceFX has a 4 unit limit for fixed function functionality).

So basically ignore the error. Does the fragment program run as it should when sampling textures bound to unit 4-15?

as your advice, I ignored the error. I swept all glGetError during rendering frame.(before I checked error after calling swapbuffer in every frame.)

then I could use units until unit0-7.
everything seems ok now.
thank you for your advice very much.

but why result error at unit 4 to confuse developer? .

[This message has been edited by pangde (edited 03-13-2004).]

As roffe said, fragment programs don’t require you to enable texture targets. That’s only required for “legacy” stuff, such as ARB_texture_env_combine. They apparently don’t want you to use more than four texture units for this. GL_MAX_TEXTURE_UNITS_ARB is four. Go figure

I’m pretty confident that if you just remove the glEnable(GL_TEXTURE_2D) calls, everything will be fine (and there will be no GL errors).