1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, g_textureID_0 );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
//
// Texture Stage 1
//
// Perform a linear interpolation between the output of stage 0
// (i.e texture0) and texture1 and use the RGB portion of the vertex's
// color to mix the two.
//
glActiveTextureARB(GL_TEXTURE1_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, g_textureID_1 );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR );
//
// Texture Stage 2
//
// Perform a linear interpolation between the output of stage 1
// (i.e texture0 mixed with texture1) and texture2 and use the ALPHA
// portion of the vertex's color to mix the two.
//
glActiveTextureARB( GL_TEXTURE2_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, g_textureID_2 );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA );
g_fContributionOfTex1 := 1.0 - (g_fContributionOfTex0 + g_fContributionOfTex2);
// Do some bounds checking...
if g_fContributionOfTex1 < 0.0 then
g_fContributionOfTex1 := 0.0;
if g_fContributionOfTex1 > 1.0 then
g_fContributionOfTex1 := 1.0;
//
// Now, lets encode the blending information into the vertex color.
// The value set into the RGB part of the color controls the blending
// between texture 0 and texture 1, and the alpha part of the color
// controls the blending between textures1 and textures 2.
//
// Note: We use the contribution of texture 0 and 2 to infer or deduce
// the contribution of texture 1. We can do this because we know that the
// total contribution of our three textures must add up to 1.0f.
//
rgbValue := g_fContributionOfTex0 / (1.0 - g_fContributionOfTex2);
alphaValue := 1.0 - g_fContributionOfTex2;
// Do some bounds checking...
if rgbValue < 0.0 then
rgbValue := 0.0;
if rgbValue > 1.0 then
rgbValue := 1.0;
if alphaValue < 0.0 then
alphaValue := 0.0;
if alphaValue > 1.0 then
alphaValue := 1.0;
glColor4f( rgbValue, rgbValue, rgbValue, alphaValue );
glBegin(GL_QUADS);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0, 0.0 );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0, 0.0);
glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 0.0, 0.0 );
glVertex3i(x,y,z);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0, 1.0 );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0, 1.0 );
glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 0.0, 1.0 );
glVertex3i(x1, x2, x3);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0, 1.0 );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0, 1.0 );
glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 1.0, 1.0 );
glVertex3i(x11, x12, x13);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0, 0.0 );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0, 0.0 );
glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 1.0, 0.0 );
glVertex3i(x21, x22, x23);
glEnd;
Inc(arrayY,STEP_SIZE);
end;
arrayY := 0;
Inc(arrayX,STEP_SIZE);
end; |
Partager