LCOV - code coverage report
Current view: top level - eq/util - bitmapFont.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 29 3.4 %
Date: 2017-12-16 05:07:20 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           0 :         : om(om_),
      37           0 :           key(key_)
      38             :     {
      39           0 :     }
      40             : 
      41             :     util::ObjectManager om;
      42             :     const void* key;
      43             : };
      44             : }
      45             : 
      46           0 : BitmapFont::BitmapFont(ObjectManager& om, const void* key)
      47           0 :     : _impl(new detail::BitmapFont(om, key))
      48             : {
      49           0 : }
      50             : 
      51           0 : BitmapFont::~BitmapFont()
      52             : {
      53           0 :     const GLuint lists = _impl->om.getList(_impl->key);
      54           0 :     if (lists != ObjectManager::INVALID)
      55           0 :         LBWARN << "OpenGL BitmapFont was not freed" << std::endl;
      56           0 :     delete _impl;
      57           0 : }
      58             : 
      59           0 : bool BitmapFont::init(const WindowSystem& ws, const std::string& name,
      60             :                       const uint32_t size)
      61             : {
      62           0 :     return ws.setupFont(_impl->om, _impl->key, name, size);
      63             : }
      64             : 
      65           0 : void BitmapFont::exit()
      66             : {
      67           0 :     GLuint lists = _impl->om.getList(_impl->key);
      68           0 :     if (lists != ObjectManager::INVALID)
      69           0 :         _impl->om.deleteList(_impl->key);
      70           0 : }
      71             : 
      72           0 : void BitmapFont::draw(const std::string& text) const
      73             : {
      74           0 :     const GLuint lists = _impl->om.getList(_impl->key);
      75           0 :     if (lists != ObjectManager::INVALID)
      76             :     {
      77           0 :         glListBase(lists);
      78           0 :         glCallLists(GLsizei(text.size()), GL_UNSIGNED_BYTE, text.c_str());
      79           0 :         glListBase(0);
      80             :     }
      81           0 : }
      82             : }
      83          30 : }

Generated by: LCOV version 1.11