Line data Source code
1 : /* Copyright (c) 2013, Julio Delgado Mangas <julio.delgadomangas@epfl.ch>
2 : *
3 : * This library is free software; you can redistribute it and/or modify it under
4 : * the terms of the GNU Lesser General Public License version 2.1 as published
5 : * by the Free Software Foundation.
6 : *
7 : * This library is distributed in the hope that it will be useful, but WITHOUT
8 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 : * details.
11 : *
12 : * You should have received a copy of the GNU Lesser General Public License
13 : * along with this library; if not, write to the Free Software Foundation, Inc.,
14 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 : */
16 :
17 : #include "fileFrameWriter.h"
18 :
19 : #include <eq/client/channel.h>
20 : #include <eq/client/image.h>
21 : #include <eq/client/gl.h>
22 : #include <eq/client/pipe.h>
23 :
24 : #include <lunchbox/log.h>
25 :
26 : #include <sstream>
27 :
28 : namespace
29 : {
30 1 : std::string _buildFileName( const eq::Channel* channel )
31 : {
32 1 : std::stringstream name;
33 2 : name << channel->getSAttribute( eq::Channel::SATTR_DUMP_IMAGE )
34 2 : << channel->getPipe()->getCurrentFrame() << ".rgb";
35 1 : return name.str();
36 : }
37 : }
38 :
39 : namespace eq
40 : {
41 : namespace detail
42 : {
43 825 : FileFrameWriter::FileFrameWriter()
44 : {
45 825 : _image.setAlphaUsage( true );
46 825 : _image.setQuality( eq::Frame::BUFFER_COLOR, 1.0f );
47 825 : _image.setStorageType( eq::Frame::TYPE_MEMORY );
48 825 : _image.setInternalFormat( eq::Frame::BUFFER_COLOR, GL_RGBA );
49 825 : }
50 :
51 1 : void FileFrameWriter::write( eq::Channel* channel )
52 : {
53 1 : if( _image.startReadback( eq::Frame::BUFFER_COLOR,
54 1 : channel->getPixelViewport(),
55 2 : channel->getZoom(), channel->getObjectManager( )))
56 : {
57 1 : _image.finishReadback( channel->glewGetContext( ));
58 : }
59 :
60 1 : const std::string& fileName = _buildFileName( channel );
61 1 : if( !_image.writeImage( fileName, eq::Frame::BUFFER_COLOR ))
62 0 : LBWARN << "Could not write file " << fileName << std::endl;
63 1 : }
64 :
65 30 : FileFrameWriter::~FileFrameWriter()
66 : {
67 15 : _image.flush();
68 15 : }
69 :
70 : }
71 36 : }
|