2014-03-14 18:51:06 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VCL_OPENGL_CONTEXT_HXX
|
|
|
|
#define VCL_OPENGL_CONTEXT_HXX
|
|
|
|
|
2014-04-08 01:17:16 +02:00
|
|
|
#include <GL/glew.h>
|
|
|
|
|
2014-03-17 05:06:00 +01:00
|
|
|
#if defined( MACOSX )
|
|
|
|
#elif defined( UNX )
|
|
|
|
# include <prex.h>
|
|
|
|
# include "GL/glxew.h"
|
|
|
|
# include <postx.h>
|
|
|
|
#elif defined( _WIN32 )
|
|
|
|
# include "prewin.h"
|
|
|
|
# include "windows.h"
|
|
|
|
# include "postwin.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined( _WIN32 )
|
|
|
|
#include <GL/glext.h>
|
|
|
|
#include <GL/wglext.h>
|
|
|
|
#elif defined( MACOSX )
|
|
|
|
#elif defined( UNX )
|
|
|
|
#include <GL/glext.h>
|
|
|
|
#define GLX_GLXEXT_PROTOTYPES 1
|
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <GL/glxext.h>
|
|
|
|
#endif
|
|
|
|
|
2014-03-14 22:08:15 +01:00
|
|
|
#include <vcl/vclopengl_dllapi.hxx>
|
2014-03-14 23:41:11 +01:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2014-03-17 05:06:00 +01:00
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <tools/gen.hxx>
|
|
|
|
#include <vcl/syschild.hxx>
|
|
|
|
|
|
|
|
/// Holds the information of our new child window
|
|
|
|
struct GLWindow
|
|
|
|
{
|
|
|
|
#if defined( _WIN32 )
|
|
|
|
HWND hWnd;
|
|
|
|
HDC hDC;
|
|
|
|
HGLRC hRC;
|
|
|
|
#elif defined( MACOSX )
|
|
|
|
#elif defined( UNX )
|
|
|
|
Display* dpy;
|
|
|
|
int screen;
|
|
|
|
XLIB_Window win;
|
|
|
|
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
|
|
|
|
GLXFBConfig fbc;
|
|
|
|
#endif
|
|
|
|
XVisualInfo* vi;
|
|
|
|
GLXContext ctx;
|
|
|
|
|
|
|
|
bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); }
|
|
|
|
const char* GLXExtensions;
|
|
|
|
#endif
|
|
|
|
unsigned int bpp;
|
|
|
|
unsigned int Width;
|
|
|
|
unsigned int Height;
|
|
|
|
const GLubyte* GLExtensions;
|
2014-03-17 08:24:14 +01:00
|
|
|
bool bMultiSampleSupported;
|
2014-03-17 05:06:00 +01:00
|
|
|
|
|
|
|
bool HasGLExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, GLExtensions ); }
|
|
|
|
|
|
|
|
GLWindow()
|
|
|
|
:
|
|
|
|
#if defined( _WIN32 )
|
|
|
|
#elif defined( MACOSX )
|
|
|
|
#elif defined( UNX )
|
|
|
|
dpy(NULL),
|
|
|
|
screen(0),
|
|
|
|
win(0),
|
|
|
|
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
|
|
|
|
fbc(0),
|
|
|
|
#endif
|
|
|
|
vi(NULL),
|
|
|
|
ctx(0),
|
|
|
|
GLXExtensions(NULL),
|
|
|
|
#endif
|
|
|
|
bpp(0),
|
|
|
|
Width(0),
|
|
|
|
Height(0),
|
2014-03-17 08:24:14 +01:00
|
|
|
GLExtensions(NULL),
|
|
|
|
bMultiSampleSupported(false)
|
2014-03-17 05:06:00 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2014-03-14 18:51:06 +01:00
|
|
|
|
2014-03-14 22:08:15 +01:00
|
|
|
class VCLOPENGL_DLLPUBLIC OpenGLContext
|
2014-03-14 18:51:06 +01:00
|
|
|
{
|
|
|
|
public:
|
2014-03-15 07:07:08 +01:00
|
|
|
OpenGLContext();
|
|
|
|
~OpenGLContext();
|
|
|
|
|
2014-03-21 14:00:56 +01:00
|
|
|
bool init(Window* pParent = 0);
|
2014-03-14 18:51:06 +01:00
|
|
|
void setWinSize(const Size& rSize);
|
2014-03-17 05:22:33 +01:00
|
|
|
GLWindow& getOpenGLWindow();
|
2014-03-14 18:51:06 +01:00
|
|
|
|
2014-04-08 02:16:08 +02:00
|
|
|
void renderToFile();
|
|
|
|
|
2014-03-14 18:51:06 +01:00
|
|
|
private:
|
|
|
|
SAL_DLLPRIVATE bool initWindow();
|
|
|
|
|
|
|
|
GLWindow m_aGLWin;
|
|
|
|
boost::scoped_ptr<Window> m_pWindow;
|
2014-04-02 03:31:38 +02:00
|
|
|
Window* mpWindow; //points to m_pWindow or the parent window, don't delete it
|
2014-03-14 18:51:06 +01:00
|
|
|
boost::scoped_ptr<SystemChildWindow> m_pChildWindow;
|
2014-04-02 03:31:01 +02:00
|
|
|
bool mbInitialized;
|
2014-03-14 18:51:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|