View Full Version : a problem about single and multi texture mapping

10-09-2002, 05:53 PM
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.

10-09-2002, 10:37 PM
Do you disable all texture units you don't need anymore?

10-11-2002, 03:35 PM
I read some old posts, it seems impossible to disable multi-texture after activating it, anyway, some one did show another way out.

10-11-2002, 04:02 PM
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.

10-11-2002, 06:17 PM
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.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
GLRC := wglCreateContext(PxLstDC);
wglMakeCurrent(PxLstDC, GLRC);
wglGetExtensionsStringARB := wglGetProcAddress('wglGetExtensionsStringARB');

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

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

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
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);
IAttrib[FormatCnt].Format := 0; IAttrib[FormatCnt].Data := 0; Inc(FormatCnt);

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

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

10-12-2002, 07:44 PM
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
glActiveTexture( GL_TEXTURE1 );
glDisable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE0 ); <- dont forget cause its still stuck at texunit 1

10-13-2002, 03:31 PM

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.

10-13-2002, 09:34 PM
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 );
glBindTexture( GL_TEXTURE_2D, texID );
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 );
current_TU[num].use_textureID = texID;