2000-02-28 03:22:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: glcanvas.h
|
|
|
|
// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif.
|
|
|
|
// Uses the GLX extension.
|
|
|
|
// Author: Julian Smart and Wolfram Gloger
|
|
|
|
// Modified by:
|
|
|
|
// Created: 1995, 1999
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart, Wolfram Gloger
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2003-05-11 13:57:23 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2000-02-28 03:22:57 -05:00
|
|
|
#pragma interface "glcanvas.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WX_GLCANVAS_H_
|
|
|
|
#define _WX_GLCANVAS_H_
|
|
|
|
|
2001-10-21 08:49:22 -04:00
|
|
|
#include "wx/setup.h"
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
#if wxUSE_GLCANVAS
|
|
|
|
|
2001-10-21 08:49:22 -04:00
|
|
|
#include "wx/gdicmn.h"
|
|
|
|
#include "wx/palette.h"
|
|
|
|
#include "wx/scrolwin.h"
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
#include <GL/glx.h>
|
|
|
|
|
2000-07-20 13:31:40 -04:00
|
|
|
enum
|
|
|
|
{
|
2002-02-05 11:34:33 -05:00
|
|
|
WX_GL_RGBA=1, /* use true color palette */
|
|
|
|
WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
|
|
|
|
WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
|
|
|
|
WX_GL_DOUBLEBUFFER, /* use doublebuffer */
|
|
|
|
WX_GL_STEREO, /* use stereoscopic display */
|
|
|
|
WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
|
|
|
|
WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
|
|
|
|
WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
|
|
|
|
WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
|
|
|
|
WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */
|
|
|
|
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
|
|
|
|
WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
|
|
|
|
WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
|
|
|
|
WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
|
|
|
|
WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
|
|
|
|
WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
|
2000-07-20 13:31:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxGLContext: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxGLContext( bool isRGB, wxWindow *win,
|
2002-02-05 11:34:33 -05:00
|
|
|
const wxPalette& palette = wxNullPalette );
|
2000-07-29 23:32:39 -04:00
|
|
|
wxGLContext( bool WXUNUSED(isRGB), wxWindow *win,
|
2002-02-05 11:34:33 -05:00
|
|
|
const wxPalette& WXUNUSED(palette),
|
|
|
|
const wxGLContext *other /* for sharing display lists */
|
|
|
|
);
|
2000-07-29 23:32:39 -04:00
|
|
|
~wxGLContext();
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
void SetCurrent();
|
|
|
|
void SetColour(const char *colour);
|
|
|
|
void SwapBuffers();
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
void SetupPixelFormat();
|
|
|
|
void SetupPalette(const wxPalette& palette);
|
|
|
|
wxPalette CreateDefaultPalette();
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
|
|
|
|
inline wxWindow* GetWindow() const { return m_window; }
|
|
|
|
// inline GtkWidget* GetWidget() const { return m_widget; }
|
|
|
|
inline GLXContext GetContext() const { return m_glContext; }
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
public:
|
2002-02-05 11:34:33 -05:00
|
|
|
GLXContext m_glContext;
|
|
|
|
|
|
|
|
// GtkWidget *m_widget;
|
|
|
|
wxPalette m_palette;
|
|
|
|
wxWindow* m_window;
|
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
DECLARE_CLASS(wxGLContext)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-02-28 03:22:57 -05:00
|
|
|
class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
|
|
|
|
{
|
|
|
|
public:
|
2002-02-05 11:34:33 -05:00
|
|
|
inline wxGLCanvas() {
|
|
|
|
m_glContext = (wxGLContext*) NULL;
|
|
|
|
m_sharedContext = (wxGLContext*) NULL;
|
|
|
|
// m_glWidget = (GtkWidget*) NULL;
|
|
|
|
m_vi = (void*) NULL;
|
|
|
|
// m_exposed = FALSE;
|
|
|
|
}
|
|
|
|
wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
|
2000-07-29 23:32:39 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0, const wxString& name = "GLCanvas",
|
|
|
|
int *attribList = (int*) NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette );
|
2002-02-05 11:34:33 -05:00
|
|
|
wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
|
2000-07-29 23:32:39 -04:00
|
|
|
wxWindowID id = -1,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0, const wxString& name = "GLCanvas",
|
|
|
|
int *attribList = (int*) NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette );
|
2002-02-05 11:34:33 -05:00
|
|
|
wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL,
|
2000-07-29 23:32:39 -04:00
|
|
|
wxWindowID id = -1,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0, const wxString& name = "GLCanvas",
|
|
|
|
int *attribList = (int*) NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette );
|
2002-02-05 11:34:33 -05:00
|
|
|
|
|
|
|
bool Create( wxWindow *parent,
|
|
|
|
const wxGLContext *shared = (wxGLContext*)NULL,
|
|
|
|
const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
|
2000-07-29 23:32:39 -04:00
|
|
|
wxWindowID id = -1,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2002-02-05 11:34:33 -05:00
|
|
|
long style = 0, const wxString& name = "GLCanvas",
|
|
|
|
int *attribList = (int*) NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette );
|
|
|
|
|
|
|
|
~wxGLCanvas();
|
|
|
|
|
|
|
|
void SetCurrent();
|
|
|
|
void SetColour(const char *colour);
|
|
|
|
void SwapBuffers();
|
|
|
|
|
|
|
|
// void OnSize(wxSizeEvent& event);
|
|
|
|
|
|
|
|
// void OnInternalIdle();
|
|
|
|
|
|
|
|
inline wxGLContext* GetContext() const { return m_glContext; }
|
|
|
|
|
|
|
|
// implementation
|
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
wxGLContext *m_glContext,
|
2002-02-05 11:34:33 -05:00
|
|
|
*m_sharedContext;
|
2000-07-29 23:32:39 -04:00
|
|
|
wxGLCanvas *m_sharedContextOf;
|
|
|
|
void *m_vi;
|
|
|
|
// GtkWidget *m_glWidget;
|
|
|
|
// bool m_exposed;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2000-07-29 23:32:39 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
2002-02-05 11:34:33 -05:00
|
|
|
DECLARE_CLASS(wxGLCanvas)
|
|
|
|
|
2000-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2002-02-05 11:34:33 -05:00
|
|
|
// wxUSE_GLCANVAS
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
#endif
|
2002-02-05 11:34:33 -05:00
|
|
|
// _WX_GLCANVAS_H_
|