]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/x11/glcanvas.h
Make wxABI_VERSION default be e.g. 20699
[wxWidgets.git] / include / wx / x11 / glcanvas.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: glcanvas.h
3// Purpose: wxGLCanvas, for using OpenGL with wxWidgets 2.0 for Motif.
4// Uses the GLX extension.
5// Author: Julian Smart and Wolfram Gloger
6// Modified by:
7// Created: 1995, 1999
8// RCS-ID: $Id$
9// Copyright: (c) Julian Smart, Wolfram Gloger
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef _WX_GLCANVAS_H_
14#define _WX_GLCANVAS_H_
15
16#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
17#pragma interface "glcanvas.h"
18#endif
19
20#include "wx/setup.h"
21
22#if wxUSE_GLCANVAS
23
24#include "wx/gdicmn.h"
25#include "wx/palette.h"
26#include "wx/scrolwin.h"
27
28#include <GL/glx.h>
29
30enum
31{
32 WX_GL_RGBA=1, /* use true color palette */
33 WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
34 WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
35 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
36 WX_GL_STEREO, /* use stereoscopic display */
37 WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
38 WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
39 WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
40 WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
41 WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */
42 WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
43 WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
44 WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
45 WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
46 WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
47 WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
48};
49
50//---------------------------------------------------------------------------
51// classes
52//---------------------------------------------------------------------------
53
54
55class WXDLLEXPORT wxGLContext: public wxObject
56{
57public:
58 wxGLContext( bool isRGB, wxWindow *win,
59 const wxPalette& palette = wxNullPalette );
60 wxGLContext( bool WXUNUSED(isRGB), wxWindow *win,
61 const wxPalette& WXUNUSED(palette),
62 const wxGLContext *other /* for sharing display lists */
63 );
64 ~wxGLContext();
65
66 void SetCurrent();
67 void SetColour(const wxChar *colour);
68 void SwapBuffers();
69
70 void SetupPixelFormat();
71 void SetupPalette(const wxPalette& palette);
72 wxPalette CreateDefaultPalette();
73
74 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
75 inline wxWindow* GetWindow() const { return m_window; }
76 // inline GtkWidget* GetWidget() const { return m_widget; }
77 inline GLXContext GetContext() const { return m_glContext; }
78
79public:
80 GLXContext m_glContext;
81
82 // GtkWidget *m_widget;
83 wxPalette m_palette;
84 wxWindow* m_window;
85
86 DECLARE_CLASS(wxGLContext)
87};
88
89
90class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
91{
92public:
93 inline wxGLCanvas() {
94 m_glContext = (wxGLContext*) NULL;
95 m_sharedContext = (wxGLContext*) NULL;
96 // m_glWidget = (GtkWidget*) NULL;
97 m_vi = (void*) NULL;
98 // m_exposed = FALSE;
99 }
100 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
101 const wxPoint& pos = wxDefaultPosition,
102 const wxSize& size = wxDefaultSize,
103 long style = 0, const wxString& name = wxT("GLCanvas"),
104 int *attribList = (int*) NULL,
105 const wxPalette& palette = wxNullPalette );
106 wxGLCanvas( wxWindow *parent, const wxGLContext *shared,
107 wxWindowID id = -1,
108 const wxPoint& pos = wxDefaultPosition,
109 const wxSize& size = wxDefaultSize,
110 long style = 0, const wxString& name = wxT("GLCanvas"),
111 int *attribList = (int*) NULL,
112 const wxPalette& palette = wxNullPalette );
113 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared,
114 wxWindowID id = -1,
115 const wxPoint& pos = wxDefaultPosition,
116 const wxSize& size = wxDefaultSize,
117 long style = 0, const wxString& name = wxT("GLCanvas"),
118 int *attribList = (int*) NULL,
119 const wxPalette& palette = wxNullPalette );
120
121 bool Create( wxWindow *parent,
122 const wxGLContext *shared = (wxGLContext*)NULL,
123 const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
124 wxWindowID id = -1,
125 const wxPoint& pos = wxDefaultPosition,
126 const wxSize& size = wxDefaultSize,
127 long style = 0, const wxString& name = wxT("GLCanvas"),
128 int *attribList = (int*) NULL,
129 const wxPalette& palette = wxNullPalette );
130
131 ~wxGLCanvas();
132
133 void SetCurrent();
134 void SetColour(const wxChar *colour);
135 void SwapBuffers();
136
137 // void OnSize(wxSizeEvent& event);
138
139 // void OnInternalIdle();
140
141 inline wxGLContext* GetContext() const { return m_glContext; }
142
143 // implementation
144
145 wxGLContext *m_glContext,
146 *m_sharedContext;
147 wxGLCanvas *m_sharedContextOf;
148 void *m_vi;
149 // GtkWidget *m_glWidget;
150 // bool m_exposed;
151
152 DECLARE_EVENT_TABLE()
153 DECLARE_CLASS(wxGLCanvas)
154
155};
156
157#endif
158// wxUSE_GLCANVAS
159
160#endif
161// _WX_GLCANVAS_H_