a problem about single and multi texture mapping

Hi, all,
I wrote 2 sub-functions to do single and multi texture mapping(with NV register combiner) individually. But I found if I go through multi stage and then turn back to render single stage, it doesn’t work any more. It seems in multi stage some states have been set up which influence the single stage. But I tried disabling registercombiner, it still doesn’t work.
So if anybody met such problems, plz help me. Thanks a lot.

Do you disable all texture units you don’t need anymore?

I read some old posts, it seems impossible to disable multi-texture after activating it, anyway, some one did show another way out.

It is entirely possible to disable multi-texturing after enabling it. You can change the number of combiners you’re using. You can also do glActiveTexture(GL_TEXTUREi) and glDisable(GL_TEXTURE_2D) to avoid fetches.

This’s my code write in Delphi 5
First SetPixelFormat is OK but mode isnt antialias
but second SetPixelFormat not return mode …
what i should do… ?
(3D Antialias Setting is allow application …)

 DC := GetDC(Handle);
 ZeroMemory(@PixelFormat, Sizeof(PixelFormat));
 PixelFormat.nSize := Sizeof(PixelFormat);
 PixelFormat.nVersion := 1;
 PixelFormat.dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
 PixelFormat.iPixelType := PFD_TYPE_RGBA;
 PixelFormat.cColorBits := 32;
 PixelFormat.cDepthBits := 16;
 PixelFormat.cStencilBits := 16;
 PixelFormat.iLayerType := PFD_OVERLAY_PLANE;


 DefPxlFmt := Windows.ChoosePixelFormat(DC, @PixelFormat);

 If SetPixelFormat(DC, DefPxlFmt, nil) then
    Begin
       GLRC := wglCreateContext(PxLstDC);
       wglMakeCurrent(PxLstDC, GLRC);
       wglGetExtensionsStringARB := wglGetProcAddress('wglGetExtensionsStringARB');

       wglChoosePixelFormatARB := wglGetProcAddress('wglChoosePixelFormatARB');
       glSampleCoverageARB := wglGetProcAddress('glSampleCoverageARB');

       wglMakeCurrent(0, 0);
       wglDeleteContext(GLRC);
 { Enable All Feature including MultiSample }
 If @wglChoosePixelFormatARB <> nil then
    Begin
       wglMakeCurrent(0, 0);
       wglDeleteContext(GLRC);

       FormatCnt := 0;
       ZeroMemory(@IAttrib, Sizeof(IAttrib));
       ZeroMemory(@FAttrib, Sizeof(FAttrib));
       IAttrib[FormatCnt].Format := WGL_DRAW_TO_WINDOW_ARB; IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_SUPPORT_OPENGL_ARB; IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_ACCELERATION_ARB;   IAttrib[FormatCnt].Data := WGL_FULL_ACCELERATION_ARB;  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_DOUBLE_BUFFER_ARB;  IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_COLOR_BITS_ARB;     IAttrib[FormatCnt].Data := ColorBits;                  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_ALPHA_BITS_ARB;     IAttrib[FormatCnt].Data := AlphaBits;                  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_DEPTH_BITS_ARB;     IAttrib[FormatCnt].Data := DepthBits;                  Inc(FormatCnt);
       IAttrib[FormatCnt].Format := WGL_STENCIL_BITS_ARB;   IAttrib[FormatCnt].Data := StencilBits;                Inc(FormatCnt);
       If MultiSamples > 0 then
          Begin
             IAttrib[FormatCnt].Format := WGL_SAMPLE_BUFFERS_ARB; IAttrib[FormatCnt].Data := GL_TRUE;                    Inc(FormatCnt);
             IAttrib[FormatCnt].Format := WGL_SAMPLES_ARB;        IAttrib[FormatCnt].Data := MultiSamples;               Inc(FormatCnt);
          end;
       IAttrib[FormatCnt].Format := 0;                      IAttrib[FormatCnt].Data := 0;                          Inc(FormatCnt);

       wglChoosePixelFormatARB(DC, @IAttrib, @FAttrib, 1, @PixelFormatType, @FormatCnt);

       If SetPixelFormat(DC, PixelFormatType, nil) then
          Begin
             GLRC := wglCreateContext(DC);
             wglMakeCurrent(DC, GLRC);
             ......

Originally posted by jwatte:
It is entirely possible to disable multi-texturing after enabling it. You can change the number of combiners you’re using. You can also do glActiveTexture(GL_TEXTUREi) and glDisable(GL_TEXTURE_2D) to avoid fetches.

also dont forget to switch to another textur stage afterwards
eg
glActiveTexture( GL_TEXTURE1 );
glDisable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE0 ); <- dont forget cause its still stuck at texunit 1

Zed,

What do you mean “still stuck at” texture stage 1? ActiveTexture tells OpenGL which texture unit you’re talking about. If you have nothing more to say, then it doesn’t matter which texture unit is the “active” one. It doesn’t change rendering at all.

Perhaps what you meant was a reminder: if you want to talk about some other texture unit later, you’ll have to make that the active texture unit when you want to give it commands.

sorry i do have trouble with english

heres an example
glActiveTexture( GL_TEXTURE1 );
glDisable( GL_TEXTURE_2D );


glBindTexture( GL_TEXTURE_2D, house_texture)
draw a polygon
this polygon wont show up with the texture cause textureunit1 is still active. i know its logical but ppl (including myself) had problems understanding this at first

i use the following code in my game for binding textures (ie i dont worry about enabling/disabling them)

// passing 0 is texID will disable the texture unit
void GLstate::bindTexture( const int num, const GLuint texID )
{
if ( texID ) // we want a texture bound
{
if ( current_TU[ num ].use_textureID == texID )
return; // already set so return
set_current_active_texture_unit( num );
if ( current_TU[ num ].use_textureID == 0 ) // if the unit was previously disabled we need to enable it
{
glEnable( GL_TEXTURE_2D );
CALL_glEnableTexture2D++;
}
glBindTexture( GL_TEXTURE_2D, texID );
CALL_glBindTexture++;
current_TU[ num ].use_textureID = texID;
}
else // we want this texture unit disabled
{
if ( current_TU[num].use_textureID ) // the unit is currently enabled
{
set_current_active_texture_unit( num );
glDisable( GL_TEXTURE_2D );
CALL_glDisableTexture2D++;
current_TU[num].use_textureID = texID;
}
}
}