From: <sv...@ww...> - 2005-01-16 10:19:34
|
Author: delta Date: 2005-01-16 02:19:28 -0800 (Sun, 16 Jan 2005) New Revision: 1447 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Source/GameScreen.cpp Log: * A Screenshots/ directory will be created (if non existent), when a snapshot is taken. The default location is CSPSim/Screenshots and is configurable in CSPSim.ini. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1447 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2005-01-16 10:12:07 UTC (rev 1446) +++ trunk/CSP/CSPSim/CHANGES.current 2005-01-16 10:19:28 UTC (rev 1447) @@ -1,6 +1,11 @@ Version 0.4.0 (in progress) =========================== +2005-01-16: delta + * A Screenshots/ directory will be created (if non existent), when a + snapshot is taken. The default location is CSPSim/Screenshots and is + configurable in CSPSim.ini. + 2005-01-15: lologramme * Mirage 2000: Textures "color diffuse" problem resolved Modified: trunk/CSP/CSPSim/Source/GameScreen.cpp =================================================================== --- trunk/CSP/CSPSim/Source/GameScreen.cpp 2005-01-16 10:12:07 UTC (rev 1446) +++ trunk/CSP/CSPSim/Source/GameScreen.cpp 2005-01-16 10:19:28 UTC (rev 1447) @@ -30,10 +30,13 @@ #include <osg/Image> #include <osgDB/WriteFile> +#include <osgDB/FileUtils> #include <osgUtil/SceneView> #include <osgText/Text> #include <Producer/Camera> +#include <Simdata/FileUtility.h> + #include "Animation.h" #include "ConsoleCommands.h" #include "CSPSim.h" @@ -90,7 +93,7 @@ // XXX: Preparing for the jump to OpenProducer ... class SnapImageDrawCallback: public Producer::Camera::Callback { - std::string m_Filename, m_Ext; + std::string m_Filename, m_Ext, m_Directory; bool m_SnapImageOnNextFrame; std::string getDate() { time_t timer; @@ -109,7 +112,10 @@ SnapImageDrawCallback(const std::string& filename = "CSP",const std::string& ext = ".jpg"): m_Filename(filename), m_Ext(ext), + m_Directory(g_Config.getString("Paths", "Screenshots", "../Screenshots", true)), m_SnapImageOnNextFrame(false){ + if (!osgDB::makeDirectory(m_Directory)) + std::cerr << "Warning: can't create target: " << m_Directory << "; no snapshot will be saved." << std::endl; } void setSnapImageOnNextFrame(bool flag) { m_SnapImageOnNextFrame = flag; @@ -130,7 +136,7 @@ image->readPixels(x,y,width,height,GL_RGB,GL_UNSIGNED_BYTE); // save the file in the form CSPmmddyy-hhmmss.ext - osgDB::writeImageFile(*image,m_Filename + getDate() + m_Ext); + osgDB::writeImageFile(*image, simdata::ospath::join(m_Directory, m_Filename + getDate() + m_Ext)); m_SnapImageOnNextFrame = false; } } |