// 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(); }
int main(int argc, char * argv[]) { /* initalise and run the mandelbrot kernel */ clMandelbrot.initialize(); if(!clMandelbrot.parseCommandLine(argc, argv)) return SDK_FAILURE; if(clMandelbrot.setup()!=SDK_SUCCESS) return SDK_FAILURE; if(clMandelbrot.run()!=SDK_SUCCESS) return SDK_FAILURE; if(clMandelbrot.verifyResults()!=SDK_SUCCESS) return SDK_FAILURE; /* show window if it is not running in quiet mode */ if(clMandelbrot.showWindow()) { width = clMandelbrot.getWidth(); height = clMandelbrot.getHeight(); int * output = clMandelbrot.getPixels(); pixels = (unsigned char *)malloc(height*width*4*sizeof(unsigned char)); for(int i=0; i< width*height; ++i) { pixels[4*i] = (unsigned char)output[i]*(i/width)/height; pixels[4*i + 1] = (unsigned char)output[i]*(i%width)/width ; pixels[4*i + 2] = (unsigned char)output[i]*i/(width*height); pixels[4*i + 3] = 255; } initDisplay(argc, argv); mainLoopGL(); } cleanup(); return SDK_SUCCESS; }
int main(int argc, char * argv[]) { // initalise and run the mandelbrot kernel clMandelbrot.initialize(); if(clMandelbrot.parseCommandLine(argc, argv)) return SDK_FAILURE; if(clMandelbrot.isDumpBinaryEnabled()) { return clMandelbrot.genBinaryImage(); } else { int returnVal = clMandelbrot.setup(); if(returnVal != SDK_SUCCESS) return (returnVal == SDK_EXPECTED_FAILURE)? SDK_SUCCESS : SDK_FAILURE; if(clMandelbrot.run()!=SDK_SUCCESS) return SDK_FAILURE; if(clMandelbrot.verifyResults()!=SDK_SUCCESS) return SDK_FAILURE; // show window if it is not running in quiet mode if(clMandelbrot.showWindow()) { width = clMandelbrot.getWidth(); height = clMandelbrot.getHeight(); output = (unsigned char *)clMandelbrot.getPixels(); initDisplay(argc, argv); mainLoopGL(); } cleanup(); } return SDK_SUCCESS; }