c - Using two textures in OpenGL -


I am writing a program in which I have to use two different textures. I can read a file and use it as a texture, but by now I'm unable to get two textures to work. I have my code to set a texture which I have:

  FILE * fd; Int k, nm; Four c; Int i, i; Four b [256]; Float S; Int red, green, blue; FD = FOPAN ("AILAPPPM", "R"); Check the first line for // p3 fscanf (fd, "% [^ \ n]", b); if (b [0]! = 'P' || b [1]! = '3') {printf ("% s is not a PPM file \ n", b); System ("pause"); Exit (0); } // leave comments fscanf (fd, "% c% c", & amp; c, & c); While (C == '#') {fscanf (fd, "% [^ \ n]", b); FSACNF (FD, "% C% C", and C, and C); } // First put the first character of the non comment line ungetc (C, FD); // file file information fscanf (fd, "% d% d% d", & amp; o, & amp; m; & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; Nm = o * m; // Image of the overall size = mallok (3 * size (glutton) * nm); S = 255./k; For (i = 0; i & lt; nm; i ++) {fscanf (FD, "% d% d% d", & red, and green, and blue); Image [3 * nm - 3 * i - 3] = Red; Image [3 * nm - 3 * i-2] = green; Image [3 * nm - 3 * i - 1] = blue; } GlPixelTransferf (GL_RED_SCALE, S); Glupecs Transfurf (GL_Green_SCAL, S); Glupecs Transfife (GL_ BLUE_SCALE, S); Glupeclasty (GL_UNPAPIPPHGHH, GLTRU); Glaxics Story (GL_UNPAP_IMENTMENT, 1); glEnable (GL_TEXTURE_2D); GlTexImage2D (GL_TEXTURE_2D, 0, 3, o1, M1, 0, GL_RGB, GL_ UNSIGNED_INT, image); GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); Glennable (GL_DEPTH_TEST); Glucaller (0.0, 0.0, 0.0, 1.0);   

I have tried to fix everything that I can think and can not work properly.

Your texture details look fine, but you have to brush on the basics of OpenGL. The red book is a good place to start.

Go to the bottom of the section on the Texture Object .

Before calling glTexImage2d , you want to generate and bind a new textured object.

When rendering, you compose the texture that you want to render before making any preferences.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -