title: drag and drop of images using opengl c++
body: <p>i want to create a game similare to this one <a href="http://www.sciencekids.co.nz/gamesactivities/movinggrowing.html" rel="nofollow">http://www.sciencekids.co.nz/gamesactivities/movinggrowing.html</a> </p>
  
  <p>1-how to move the image according to coordinates from the mouse? i know how to translate an object that i drow like polygon but not images?</p>
  
  <p>2- how to check if its in right plce and make it stuck there
  i used gltranslate but the image didn't move , and tried copypixl but it kept copying the image
  every where the mouse hits .</p>
  
  <pre><code> #include &lt;windows.h&gt;
  #include &lt;GL/glut.h&gt;
  #include &lt;gl/glaux.h&gt;
  
  #pragma comment(lib,"glaux.lib")
  
  AUX_RGBImageRec *image ;
  GLsizei wh = 600, ww = 800;
  //-----------------------------------------------------------------------------------------------
  void display(void){
  
      image = new AUX_RGBImageRec();
      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      image = auxDIBImageLoad(L"boy.bmp");
      glDrawPixels(image-&gt;sizeX, image-&gt;sizeY, GL_RGB,
      GL_UNSIGNED_BYTE,image-&gt;data);
  
      glFlush();
  }
  //-----------------------------------------------------------------------------------------------
  void mouse (int btn , int state , int x , int y){
  
      int h = wh-y ;
      if(btn == GLUT_LEFT_BUTTON &amp;&amp; state == GLUT_DOWN){
  
          /*glPushMatrix();*/
          /*glTranslatef(x , h , 0);*/
          glRasterPos2i(x,h);
          glCopyPixels(0,0,image-&gt;sizeX, image-&gt;sizeY,GL_COLOR);
          //glPopMatrix();}
          if(btn == GLUT_LEFT_BUTTON &amp;&amp; state == GLUT_UP) {
  
            // check if it is in right place to stuck it else will retuen to original place  
        }
      }glFlush();
  
  }
  //-----------------------------------------------------------------------------------------------
  void intiate(){
  
      glClearColor(0.0, 0.0, 0.0, 0.0);
      glMatrixMode (GL_PROJECTION);
      glLoadIdentity ();
      gluOrtho2D(0,ww,0,wh);
  }
  //-----------------------------------------------------------------------------------------------
  void main()
  {
  glutInitDisplayMode (GLUT_RGB);  
  glutInitWindowSize (ww, wh);
  glutInitWindowPosition (100, 100);
  glutCreateWindow ("Inside my Body");
  intiate();
  glutDisplayFunc(display);
  glutMouseFunc(mouse);
  glutMainLoop();
  } 
  </code></pre>