Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eVolve/window.cpp
1 
2 /* Copyright (c) 2007-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * - Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  * - Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * - Neither the name of Eyescale Software GmbH nor the names of its
13  * contributors may be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "window.h"
30 
31 #include "error.h"
32 #include "pipe.h"
33 
34 namespace eVolve
35 {
36 
37 bool Window::configInit( const eq::uint128_t& initID )
38 {
39  // Enforce alpha channel, since we need one for rendering
41 
42  return eq::Window::configInit( initID );
43 }
44 
45 bool Window::configInitGL( const eq::uint128_t& )
46 {
47  Pipe* pipe = static_cast<Pipe*>( getPipe() );
48  Renderer* renderer = pipe->getRenderer();
49 
50  if( !renderer )
51  return false;
52 
53  if( !GLEW_ARB_shader_objects )
54  {
55  sendError( ERROR_EVOLVE_ARB_SHADER_OBJECTS_MISSING );
56  return false;
57  }
58  if( !GLEW_EXT_blend_func_separate )
59  {
60  sendError( ERROR_EVOLVE_EXT_BLEND_FUNC_SEPARATE_MISSING );
61  return false;
62  }
63  if( !GLEW_ARB_multitexture )
64  {
65  sendError( ERROR_EVOLVE_ARB_MULTITEXTURE_MISSING );
66  return false;
67  }
68 
69  glEnable( GL_SCISSOR_TEST ); // needed to constrain channel viewport
70 
71  glClear( GL_COLOR_BUFFER_BIT );
72  swapBuffers();
73  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
74 
75  renderer->glewSetContext( glewGetContext( ));
76 
77  if( !renderer->loadShaders( ))
78  {
79  sendError( ERROR_EVOLVE_LOADSHADERS_FAILED );
80  return false;
81  }
82 
83  _loadLogo();
84  return true;
85 }
86 
87 namespace
88 {
89 static const std::string _logoTextureName =
90  std::string( lunchbox::getExecutablePath() +
91  "/../share/Equalizer/data/logo.rgb" );
92 }
93 
94 void Window::_loadLogo()
95 {
96  if( !GLEW_ARB_texture_rectangle )
97  {
98  LBWARN << "Can't load overlay logo, GL_ARB_texture_rectangle not "
99  << "available" << std::endl;
100  return;
101  }
102 
104  _logoTexture = om.getEqTexture( _logoTextureName.c_str( ));
105  if( _logoTexture )
106  return;
107 
108  eq::Image image;
109  if( !image.readImage( _logoTextureName, eq::Frame::BUFFER_COLOR ))
110  {
111  LBWARN << "Can't load overlay logo " << _logoTextureName << std::endl;
112  return;
113  }
114 
115  _logoTexture = om.newEqTexture( _logoTextureName.c_str(),
116  GL_TEXTURE_RECTANGLE_ARB );
117  LBASSERT( _logoTexture );
118 
119  image.upload(eq::Frame::BUFFER_COLOR, _logoTexture, eq::Vector2i::ZERO, om);
120  image.deleteGLObjects( om );
121  LBVERB << "Created logo texture of size " << _logoTexture->getWidth() << "x"
122  << _logoTexture->getHeight() << std::endl;
123 }
124 
125 
127 {
128  const Pipe* pipe = static_cast<Pipe*>( getPipe( ));
129  const FrameData& frameData = pipe->getFrameData();
130  const eq::Channels& channels = getChannels();
131 
132  if( frameData.useStatistics() && !channels.empty( ))
133  EQ_GL_CALL( channels.back()->drawStatistics( ));
134 
136 }
137 }
virtual bool configInitGL(const eq::uint128_t &initID)
Initialize the OpenGL state for this window.
EQ_API bool upload(const Frame::Buffer buffer, util::Texture *texture, const Vector2i &position, util::ObjectManager &glObjects) const
Upload this image to the frame buffer or a texture.
virtual bool configInit(const eq::uint128_t &initID)
Initialize this window.
EQ_API EventOCommand sendError(const uint32_t error) final
Send a window error event to the application node.
EQFABRIC_INL void setIAttribute(const WindowSettings::IAttribute attr, const int32_t value)
Set a window attribute.
EQ_API void deleteGLObjects(util::ObjectManager &om)
Delete all OpenGL objects allocated from the given object manager.
virtual void swapBuffers()
Swap the front and back buffer of the window.
A holder for pixel data.
Definition: image.h:35
std::vector< Channel * > Channels
A vector of pointers to eq::Channel.
EQ_API int32_t getWidth() const
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:51
virtual EQ_API void swapBuffers()
Swap the front and back buffer of the window.
EQ_API int32_t getHeight() const
EQ_API const GLEWContext * glewGetContext() const
Get the GLEW context for this window.
EQ_API bool readImage(const std::string &filename, const Frame::Buffer buffer)
Read pixel data from an uncompressed rgb image file.
virtual EQ_API bool configInit(const uint128_t &initID)
Initialize this window.
util::ObjectManager & getObjectManager()