LCOV - code coverage report
Current view: top level - include/vcl - OpenGLContext.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 19 0.0 %
Date: 2014-04-11 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef VCL_OPENGL_CONTEXT_HXX
      11             : #define VCL_OPENGL_CONTEXT_HXX
      12             : 
      13             : #include <string.h>
      14             : 
      15             : #include <GL/glew.h>
      16             : 
      17             : #if defined( MACOSX )
      18             : #elif defined( IOS )
      19             : #elif defined( ANDROID )
      20             : #elif defined( UNX )
      21             : #  include <prex.h>
      22             : #  include "GL/glxew.h"
      23             : #  include <postx.h>
      24             : #elif defined( _WIN32 )
      25             : #  include "prewin.h"
      26             : #  include "windows.h"
      27             : #  include "postwin.h"
      28             : #endif
      29             : 
      30             : #if defined( _WIN32 )
      31             : #include <GL/glext.h>
      32             : #include <GL/wglext.h>
      33             : #elif defined( MACOSX )
      34             : #elif defined( IOS )
      35             : #elif defined( ANDROID )
      36             : #elif defined( UNX )
      37             : #include <GL/glext.h>
      38             : #define GLX_GLXEXT_PROTOTYPES 1
      39             : #include <GL/glx.h>
      40             : #include <GL/glxext.h>
      41             : #endif
      42             : 
      43             : #include <vcl/vclopengl_dllapi.hxx>
      44             : #include <boost/scoped_ptr.hpp>
      45             : #include <vcl/window.hxx>
      46             : #include <tools/gen.hxx>
      47             : #include <vcl/syschild.hxx>
      48             : 
      49             : /// Holds the information of our new child window
      50             : struct GLWindow
      51             : {
      52             :     // Copy of gluCheckExtension(), from the Apache-licensed
      53             :     // https://code.google.com/p/glues/source/browse/trunk/glues/source/glues_registry.c
      54           0 :     static GLboolean checkExtension(const GLubyte* extName, const GLubyte* extString)
      55             :     {
      56           0 :       GLboolean flag=GL_FALSE;
      57             :       char* word;
      58             :       char* lookHere;
      59             :       char* deleteThis;
      60             : 
      61           0 :       if (extString==NULL)
      62             :       {
      63           0 :          return GL_FALSE;
      64             :       }
      65             : 
      66           0 :       deleteThis=lookHere=(char*)malloc(strlen((const char*)extString)+1);
      67           0 :       if (lookHere==NULL)
      68             :       {
      69           0 :          return GL_FALSE;
      70             :       }
      71             : 
      72             :       /* strtok() will modify string, so copy it somewhere */
      73           0 :       strcpy(lookHere,(const char*)extString);
      74             : 
      75           0 :       while ((word=strtok(lookHere, " "))!=NULL)
      76             :       {
      77           0 :          if (strcmp(word,(const char*)extName)==0)
      78             :          {
      79           0 :             flag=GL_TRUE;
      80           0 :             break;
      81             :          }
      82           0 :          lookHere=NULL; /* get next token */
      83             :       }
      84           0 :       free((void*)deleteThis);
      85             : 
      86           0 :       return flag;
      87             :     }
      88             : 
      89             : #if defined( _WIN32 )
      90             :     HWND                    hWnd;
      91             :     HDC                     hDC;
      92             :     HGLRC                   hRC;
      93             : #elif defined( MACOSX )
      94             : #elif defined( IOS )
      95             : #elif defined( ANDROID )
      96             : #elif defined( UNX )
      97             :     Display*           dpy;
      98             :     int                     screen;
      99             :     XLIB_Window             win;
     100             : #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
     101             :     GLXFBConfig        fbc;
     102             : #endif
     103             :     XVisualInfo*       vi;
     104             :     GLXContext         ctx;
     105             : 
     106           0 :     bool HasGLXExtension( const char* name ) { return checkExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); }
     107             :     const char*             GLXExtensions;
     108             : #endif
     109             :     unsigned int            bpp;
     110             :     unsigned int            Width;
     111             :     unsigned int            Height;
     112             :     const GLubyte*          GLExtensions;
     113             :     bool bMultiSampleSupported;
     114             : 
     115             :     bool HasGLExtension( const char* name ) { return checkExtension( (const GLubyte*) name, GLExtensions ); }
     116             : 
     117           0 :     GLWindow()
     118             :         :
     119             : #if defined( _WIN32 )
     120             : #elif defined( MACOSX )
     121             : #elif defined( IOS )
     122             : #elif defined( ANDROID )
     123             : #elif defined( UNX )
     124             :         dpy(NULL),
     125             :         screen(0),
     126             :         win(0),
     127             : #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
     128             :         fbc(0),
     129             : #endif
     130             :         vi(NULL),
     131             :         ctx(0),
     132             :         GLXExtensions(NULL),
     133             : #endif
     134             :         bpp(0),
     135             :         Width(0),
     136             :         Height(0),
     137             :         GLExtensions(NULL),
     138           0 :         bMultiSampleSupported(false)
     139             :     {
     140           0 :     }
     141             : };
     142             : 
     143             : class VCLOPENGL_DLLPUBLIC OpenGLContext
     144             : {
     145             : public:
     146             :     OpenGLContext();
     147             :     ~OpenGLContext();
     148             : 
     149             :     bool init(Window* pParent = 0);
     150             :     void setWinSize(const Size& rSize);
     151             :     GLWindow& getOpenGLWindow();
     152             : 
     153             :     void renderToFile();
     154             : 
     155             : private:
     156             :     SAL_DLLPRIVATE bool initWindow();
     157             : 
     158             :     GLWindow m_aGLWin;
     159             :     boost::scoped_ptr<Window> m_pWindow;
     160             :     Window* mpWindow; //points to m_pWindow or the parent window, don't delete it
     161             :     boost::scoped_ptr<SystemChildWindow> m_pChildWindow;
     162             :     bool mbInitialized;
     163             : };
     164             : 
     165             : #endif
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10