Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. void display()
  2. {
  3.       glClearColor(0.0,0.0,0.0,1.0);
  4.  
  5.       glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);  
  6.  
  7.       for(std::vector<GLuint>::iterator I = cube.begin(); I != cube.end(); ++I)
  8.       {
  9.                
  10.           glCallList(*I);
  11.  
  12.            }
  13.  
  14.      
  15.          if(DrawArea == true)
  16.          {
  17.  
  18.         glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
  19.  
  20.     cerr << winZ << endl;
  21.  
  22.  
  23.     //MIGHT NEED TO CHANGE THE ORDER OF THESE TWO FUNCTIONS PREHAPS [ 0 ]  0 = NOT DONE , 1 = DONE
  24.  
  25.     glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
  26.  
  27.     glGetDoublev(GL_PROJECTION_MATRIX, projection);
  28.  
  29.     glGetIntegerv(GL_VIEWPORT, viewport);
  30.  
  31.     gluUnProject(winX, winY, winZ , modelview, projection, viewport, &posX, &posY, & posZ);
  32.  
  33.         glBindTexture(GL_TEXTURE_2D, DrawAreaTexture);
  34.  
  35.         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  36.  
  37.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  38.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  39.      
  40.         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);  
  41.  
  42.         glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, DrawAreaSurface->w, DrawAreaSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, DrawAreaSurface->pixels);
  43.  
  44.         glEnable(GL_TEXTURE_2D);
  45.  
  46.         glBindTexture(GL_TEXTURE_2D, DrawAreaTexture);
  47.  
  48.     glTranslatef(posX , posY, posZ);
  49.  
  50.          glBegin(GL_QUADS);
  51.  
  52.          glTexCoord2f (0.0, 0.0);
  53.          glVertex3f(0.5, 0.5, 0);
  54.  
  55.          glTexCoord2f (1.0, 0.0);
  56.          glVertex3f(0, 0.5, 0);
  57.        
  58.          glTexCoord2f (1.0, 1.0);
  59.          glVertex3f(0, 0, 0);
  60.  
  61.          glTexCoord2f (0.0, 1.0);
  62.          glVertex3f(0.5, 0, 0);
  63.  
  64.          glEnd();
  65.  
  66.      
  67.  
  68.             }    
  69.          
  70.           SwapBuffers(hDC);
  71.  
  72.  
  73.           //FOR SPAMMING 1/0
  74.          // cerr << DrawArea << endl;              
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement