コード例 #1
0
// idle function 
void
idleFunc(void)
{
    if (panning)
    {
        if (mouseX < (width / 4))
        {
            clMandelbrot.setXPos(clMandelbrot.getXPos() - clMandelbrot.getXStep());
        }
        else if (mouseX > (3 * width / 4))
        {
            clMandelbrot.setXPos(clMandelbrot.getXPos() + clMandelbrot.getXStep());
        }
        if (mouseY < (height / 4))
        {
            clMandelbrot.setYPos(clMandelbrot.getYPos() + clMandelbrot.getYStep());
        }
        else if (mouseY > (3 * height / 4))
        {
            clMandelbrot.setYPos(clMandelbrot.getYPos() - clMandelbrot.getYStep());
        }
        if (zoomIn)
        {
            clMandelbrot.setXSize(clMandelbrot.getXSize() * 0.99);
        }
        else if (zoomOut)
        {
            clMandelbrot.setXSize(clMandelbrot.getXSize() / 0.99);
        }
    }
    clMandelbrot.run();
    //clMandelbrot.verifyResults();

    glutPostRedisplay();
}
コード例 #2
0
// keyboard function 
void
keyboardFunc(unsigned char key, int mouseX, int mouseY)
{
    switch(key)
    {
        // If the user hits escape or Q, then exit 
        case GLUT_ESCAPE_KEY:
        case 'q':
        case 'Q':
            {
                cleanup();
                exit(0);
                break;
            }
        case 'c':
            {
                printf("center (%.13f, %.13f), window width %.13f\n", clMandelbrot.getXPos(), clMandelbrot.getYPos(),
                                                                      clMandelbrot.getXStep());
                break;
            }
        case 'i':
            {
                cl_uint maxIterations = clMandelbrot.getMaxIterations();
                maxIterations = ((maxIterations * 2) < MAX_ITER) ? maxIterations * 2 : MAX_ITER;
                printf("Setting maxIterations to %d\n", maxIterations);
                clMandelbrot.setMaxIterations(maxIterations);
                break;
            }
        case 'I':
            {
                cl_uint maxIterations = clMandelbrot.getMaxIterations();
                maxIterations = ((maxIterations / 2) > MIN_ITER) ? maxIterations / 2 : MIN_ITER;
                printf("Setting maxIterations to %d\n", maxIterations);
                clMandelbrot.setMaxIterations(maxIterations);
                break;
            }
        case 'b':
            {
                if (clMandelbrot.getTiming())
                {
                    clMandelbrot.setBench(1);
                }
            }
        case 'p':
            {
                panning = (panning == false)? true : false;
                break;
            }
        default:
            break;
    }
}