From: spixx Date: Sun, 26 Nov 2006 14:26:34 +0000 (+0000) Subject: Minor cleanup. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1b297ccb518ed5e707ba6a09353adc3818f6161c;p=lsystem3d.git Minor cleanup. Handle close button events. --- diff --git a/src/renderingsurface.cpp b/src/renderingsurface.cpp index d01ffe6..b027e48 100644 --- a/src/renderingsurface.cpp +++ b/src/renderingsurface.cpp @@ -39,7 +39,8 @@ FXDEFMAP(RenderingSurface) RenderingSurfaceMap[] = FXMAPFUNC(SEL_RIGHTBUTTONPRESS, RenderingSurface::ID_CANVAS, RenderingSurface::onRightMouseDown), FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, RenderingSurface::ID_CANVAS, RenderingSurface::onRightMouseUp), FXMAPFUNC(SEL_MOTION, RenderingSurface::ID_CANVAS, RenderingSurface::onMouseMove), - FXMAPFUNC(SEL_PAINT, RenderingSurface::ID_CANVAS, RenderingSurface::onRepaint) + FXMAPFUNC(SEL_PAINT, RenderingSurface::ID_CANVAS, RenderingSurface::onRepaint), + FXMAPFUNC(SEL_CLOSE, 0, RenderingSurface::onQuit) }; // macro to set up class implementation @@ -49,12 +50,11 @@ FXIMPLEMENT(RenderingSurface, FXMainWindow, RenderingSurfaceMap, ARRAYNUMBER(Ren /** * Constructor - * @param application the FOX application object - * @param lsystem the Lindenmayer-system + * @param application the application object */ -RenderingSurface::RenderingSurface(FXApp *application, LindenmayerSystem *lsystem) : FXMainWindow(application, "LSystem3D", NULL, NULL, DECOR_ALL, 100, 100, 800, 800) +RenderingSurface::RenderingSurface(FXApp *application) : FXMainWindow(application, "LSystem3D", NULL, NULL, DECOR_ALL, 100, 100, 800, 800) { - _lsystem = lsystem; + _lsystem = NULL; _modelX = 0.0; _modelY = 0.0; @@ -75,6 +75,16 @@ RenderingSurface::RenderingSurface(FXApp *application, LindenmayerSystem *lsyste +/** + * Destructor + */ +RenderingSurface::~RenderingSurface() +{ + delete _visual; +} + + + /** * Create and initialize the window */ @@ -85,6 +95,7 @@ void RenderingSurface::create() // set up OpenGL _canvas->makeCurrent(); + initOpenGL(); // make the window appear @@ -302,9 +313,35 @@ long RenderingSurface::onRepaint(FXObject *sender, FXSelector selector, void *da glRotatef(_modelRotationY, 0.0, 1.0, 0.0); // render model - _lsystem->getModel()->draw(); - + _lsystem->render(); // make it appear _canvas->swapBuffers(); } + + + +/** + * Called by the system when the close button is pressed + * @param sender the sender object + * @param selector message type and id + * @param data event related data + * @return + */ +long RenderingSurface::onQuit(FXObject *sender, FXSelector selector, void *data) +{ + getApp()->exit(0); + + return 1; +} + + + +/** + * Set current L-system generator + * @param lsystem the L-system generator + */ +void RenderingSurface::setLSystem(LindenmayerSystem *lsystem) +{ + _lsystem = lsystem; +}