Example #1
0
void Click(int button, int state, int x, int y)
{
    double posX, posY;
    switch(button)
    {
    case 0:
        posX = ((double)x / (double)graphWin.xWinFunc()) * (graphWin.xMax() - graphWin.xMin()) + graphWin.xMin();
        posY = ((1 - (double)y / (double)graphWin.yWinFunc())) * (graphWin.yMax() - graphWin.yMin()) + graphWin.yMin();
        dessinerCourbe(posX, posY);
        break;
    }
}
void Reshape(int w, int h)
{
  if (h == 0) h = 1;
  if (w == 0) w = 1;
  glViewport(0, 0, w, h);

  graphWin.setWinPixels( w, h );

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();

  float xRatio = static_cast<float>(w)/static_cast<float>(graphWin.xWinFunc());
  float yRatio = static_cast<float>(h)/static_cast<float>(graphWin.yWinFunc());

  // Volume de clipping : (left, right, bottom, top, near, far)
  glOrtho(graphWin.xMin()*xRatio, graphWin.xMax()*xRatio, graphWin.yMin()*yRatio, graphWin.yMax()*yRatio, -2.0f, 2.0f);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}