LCOV - code coverage report
Current view: top level - eq/util - bitmapFont.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 28 3.6 %
Date: 2016-07-30 05:04:55 Functions: 2 9 22.2 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2014, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #include "bitmapFont.h"
      19             : #include "objectManager.h"
      20             : 
      21             : #include <eq/gl.h>
      22             : #include <eq/windowSystem.h>
      23             : 
      24             : namespace eq
      25             : {
      26             : namespace util
      27             : {
      28             : namespace detail
      29             : {
      30           0 : class BitmapFont
      31             : {
      32             : public:
      33           0 :     BitmapFont( util::ObjectManager& om_, const void* key_ )
      34             :         // We create a new shared object manager. Typically we are exited by
      35             :         // the last user, at which point the given OM may have been deleted
      36             :         : om( om_ )
      37           0 :         , key( key_ )
      38           0 :     {}
      39             : 
      40             :     util::ObjectManager om;
      41             :     const void* key;
      42             : };
      43             : }
      44             : 
      45           0 : BitmapFont::BitmapFont( ObjectManager& om, const void* key )
      46           0 :     : _impl( new detail::BitmapFont( om, key ))
      47             : {
      48           0 : }
      49             : 
      50           0 : BitmapFont::~BitmapFont()
      51             : {
      52           0 :     const GLuint lists = _impl->om.getList( _impl->key );
      53           0 :     if( lists != ObjectManager::INVALID )
      54           0 :         LBWARN << "OpenGL BitmapFont was not freed" << std::endl;
      55           0 :     delete _impl;
      56           0 : }
      57             : 
      58           0 : bool BitmapFont::init( const WindowSystem& ws, const std::string& name,
      59             :                        const uint32_t size )
      60             : {
      61           0 :     return ws.setupFont( _impl->om, _impl->key, name, size );
      62             : }
      63             : 
      64           0 : void BitmapFont::exit()
      65             : {
      66           0 :     GLuint lists = _impl->om.getList( _impl->key );
      67           0 :     if( lists != ObjectManager::INVALID )
      68           0 :         _impl->om.deleteList( _impl->key );
      69           0 : }
      70             : 
      71           0 : void BitmapFont::draw( const std::string& text ) const
      72             : {
      73           0 :     const GLuint lists = _impl->om.getList( _impl->key );
      74           0 :     if( lists != ObjectManager::INVALID )
      75             :     {
      76           0 :         glListBase( lists );
      77           0 :         glCallLists( GLsizei( text.size( )), GL_UNSIGNED_BYTE, text.c_str( ));
      78           0 :         glListBase( 0 );
      79             :     }
      80           0 : }
      81             : 
      82             : }
      83          42 : }

Generated by: LCOV version 1.11