Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2007-2011, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * - Redistributions of source code must retain the above copyright notice, this 00008 * list of conditions and the following disclaimer. 00009 * - Redistributions in binary form must reproduce the above copyright notice, 00010 * this list of conditions and the following disclaimer in the documentation 00011 * and/or other materials provided with the distribution. 00012 * - Neither the name of Eyescale Software GmbH nor the names of its 00013 * contributors may be used to endorse or promote products derived from this 00014 * software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00019 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00020 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00022 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00025 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00026 * POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00029 #include "window.h" 00030 00031 #include "error.h" 00032 #include "pipe.h" 00033 00034 namespace eVolve 00035 { 00036 00037 bool Window::configInit( const eq::uint128_t& initID ) 00038 { 00039 // Enforce alpha channel, since we need one for rendering 00040 setIAttribute( IATTR_PLANES_ALPHA, 8 ); 00041 00042 return eq::Window::configInit( initID ); 00043 } 00044 00045 bool Window::configInitGL( const eq::uint128_t& initID ) 00046 { 00047 Pipe* pipe = static_cast<Pipe*>( getPipe() ); 00048 Renderer* renderer = pipe->getRenderer(); 00049 00050 if( !renderer ) 00051 return false; 00052 00053 if( !GLEW_ARB_shader_objects ) 00054 { 00055 setError( ERROR_EVOLVE_ARB_SHADER_OBJECTS_MISSING ); 00056 return false; 00057 } 00058 if( !GLEW_EXT_blend_func_separate ) 00059 { 00060 setError( ERROR_EVOLVE_EXT_BLEND_FUNC_SEPARATE_MISSING ); 00061 return false; 00062 } 00063 if( !GLEW_ARB_multitexture ) 00064 { 00065 setError( ERROR_EVOLVE_ARB_MULTITEXTURE_MISSING ); 00066 return false; 00067 } 00068 00069 glEnable( GL_SCISSOR_TEST ); // needed to constrain channel viewport 00070 00071 glClear( GL_COLOR_BUFFER_BIT ); 00072 swapBuffers(); 00073 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 00074 00075 renderer->glewSetContext( glewGetContext( )); 00076 00077 if( !renderer->loadShaders( )) 00078 { 00079 setError( ERROR_EVOLVE_LOADSHADERS_FAILED ); 00080 return false; 00081 } 00082 00083 _loadLogo(); 00084 return true; 00085 } 00086 00087 namespace 00088 { 00089 #ifdef EQ_RELEASE 00090 # ifdef _WIN32 // final INSTALL_DIR is not known at compile time 00091 static const std::string _logoTextureName = 00092 std::string( "../share/Equalizer/data/logo.rgb" ); 00093 # else 00094 static const std::string _logoTextureName = std::string( EQ_INSTALL_DIR ) + 00095 std::string( "share/Equalizer/data/logo.rgb" ); 00096 # endif 00097 #else 00098 static const std::string _logoTextureName = std::string( EQ_SOURCE_DIR ) + 00099 std::string( "examples/eVolve/logo.rgb" ); 00100 #endif 00101 } 00102 00103 void Window::_loadLogo() 00104 { 00105 if( !GLEW_ARB_texture_rectangle ) 00106 { 00107 EQWARN << "Can't load overlay logo, GL_ARB_texture_rectangle not " 00108 << "available" << std::endl; 00109 return; 00110 } 00111 00112 eq::Window::ObjectManager* om = getObjectManager(); 00113 _logoTexture = om->getEqTexture( _logoTextureName.c_str( )); 00114 if( _logoTexture ) 00115 return; 00116 00117 eq::Image image; 00118 if( !image.readImage( _logoTextureName, eq::Frame::BUFFER_COLOR )) 00119 { 00120 EQWARN << "Can't load overlay logo " << _logoTextureName << std::endl; 00121 return; 00122 } 00123 00124 _logoTexture = om->newEqTexture( _logoTextureName.c_str(), 00125 GL_TEXTURE_RECTANGLE_ARB ); 00126 EQASSERT( _logoTexture ); 00127 00128 image.upload(eq::Frame::BUFFER_COLOR, _logoTexture, eq::Vector2i::ZERO, om); 00129 EQVERB << "Created logo texture of size " << _logoTexture->getWidth() << "x" 00130 << _logoTexture->getHeight() << std::endl; 00131 } 00132 00133 00134 void Window::swapBuffers() 00135 { 00136 const Pipe* pipe = static_cast<Pipe*>( getPipe( )); 00137 const FrameData& frameData = pipe->getFrameData(); 00138 const eq::Channels& channels = getChannels(); 00139 00140 if( frameData.useStatistics() && !channels.empty( )) 00141 EQ_GL_CALL( channels.back()->drawStatistics( )); 00142 00143 eq::Window::swapBuffers(); 00144 } 00145 }