Revision: 2452 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2452&view=rev Author: rorthomas Date: 2012-02-05 22:17:43 +0000 (Sun, 05 Feb 2012) Log Message: ----------- moved skia code to better place fixed skia linking
Modified Paths: -------------- trunk/source/main/CMakeLists.txt trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gameplay/RoRFrameListener.h trunk/source/main/physics/threading/BeamWorkerManager.cpp trunk/source/main/physics/threading/BeamWorkerManager.h Modified: trunk/source/main/CMakeLists.txt =================================================================== --- trunk/source/main/CMakeLists.txt 2012-02-05 07:04:08 UTC (rev 2451) +++ trunk/source/main/CMakeLists.txt 2012-02-05 22:17:43 UTC (rev 2452) @@ -51,6 +51,7 @@ if(ROR_USE_SKIA) setup_lib(SKIA) + add_definitions("-DOGRE_CANVAS_LIB") set(optional_libs ${optional_libs};${SKIA_LIBRARIES};OgreCanvas) endif() Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-02-05 07:04:08 UTC (rev 2451) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-02-05 22:17:43 UTC (rev 2452) @@ -1276,6 +1276,8 @@ #endif // MYGUI } + initGFXDebugging(); + initialized=true; } @@ -1313,7 +1315,6 @@ if (mplatform->disconnect()) delete(mplatform); } #endif - } @@ -5995,6 +5996,9 @@ // update GUI INPUTENGINE.Capture(); + if(mCanvasTextureClock1) + updateGFXDebugging(dt); + //if(collisions) printf("> ground model used: %s\n", collisions->last_used_ground_model->name); // exit frame started method when just displaying the GUI @@ -6578,3 +6582,78 @@ camRotX = camRotX_saved; camRotY = camRotY_saved; } + + + +void RoRFrameListener::updateGFXDebugging(float dt) +{ +#ifdef USE_SKIA + if(dt == 0) return; + rot += dt * 5.0f; + + // paint + Ogre::Canvas::Context* ctx = mCanvasTextureClock1->getContext(); + + x--; + if(x<0) + x = ctx->width(); + + ctx->save(); + ctx->clearRect(0, 0, 200, 150); + ctx->strokeStyle(Ogre::ColourValue::Black); + ctx->fillStyle(Ogre::ColourValue::White); + ctx->fillRect(0, 0, 200, 150); + ctx->translate(75, 75); + ctx->scale(0.4f, 0.4f); + ctx->rotate(-Ogre::Math::PI/2.0f + rot); + ctx->lineWidth(8); + ctx->lineCap(Ogre::Canvas::LineCap_Round); + // Hour marks + //ctx->save(); + for (float i=0; i<12; i++) + { + ctx->beginPath(); + ctx->rotate(Ogre::Math::PI/6.0f); + ctx->moveTo(100, 0); + ctx->lineTo(120, 0); + ctx->stroke(); + } + ctx->restore(); + + ctx->fillText("dt: " + TOSTRING(dt), 0, 10); + + const RenderTarget::FrameStats &stats = Ogre::Root::getSingleton().getAutoCreatedWindow()->getStatistics(); + ctx->fillText("fps: " + TOSTRING(stats.lastFPS), 0, 20); + + ctx->lineWidth(1); + ctx->strokeStyle(Ogre::ColourValue::White); + ctx->fillStyle(Ogre::ColourValue::White); + ctx->lineCap(Ogre::Canvas::LineCap_Square); + ctx->beginPath(); + ctx->moveTo(x, ctx->height()); + int h = ctx->height() - (ctx->height() / 120.0f) * (float)stats.lastFPS; + ctx->lineTo(x, h); + ctx->stroke(); + + mCanvasTextureClock1->uploadTexture(); +#endif // USE_SKIA +} + +void RoRFrameListener::initGFXDebugging() +{ +#ifdef USE_SKIA + // first, create skia texture + mCanvasTextureClock1 = new Ogre::Canvas::Texture("CanvasClock1", 600, 150); + mCanvasTextureClock1->createMaterial(); + + // the ogre overlay + Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create("Canvas/Overlay"); + Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "CanvasClock1/Panel")); + panel->setMetricsMode(Ogre::GMM_PIXELS); + panel->setMaterialName("CanvasClock1"); + panel->setDimensions(600.0f, 150.0f); + panel->setPosition(0, 0); + overlay->add2D(panel); + overlay->show(); +#endif // USE_SKIA +} \ No newline at end of file Modified: trunk/source/main/gameplay/RoRFrameListener.h =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.h 2012-02-05 07:04:08 UTC (rev 2451) +++ trunk/source/main/gameplay/RoRFrameListener.h 2012-02-05 22:17:43 UTC (rev 2452) @@ -54,6 +54,10 @@ # include "TreeLoader2D.h" #endif +#ifdef USE_SKIA +#include <CanvasTexture.h> +#endif // USE_SKIA + #include "OgreTerrainGroup.h" @@ -441,6 +445,12 @@ RenderWindow* renderwin; +#ifdef USE_SKIA + Ogre::Canvas::Texture *mCanvasTextureClock1; + float rot; + int x; +#endif // USE_SKIA + char screenshotformat[256]; bool useCaelumSky; float farclip; @@ -451,6 +461,8 @@ std::vector<animated_object_t> animatedObjects; bool updateAnimatedObjects(float dt); + void initGFXDebugging(); + void updateGFXDebugging(float dt); }; Modified: trunk/source/main/physics/threading/BeamWorkerManager.cpp =================================================================== --- trunk/source/main/physics/threading/BeamWorkerManager.cpp 2012-02-05 07:04:08 UTC (rev 2451) +++ trunk/source/main/physics/threading/BeamWorkerManager.cpp 2012-02-05 22:17:43 UTC (rev 2452) @@ -50,17 +50,12 @@ , done_count(0) , done_count_mutex() , done_count_cv() - , mCanvasTextureClock1(0) - , rot(0) - { pthread_mutex_init(&api_mutex, NULL); pthread_mutex_init(&done_count_mutex, NULL); pthread_cond_init(&done_count_cv, NULL); threads.clear(); - - initDebugging(); } BeamWorkerManager::~BeamWorkerManager() @@ -218,68 +213,3 @@ MUTEX_UNLOCK(&wd.work_mutex); // return to continue to do work } - -bool BeamWorkerManager::frameStarted(const FrameEvent& evt) -{ -#ifdef USE_SKIA - if(mCanvasTextureClock1) - updateDebugging(evt.timeSinceLastEvent); -#endif // USE_SKIA - return true; -} - -void BeamWorkerManager::updateDebugging(float dt) -{ -#ifdef USE_SKIA - rot += dt; - - // paint - Ogre::Canvas::Context* ctx = mCanvasTextureClock1->getContext(); - ctx->save(); - ctx->clearRect(0, 0, 200, 150); - ctx->strokeStyle(Ogre::ColourValue::Black); - ctx->fillStyle(Ogre::ColourValue::White); - ctx->fillRect(0, 0, 200, 150); - ctx->translate(75, 75); - ctx->scale(0.4f, 0.4f); - ctx->rotate(-Ogre::Math::PI/2.0f); - ctx->lineWidth(8); - ctx->lineCap(Ogre::Canvas::LineCap_Round); - // Hour marks - //ctx->save(); - for (float i=0; i<12; i++) - { - ctx->beginPath(); - ctx->rotate(Ogre::Math::PI/6.0f + rot); - ctx->moveTo(100, 0); - ctx->lineTo(120, 0); - ctx->stroke(); - } - ctx->restore(); - - ctx->fillText("dt: " + TOSTRING(dt), 10, 10); - - mCanvasTextureClock1->uploadTexture(); -#endif // USE_SKIA -} -void BeamWorkerManager::initDebugging() -{ -#ifdef USE_SKIA - // first, create skia texture - mCanvasTextureClock1 = new Ogre::Canvas::Texture("CanvasClock1", 600, 150); - mCanvasTextureClock1->createMaterial(); - - // the ogre overlay - Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create("Canvas/Overlay"); - Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "CanvasClock1/Panel")); - panel->setMetricsMode(Ogre::GMM_PIXELS); - panel->setMaterialName("CanvasClock1"); - panel->setDimensions(600.0f, 150.0f); - panel->setPosition(0, 0); - overlay->add2D(panel); - overlay->show(); - - // then add ourself as frame listener - Ogre::Root::getSingleton().addFrameListener(this); -#endif // USE_SKIA -} \ No newline at end of file Modified: trunk/source/main/physics/threading/BeamWorkerManager.h =================================================================== --- trunk/source/main/physics/threading/BeamWorkerManager.h 2012-02-05 07:04:08 UTC (rev 2451) +++ trunk/source/main/physics/threading/BeamWorkerManager.h 2012-02-05 22:17:43 UTC (rev 2452) @@ -27,16 +27,12 @@ #include "Singleton.h" #include "utils.h" -#ifdef USE_SKIA -#include <CanvasTexture.h> -#endif // USE_SKIA class BeamThread; // Manager that manages all threads and the beam locking class BeamWorkerManager : public RoRSingleton<BeamWorkerManager> - , Ogre::FrameListener { friend class BeamThread; friend class RoRSingleton<BeamWorkerManager>; @@ -66,15 +62,7 @@ void addThread(BeamThread *bthread); void removeThread(BeamThread *bthread); void syncThreads(BeamThread *bthread); - void initDebugging(); - void updateDebugging(float dt); -#ifdef USE_SKIA - Ogre::Canvas::Texture *mCanvasTextureClock1; - float rot; -#endif // USE_SKIA - - bool frameStarted(const FrameEvent& evt); public: static void createThread(); void _startWorkerLoop(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel