Results 1 to 3 of 3

Thread: Texure mapped to unwanted objects

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    7

    Texure mapped to unwanted objects

    Hi all,

    in openGL I've drawn a cube (using triangle strip) and textured it using a TGA file I created. The cube textures based on a buffer array I created with texture coordinates (wanted), but so does a neighbouring object (unwanted!). Also, the neighbouring object's colour influences the TGA texture on the cube.

    The TGA texture is meant to be coloured brown with black specks, but it is influenced by the green colour of the neighbourin object.

    Can anyone see why this is?

    Code :
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glLoadIdentity();
    	glEnable(GL_TEXTURE_2D);
     
    	gluLookAt(0.0,0.0,-100.0,0,0,0,0,1,0);
     
    	glRotatef(x_rotationAngle, 1, 0, 0);
    	glRotatef(y_rotationAngle, 0, 1, 0);
     
    	glEnableClientState(GL_VERTEX_ARRAY);
    	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     
    	glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    	glVertexPointer(3, GL_FLOAT, 0, 0);
     
    	glBindBuffer(GL_ARRAY_BUFFER, coordBuffer);
    	glTexCoordPointer(2, GL_FLOAT, 0, 0);
     
    	//Draw the triangles, we pass in the number of indices, the data type of the index array
    	// (GL_UNSIGNED_INT) and then the pointer to the start of the array
    	glDrawArrays(GL_TRIANGLE_STRIP, 0, 24);
     
    	//Finally disable the vertex array
    	glDisableClientState(GL_VERTEX_ARRAY);
    	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     
    	glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
    	glTranslatef(0.0f, 0.0f, -21.0f);
    	glPushMatrix();
    	gluSphere(quadratic,1.0f,32,32);
    	glTranslatef(0.00f, 0.0f, 0.5f);
    	glRotatef(-90,0,1,0);
    	gluCylinder(quadratic,0.5f,0.5f,1.5f,36,2);
    	glPopMatrix();
    	glTranslatef(-1.5f, 0.0f, 0.5f);
    	gluSphere(quadratic,0.5f,32,32);

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    12

    Re: Texure mapped to unwanted objects

    Disable texturing after you use it, just as you enabled it before, with glDisable(GL_TEXTURE_2D). And set the Color to white (1,1,1,1) before rendering the textured object. OpenGL is a state machine, so when you say "Use textures from now on" or "the following objects should be green" OpenGL will do so until you tell it otherwise.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    7

    Re: Texure mapped to unwanted objects

    Thank you very much! Those two things helped solve the problem. I also found that on top of those two things I didn't have my tga file read in using the correct data type either.

Similar Threads

  1. Replies: 0
    Last Post: 08-22-2015, 05:54 PM
  2. Corrupted data during mapped buffer! (Uniform Buffer Objects)
    By FrankBoltzmann in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-24-2014, 03:15 AM
  3. Texure Mapping
    By hksuhagiya in forum OpenGL: General
    Replies: 1
    Last Post: 09-23-2002, 01:32 PM
  4. > 64MB texure & GF4
    By Moshe Nissim in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 07-18-2002, 11:19 AM
  5. Surface Texure
    By aus79er in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-29-2002, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean