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