]> git.saurik.com Git - wxWidgets.git/blame - utils/glcanvas/gtk/glcanvas.h
1. fixed small bug with toolbar size updates
[wxWidgets.git] / utils / glcanvas / gtk / glcanvas.h
CommitLineData
9d3221ab
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: glcanvas.h
3// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
4// Author: Robert Roebling
5// Modified by:
6// Created: 17/8/98
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma interface "glcanvas.h"
14#endif
15
16#ifndef _WX_GLCANVAS_H_
17#define _WX_GLCANVAS_H_
18
19#include "wx/defs.h"
20#include "wx/scrolwin.h"
21
aae24d21 22extern "C" {
9d3221ab
RR
23#include "GL/gl.h"
24#include "GL/glx.h"
25#include "GL/glu.h"
aae24d21 26}
9d3221ab 27
089e55d6
RR
28//---------------------------------------------------------------------------
29// Constants for attriblist
30//---------------------------------------------------------------------------
31
32enum
33{
34 WX_GL_RGBA=1, /* use true color palette */
35 WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
36 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
37 WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
38 WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
39 WX_GL_MIN_BLUE /* use blue buffer with most bits (> MIN_BLUE bits) */
40/* these are enough constants for now, the remaining will be added later */
41};
42
9d3221ab
RR
43//---------------------------------------------------------------------------
44// classes
45//---------------------------------------------------------------------------
46
47class wxGLContext;
48class wxGLCanvas;
49
50//---------------------------------------------------------------------------
51// wxGLContext
52//---------------------------------------------------------------------------
53
54
55class wxGLContext: public wxObject
56{
5fd11f09 57public:
9d3221ab 58 wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
089e55d6
RR
59 wxGLContext(
60 bool WXUNUSED(isRGB), wxWindow *win,
61 const wxPalette& WXUNUSED(palette),
62 const wxGLContext *other /* for sharing display lists */
63 );
9d3221ab
RR
64 ~wxGLContext();
65
66 void SetCurrent();
67 void SetColour(const char *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
5fd11f09 79public:
9d3221ab
RR
80 GLXContext m_glContext;
81
82 GtkWidget *m_widget;
83 wxPalette m_palette;
84 wxWindow* m_window;
5fd11f09
RR
85
86private:
87 DECLARE_CLASS(wxGLContext)
9d3221ab
RR
88};
89
90//---------------------------------------------------------------------------
91// wxGLContext
92//---------------------------------------------------------------------------
93
94class wxGLCanvas: public wxScrolledWindow
95{
5fd11f09 96public:
aae24d21
RR
97 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
98 const wxPoint& pos = wxDefaultPosition,
99 const wxSize& size = wxDefaultSize,
089e55d6
RR
100 long style = 0, const wxString& name = "GLCanvas",
101 int *attribList = (int*) NULL,
102 const wxPalette& palette = wxNullPalette );
103 wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
104 wxWindowID id = -1,
105 const wxPoint& pos = wxDefaultPosition,
106 const wxSize& size = wxDefaultSize,
107 long style = 0, const wxString& name = "GLCanvas",
108 int *attribList = (int*) NULL,
109 const wxPalette& palette = wxNullPalette );
110
9434fb90
JS
111 inline wxGLCanvas() {
112 m_glContext = (wxGLContext*) NULL;
113 m_sharedContext = (wxGLContext*) NULL;
114 m_glWidget = (GtkWidget*) NULL;
115 m_vi = (void*) NULL;
116 m_exposed = FALSE;
117 }
118
089e55d6
RR
119 bool Create( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
120 wxWindowID id = -1,
aae24d21
RR
121 const wxPoint& pos = wxDefaultPosition,
122 const wxSize& size = wxDefaultSize,
123 long style = 0, const wxString& name = "GLCanvas",
124 int *attribList = (int*) NULL,
125 const wxPalette& palette = wxNullPalette );
126
9d3221ab
RR
127 ~wxGLCanvas();
128
129 void SetCurrent();
130 void SetColour(const char *colour);
131 void SwapBuffers();
132
133 void OnSize(wxSizeEvent& event);
147bc491
RR
134
135 void OnInternalIdle();
9d3221ab 136
aae24d21 137 inline wxGLContext* GetContext() const { return m_glContext; }
9d3221ab 138
aae24d21 139 // implementation
9d3221ab 140
147bc491
RR
141 wxGLContext *m_glContext,
142 *m_sharedContext;
4b59bea3 143 void *m_vi;
aae24d21 144 GtkWidget *m_glWidget;
147bc491 145 bool m_exposed;
9d3221ab 146
5fd11f09
RR
147private:
148 DECLARE_EVENT_TABLE()
149 DECLARE_CLASS(wxGLCanvas)
9d3221ab
RR
150};
151
152#endif