2000-02-28 03:22:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2002-05-22 11:56:38 -04:00
|
|
|
// Name: wx/msw/glcanvas.h
|
2004-05-23 10:56:36 -04:00
|
|
|
// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Windows
|
2000-02-28 03:22:57 -05:00
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2000-02-28 03:22:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-07-25 12:36:51 -04:00
|
|
|
#ifndef _WX_GLCANVAS_H_
|
|
|
|
#define _WX_GLCANVAS_H_
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
#include "wx/palette.h"
|
|
|
|
#include "wx/scrolwin.h"
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
#include <windows.h>
|
2002-12-04 09:11:26 -05:00
|
|
|
#include "wx/msw/winundef.h"
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2002-05-22 11:56:38 -04:00
|
|
|
#include <GL/gl.h>
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Constants for attriblist
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2000-07-20 13:31:40 -04:00
|
|
|
// The generic GL implementation doesn't support most of these options,
|
|
|
|
// such as stereo, auxiliary buffers, alpha channel, and accum buffer.
|
|
|
|
// Other implementations may actually support them.
|
|
|
|
|
2000-02-28 03:22:57 -05:00
|
|
|
enum
|
|
|
|
{
|
2003-11-14 07:59:03 -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-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
2003-07-17 04:31:33 -04:00
|
|
|
class WXDLLIMPEXP_GL wxGLCanvas; /* forward reference */
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-07-17 04:31:33 -04:00
|
|
|
class WXDLLIMPEXP_GL wxGLContext: public wxObject
|
2000-02-28 03:22:57 -05:00
|
|
|
{
|
|
|
|
public:
|
2006-09-06 09:31:20 -04:00
|
|
|
wxGLContext(wxGLCanvas *win, const wxGLContext* other=NULL /* for sharing display lists */ );
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxGLContext();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
inline HGLRC GetGLRC() const { return m_glContext; }
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2006-09-06 09:31:20 -04:00
|
|
|
protected:
|
|
|
|
HGLRC m_glContext;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_CLASS(wxGLContext)
|
2000-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
2003-07-17 04:31:33 -04:00
|
|
|
class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow
|
2000-02-28 03:22:57 -05:00
|
|
|
{
|
2003-11-14 07:59:03 -05:00
|
|
|
public:
|
2006-09-06 09:31:20 -04:00
|
|
|
// This ctor is identical to the next, except for the fact that it
|
|
|
|
// doesn't create an implicit wxGLContext.
|
|
|
|
// The attribList parameter has been moved to avoid overload clashes.
|
|
|
|
wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
|
|
|
|
int* attribList = 0,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
2000-02-28 03:22:57 -05:00
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2003-11-14 07:59:03 -05:00
|
|
|
const wxString& name = wxGLCanvasName, int *attribList = 0,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
2005-02-20 20:52:23 -05:00
|
|
|
const wxGLContext *shared,
|
2003-11-14 07:59:03 -05:00
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
int *attribList = (int *) NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
2005-02-20 20:52:23 -05:00
|
|
|
const wxGLCanvas *shared,
|
2003-11-14 07:59:03 -05:00
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
int *attribList = 0,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxGLCanvas();
|
2003-11-14 07:59:03 -05:00
|
|
|
|
|
|
|
// Replaces wxWindow::Create functionality, since
|
|
|
|
// we need to use a different window class
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
long style, const wxString& name);
|
|
|
|
|
2006-09-06 09:31:20 -04:00
|
|
|
void SetCurrent(const wxGLContext& RC) const;
|
2003-11-14 07:59:03 -05:00
|
|
|
void SetCurrent();
|
|
|
|
|
|
|
|
#ifdef __WXUNIVERSAL__
|
|
|
|
virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); };
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void SetColour(const wxChar *colour);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
void SwapBuffers();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
void OnSize(wxSizeEvent& event);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
void OnPaletteChanged(wxPaletteChangedEvent& event);
|
2003-09-18 10:03:09 -04:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
inline wxGLContext* GetContext() const { return m_glContext; }
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
inline WXHDC GetHDC() const { return m_hDC; }
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
void SetupPixelFormat(int *attribList = (int *) NULL);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
void SetupPalette(const wxPalette& palette);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
wxPalette CreateDefaultPalette();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2003-11-14 07:59:03 -05:00
|
|
|
inline wxPalette* GetPalette() const { return (wxPalette *) &m_palette; }
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
|
|
|
|
wxPalette m_palette;
|
|
|
|
WXHDC m_hDC;
|
|
|
|
|
2006-09-06 09:31:20 -04:00
|
|
|
private:
|
2001-09-28 10:01:34 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
2006-09-06 09:31:20 -04:00
|
|
|
DECLARE_CLASS(wxGLCanvas)
|
2000-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_GLCANVAS_H_
|
|
|
|
|