]> git.saurik.com Git - wxWidgets.git/blame - utils/glcanvas/src/glcanvas.h
1. wxLoad/SaveFileSelector return "wxString" instead of "char *"
[wxWidgets.git] / utils / glcanvas / src / 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
RR
27
28//---------------------------------------------------------------------------
29// classes
30//---------------------------------------------------------------------------
31
32class wxGLContext;
33class wxGLCanvas;
34
35//---------------------------------------------------------------------------
36// wxGLContext
37//---------------------------------------------------------------------------
38
39
40class wxGLContext: public wxObject
41{
42 DECLARE_CLASS(wxGLContext)
43
44 public:
45
46 wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
47 ~wxGLContext();
48
49 void SetCurrent();
50 void SetColour(const char *colour);
51 void SwapBuffers();
52
53 void SetupPixelFormat();
54 void SetupPalette(const wxPalette& palette);
55 wxPalette CreateDefaultPalette();
56
57 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
58 inline wxWindow* GetWindow() const { return m_window; }
59 inline GtkWidget* GetWidget() const { return m_widget; }
60 inline GLXContext GetContext() const { return m_glContext; }
61
62 public:
63
64 GLXContext m_glContext;
65
66 GtkWidget *m_widget;
67 wxPalette m_palette;
68 wxWindow* m_window;
69};
70
71//---------------------------------------------------------------------------
72// wxGLContext
73//---------------------------------------------------------------------------
74
75class wxGLCanvas: public wxScrolledWindow
76{
77 DECLARE_CLASS(wxGLCanvas)
78
79 public:
aae24d21
RR
80 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize,
83 long style = 0, const wxString& name = "GLCanvas",
84 int *attribList = (int*) NULL,
85 const wxPalette& palette = wxNullPalette );
86
87 bool Create( wxWindow *parent, wxWindowID id = -1,
88 const wxPoint& pos = wxDefaultPosition,
89 const wxSize& size = wxDefaultSize,
90 long style = 0, const wxString& name = "GLCanvas",
91 int *attribList = (int*) NULL,
92 const wxPalette& palette = wxNullPalette );
93
9d3221ab
RR
94 ~wxGLCanvas();
95
96 void SetCurrent();
97 void SetColour(const char *colour);
98 void SwapBuffers();
99
100 void OnSize(wxSizeEvent& event);
101
aae24d21 102 inline wxGLContext* GetContext() const { return m_glContext; }
9d3221ab 103
aae24d21 104 // implementation
9d3221ab 105
aae24d21
RR
106 virtual void SetSize( int x, int y, int width, int height,
107 int sizeFlags = wxSIZE_AUTO );
108 virtual void SetSize( int width, int height );
109
110 virtual GtkWidget *GetConnectWidget();
111 bool IsOwnGtkWindow( GdkWindow *window );
112
113 wxGLContext *m_glContext;
114 GtkWidget *m_glWidget;
9d3221ab
RR
115
116 DECLARE_EVENT_TABLE()
117};
118
119#endif