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
|
GLvoid LoadMenu()
{
AUX_RGBImageRec * textureMenu[2];
textureMenu[0] = auxDIBImageLoad("menu.bmp");
textureMenu[1] = auxDIBImageLoad("menuMask.bmp");
for (int i=0; i<2; i++)
{
glBindTexture(GL_TEXTURE_2D, menu[i]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, textureMenu[i]->sizeX, textureMenu[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, textureMenu[i]->data);
}
for (i=0; i<2; i++)
{
free(textureMenu[i]->data);
free(textureMenu[i]);
}
}
...
GLvoid displayMenu()
{
glBeginOrtho();
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND); // Enable Blending
glDisable(GL_DEPTH_TEST); // Disable Depth Testing
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glBindTexture(GL_TEXTURE_2D, menu[1]); // Select The Second Mask Texture
glBegin(GL_QUADS); // Start Drawing A Textured Quad
glTexCoord2i(0, 0); glVertex2i(0, 0); // Top Left
glTexCoord2i(640, 0); glVertex2i(640, 0); // Top Right
glTexCoord2i(640, 360); glVertex2i(640, 360); // Bottom Right
glTexCoord2i(0, 360); glVertex2i(0, 360); // Bottom Left
glEnd(); // Done Drawing The Quad
}
glBlendFunc(GL_ONE, GL_ONE); // Copy Image 2 Color To The Screen
glBindTexture(GL_TEXTURE_2D, menu[0]); // Select The Second Image Texture
glBegin(GL_QUADS); // Start Drawing A Textured Quad
glTexCoord2i(0, 0); glVertex2i(0, 0); // Top Left
glTexCoord2i(640, 0); glVertex2i( 640, 0); // Top Right
glTexCoord2i(640, 360); glVertex2i( 640, 360); // Bottom Right
glTexCoord2i(0, 360); glVertex2i(0, 360); // Bottom Left
glEnd();
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
glDisable(GL_BLEND); // Disable Blending
glDisable(GL_TEXTURE_2D);
glEndOrtho();
} |
Partager