Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / movie_shooter.h
blobd95f858960e416b1f758bc50576f42c436d9ba31
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CL_MOVIE_SHOOTER_H
20 #define CL_MOVIE_SHOOTER_H
23 /////////////
24 // INCLUDE //
25 /////////////
26 #include "nel/misc/types_nl.h"
27 #include "nel/misc/rgba.h"
28 #include "nel/misc/bitmap.h"
29 #include "nel/3d/u_driver.h"
30 #include "nel/3d/u_text_context.h"
33 ///////////
34 // USING //
35 ///////////
36 using NLMISC::CRGBA;
37 using NL3D::UDriver;
38 using NL3D::UTextContext;
40 // ***************************************************************************
41 /** Shoot frames into RAM, then write them to disc.
44 class CMovieShooter
46 public:
47 CMovieShooter();
48 ~CMovieShooter();
50 /// Fail if can't allocate Movie Memory, or if maxMemory==0
51 bool init(uint maxMemory);
53 /// Clear the container.
54 void clearMemory();
56 bool enabled() const {return _MemorySize>0;}
58 /// Add a frame from driver shoot.
59 bool addFrame(double time, UDriver *pDriver);
61 /// Add a frame. return false if error. NB: if the movie has looped, erase some images from begin, but still return true
62 bool addFrame(double time, CRGBA *pImage, uint w, uint h);
64 /// return the number of frames currenty added.
65 uint getNumFrames();
67 /** replay the movie in a driver, until end of movie
68 * NB: stop if ESC is pressed.
70 void replayMovie(UDriver *drv, UTextContext *textContext);
72 /** Save the movie to a directory: shoot_00000.tga, .... Throw Exception if error.
73 * Frames are saved at a constant rate. if linearInterp is true, frames are interpolated to give
74 * the best view result.
75 * NB: stop if ESC is pressed
77 void saveMovie(UDriver *drv, UTextContext *textContext, const char *path, float framePeriod, bool allowLinearInterp= true, const char *prefix = "shot_");
79 /// Reset all frames. ready to addFrame() from 0.
80 void resetMovie();
82 /// Set the frame skipping (in nb frame) set to 0 to not skip frames
83 void setFrameSkip (uint32 nNbFrameToSkip);
86 // **************
87 private:
89 struct CFrameHeader
91 double Time;
92 uint32 Width, Height;
93 uint8 *Data;
94 // NULL if end of list.
95 CFrameHeader *Next;
99 uint8 *_MemoryBlock;
100 uint32 _MemorySize;
101 uint32 _CurrentIndex;
102 uint _NumFrames;
103 // The first frame of the movie. != from _MemoryBlock if looped
104 CFrameHeader *_FirstFrame;
105 CFrameHeader *_LastFrame;
107 uint32 _FrameSkip;
108 uint32 _CurrentFrameSkip;
110 // Resize and Fill a bitmap with a frame.
111 void getFrameData(CFrameHeader *frame, NLMISC::CBitmap &bmp);
115 // ***************************************************************************
116 // The default movie_shooter
117 extern CMovieShooter MovieShooter;
120 #endif // CL_DEMO_H
122 /* End of demo.h */