X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Frenderingsurface.cpp;h=b027e48430228acb7a23d1f3ba50d85e05187167;hb=HEAD;hp=8da174d2860298914892cb2eb932db7fa81c94a0;hpb=3025996ba17bf59f5bc64def5d55b95c4d732a8a;p=lsystem3d.git diff --git a/src/renderingsurface.cpp b/src/renderingsurface.cpp index 8da174d..b027e48 100644 --- a/src/renderingsurface.cpp +++ b/src/renderingsurface.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2006 Erik Dahlberg // -// This file is part of LSystem3d. +// This file is part of LSystem3D. // // LSystem3D is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -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; +}