Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: multiples textured elements do not display

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    5

    multiples textured elements do not display

    I am working on a n-body code with "glut functions" display. I would like to display each body with a 2D texture from a bmp image.
    The coordinates of each body (x, y, z) is in the "pos" array. I try to use glTexCoordPointer with the following display function :

    Code :
      void drawPoints()
        {       
            glPushMatrix();
     
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear The Screen And The Depth Buffer
            glBindTexture(GL_TEXTURE_2D, texture[0]);    // pick the texture.
            glLoadIdentity(); // reset the view before we draw each star.
        	glTranslatef(0.0f, 0.0f, zoom);    // zoom into the screen. 
     
            glEnableClientState(GL_VERTEX_ARRAY);
            lEnableClientState(GL_TEXTURE_COORD_ARRAY);
     
            glVertexPointer(4, GL_DOUBLE, 4*sizeof(double), pos);	
        	glTexCoordPointer(4, GL_DOUBLE, 4*sizeof(double), pos);
     
            // Assign A Color Using Bytes
        	glColor4ub(30, 100, 120, 255);
        	glBegin(GL_QUADS);  // Begin Drawing The Textured Quad
        	glTexCoord2f(0.0f, 0.0f);  glVertex3f(-1.0f,-1.0f, 0.0f);
        	glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f);
        	glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f);
        	glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);
        	glEnd();   // Done Drawing The Textured Quad
     
            glDrawArrays(GL_QUADS, 0, numBodies);			
        	glDisableClientState(GL_TEXTURE_COORD_ARRAY);	
        	glDisableClientState(GL_VERTEX_ARRAY);	
     
            glPopMatrix();	
        }


    but only one textured body is displayed.

    Anyone sees what's wrong ?
    Last edited by youpi1; 10-29-2012 at 05:16 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
  •