HP Workstation zx2000 HP OpenGL Implementation Guide for HP-UX 11.X (IPF versi - Page 14
D texture program fragments, This program draws four layers in the base MIPmap level
View all HP Workstation zx2000 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 14 highlights
overview of OpenGL 3D texture program fragments This program draws four layers in the base MIPmap level, and a diagonal slice through the base MIPmap level. /* Allocate texture levels separately, then concat to get 3D texture */ GLubyte texture1[TEXTURE_WIDTH][TEXTURE_HEIGHT][4]; GLubyte texture2[TEXTURE_WIDTH][TEXTURE_HEIGHT][4]; GLubyte texture3[TEXTURE_WIDTH][TEXTURE_HEIGHT][4]; GLubyte texture4[TEXTURE_WIDTH][TEXTURE_HEIGHT][4]; GLubyte textureConcat[TEXTURE_DEPTH][TEXTURE_WIDTH][TEXTURE_HEIGHT][4]; /* The checkerPattern procedure fills a texture of width and height with a period of Checker_period alternating between firstColor and secondColor, Texture should be declared prior to calling checkerPattern. */ static void checkerPattern(int width, int height, GLubyte *firstColor, GLubyte *secondColor, GLubyte *texture, int Checker_period) { int int GLubyte texelX, texelY; index, fromIndex; *p = texture; index = 0; for (texelY = 0; texelY < height; texelY++) { for (texelX = 0; texelX < width; texelX++) { if (((texelX/Checker_period)% 2) ^ ((texelY/Checker_period)% 2)) { *p++ = firstColor[0]; /* red */ *p++ = firstColor[1]; /* green */ *p++ = firstColor[2]; /* blue */ *p++ = firstColor[3]; /* alpha */ } else { *p++ = secondColor[0]; /* red */ *p++ = secondColor[1]; /* green */ *p++ = secondColor[2]; /* blue */ *p++ = secondColor[3]; /* alpha */ } } } GLubyte blackRGBA[] = {0.0, 0.0, 0.0, 255.0}; GLubyte whiteRGBA[] = {255.0, 255.0, 255.0, 255.0}; GLubyte redRGBA[] = {255.0, 0.0, 0.0, 255.0}; GLubyte greenRGBA[] = {0.0, 255.0, 0.0, 255.0}; GLubyte blueRGBA[] = {0.0, 0.0, 255.0, 255.0}; GLubyte yellowRGBA[]= {255.0, 255.0, 0.0, 255.0}; 1-10 OpenGL implementation guide