OpenGL path (6) texture, opengl path texture
To patch an object, the image width and height must be a power of 2.
The Code is as follows (Some compilers do not contain glaux and can be configured by Baidu search. If you have any questions, go to the QQ Group 116920287 for consultation)
# Include <gl/glut. h> # include <gl/glaux. h> # pragma comment (lib, "opengl32.lib") # pragma comment (lib, "glu32.lib") # pragma comment (lib, "glu32.lib") # pragma comment (lib, "glut. lib ") # pragma comment (lib," glaux. lib ") UINT g_bmp [1]; // texture No. GLUquadricObj * g_text; // texture pointer void Box (float x, float y, float z) // cube {glPushMatrix (); glScalef (x, y, z); GL_TEXTURE_2D); // map valid glBegin (GL_QUADS); glTexCoord2f (0.0f, 0. 0f); glVertex3f (-1.0f,-1.0f, 1.0f); // front glTexCoord2f (1.0f, 0.0f); glVertex3f (1.0f,-1.0f, 1.0f); glTexCoord2f (1.0f, 1.0f, 1.0f); glVertex3f (1.0f, 1.0f, 1.0f); glTexCoord2f (0.0f, 1.0f); glVertex3f (-1.0f, 1.0f, 1.0f); glTexCoord2f (1.0f, 0.0f ); glVertex3f (-1.0f,-1.0f,-1.0f); // post glTexCoord2f (1.0f, 1.0f); glVertex3f (-1.0f, 1.0f,-1.0f); glTexCoord2f (0.0f, 1.0f ); glVertex3f (1.0f, 1.0f,-1.0f); glTexCoord2f (0.0f, 0.0f); glVertex3f (1.0f,-1.0f,-1.0f); glTexCoord2f (0.0f, 1.0f); glVertex3f (-1.0f, 1.0f,-1.0f); // upper limit (0.0f, 0.0f); glVertex3f (-1.0f, 1.0f, 1.0f); then (1.0f, 0.0f); glVertex3f (1.0f, 1.0f, 1.0f); then (1.0f, 1.0f); glVertex3f (1.0f, 1.0f,-1.0f); glTexCoord2f (1.0f, 1.0f); glVertex3f (-1.0f,-1.0f,-1.0f); // glTexCoord2f (0.0f, 1.0f); glVertex3f (1.0f, 1.0f, -1.0f,-1.0f); glTexCoord2f (0.0f, 0.0f); glVertex3f (1.0f,-1.0f, 1.0f); then (1.0f, 0.0f); glVertex3f (-1.0f,-1.0f, 1.0f); glTexCoord2f (1.0f, 0.0f ); glVertex3f (1.0f,-1.0f,-1.0f); // left glTexCoord2f (1.0f, 1.0f); glVertex3f (1.0f, 1.0f,-1.0f); glTexCoord2f (0.0f, 1.0f ); glVertex3f (1.0f, 1.0f, 1.0f); glTexCoord2f (0.0f, 0.0f); glVertex3f (1.0f,-1.0f, 1.0f); then (0.0f, 0.0f); glVertex3f (-1.0f, -1.0f,-1.0f); // right glTexCoord 2f (1.0f, 0.0f); glVertex3f (-1.0f,-1.0f, 1.0f); glTexCoord2f (1.0f, 1.0f); glVertex3f (-1.0f, 1.0f, 1.0f); glTexCoord2f (0.0f, 1.0f); glVertex3f (-1.0f, 1.0f,-1.0f); glEnd (); glDisable (GL_TEXTURE_2D); // cancel texture glPopMatrix ();} bool LoadT8 (char * filename, GLuint & texture) {AUX_RGBImageRec * pImage = NULL; pImage = auxDIBImageLoadA (filename); // load bitmap if (pImage = NULL) return false; glGenTextures (1, & texture ); // generate texture g LBindTexture (gradient, g_bmp [0]); // texture effect gluBuild2DMipmaps (GL_TEXTURE_2D, 4, pImage-> sizeX, pImage-> sizeY, GL_RGB, pixel, pImage-> data ); // map data free (pImage-> data); // release the bitmap memory free (pImage); return true;} void renderScene (void) {static float I = 0; I + = 0.01f; if (I> 360) I = 0; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); glTranslatef (0, 0,-1.5); glRotatef (I, 1, 1, 1); Box (0.3f, 0.3f, 0.3f); fig ();} void changeSize (int w, int h) {if (h = 0) h = 1; float ratio = 1.0 * w/h; glMatrixMode (GL_PROJECTION); // unitized projection matrix. GlLoadIdentity (); glViewport (0, 0, w, h); // you can specify the window size as gluPerspective (45, ratio, 1, 1000 ); // set the correct projection matrix glMatrixMode (GL_MODELVIEW); // set the Model View matrix glLoadIdentity (); gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0,-1.0, 0.0f, 1.0f, 0.0f); // set the observation point} int main (int argc, char * argv []) {gluinit (& argc, argv ); fig ); // call the function glureshapefunc (changeSize) when the specified program is idle; // specify the callback function glable (GL_DEPTH_TEST) when the window shape changes; g_text = gluNewQuadric (); // apply for the texture cache LoadT8 ("1.bmp", g_bmp [0]); fig (); return 0 ;}
The image is as follows: 1.bmp
Continent 6 Textures?
. This figure shows the glove. My original. It is already posted on the Forum. In fact, many of my original projects are mouse painting. I think PS is hard to make the desired effect. It is troublesome to change it once. So I think direct mouse painting is better. This is a picture of my mouse.
Why can't someone know why I can't open the sixth continental Paster ??
I couldn't open it a few days ago. Then I went to the Q group to ask the webmaster. The address is www.tongcx.com/this6. Can you try it? The webmaster said that you don't need to remember the website. Baidu just search for the first paid station on the sixth continent, if you cannot find this address, search Baidu.