1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/* -*- 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
#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
#include <GL/glew.h>
#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
#include <vcl/vclopengl_dllapi.hxx>
#include <boost/scoped_ptr.hpp>
#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;
bool bMultiSampleSupported;
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),
GLExtensions(NULL),
bMultiSampleSupported(false)
{
}
};
class VCLOPENGL_DLLPUBLIC OpenGLContext
{
public:
OpenGLContext();
~OpenGLContext();
bool init();
void setWinSize(const Size& rSize);
GLWindow& getOpenGLWindow();
private:
SAL_DLLPRIVATE bool initWindow();
GLWindow m_aGLWin;
boost::scoped_ptr<Window> m_pWindow;
boost::scoped_ptr<SystemChildWindow> m_pChildWindow;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|