The ARB_multitexture extension

parakeetincurableΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 4 μήνες)

83 εμφανίσεις

1

The ARB_multitexture extension

Michael I. Gold

NVIDIA Corporation

2

Multitexture Applications

Apply multiple textures in a single pass


Lightmaps


Fog


Caustics


Bump mapping

3

OpenGL Texture Application

Incoming

Fragment

Color

Resulting

Color

Texture

Color

Texture
Environment

4

Multi
-
Texture Application

Incoming

Fragment

Color

Resulting

Color

Texture 0

Color

Texture 0
Environment

Texture 1
Environment

Texture 1

Color

5

glActiveTextureARB

glActiveTextureARB(texture);


texture

is
GL_TEXTURE
n
_ARB


GL_TEXTURE
n
_ARB ==
GL_TEXTURE0_ARB+
n


n = 0 .. numTextureUnits
-

1, maximum 32


query number of texture units:


glGetIntegerv(GL_NUMBER_OF_TEXTURE_UNITS_ARB,





&numTextureUnits);

6

glActiveTextureARB (cont’d)

Active texture unit selector affects behavior of
the following:


glBindTexture


glTexImage / glTexParameter


glEnable / glDisable


glTexEnv


glTexGen


matrix operations

7

glActiveTextureARB (cont’d)

Example
-

bind and enable two textures


glActiveTextureARB(GL_TEXTURE0_ARB);

glBindTexture(GL_TEXTURE_2D, tex0);

glEnable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1_ARB);

glBindTexture(GL_TEXTURE_2D, tex1);

glEnable(GL_TEXTURE_2D);


8

glMultiTexCoord

glMultiTexCoord
2
f
v
ARB(texture, ...);







texture
is GL_TEXTURE
n
_ARB

v
:
indicates vector format, if present

data type
:

f

single precision float



d

double precision float



s

signed short integer



i

signed integer

number of components
:
2,3,4

9

glMultiTexCoord (cont’d)

Example
-

render one multitextured triangle


glBegin(GL_TRIANGLES);

glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, &t0[0]);

glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, &t1[0]);

glVertex3fv(&v[0]);

glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, &t0[1]);

glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, &t1[1]);

glVertex3fv(&v[1]);

glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, &t0[2]);

glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, &t1[2]);

glVertex3fv(&v[2]);

glEnd();

10

glClientActiveTextureARB

glClientActiveTextureARB(texture);


Client state analog to
glActiveTextureARB();


Used to set multitexture vertex array state


Client active texture unit selector affects
behavior of the following:


glTexCoordPointer


glEnableClientState


glDisableClientState

11

glClientActiveTextureARB (cont’d)

Example
-

set two texture coordinate arrays


glClientActiveTextureARB(GL_TEXTURE0_ARB);

glTexCoordPointer(2, GL_FLOAT, 0, tp0);

glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTextureARB(GL_TEXTURE1_ARB);

glTexCoordPointer(2, GL_FLOAT, 0, tp1);

glEnableClientState(GL_TEXTURE_COORD_ARRAY);


12

More Information


OpenGL 1.2.1 specification (includes
ARB_multitexture)



http://www.opengl.org/Documentation/Specs.html



Win32 multitexture sample



http://www.berkelium.com/OpenGL/examples