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"
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2006-11-05 19:57:46 -05:00
|
|
|
#include "wx/msw/wrapwin.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
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGLContext: OpenGL rendering context
|
|
|
|
// ----------------------------------------------------------------------------
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
|
2000-02-28 03:22:57 -05:00
|
|
|
{
|
|
|
|
public:
|
2007-04-10 13:38:55 -04:00
|
|
|
wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxGLContext();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-12-22 10:48:03 -05:00
|
|
|
virtual bool SetCurrent(const wxGLCanvas& win) const;
|
2007-04-10 13:38:55 -04:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGLCanvas: OpenGL output window
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
|
2000-02-28 03:22:57 -05:00
|
|
|
{
|
2003-11-14 07:59:03 -05:00
|
|
|
public:
|
2008-01-31 13:27:50 -05:00
|
|
|
wxEXPLICIT // avoid implicitly converting a wxWindow* to wxGLCanvas
|
2003-11-14 07:59:03 -05:00
|
|
|
wxGLCanvas(wxWindow *parent,
|
2007-04-10 13:38:55 -04:00
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
2003-11-14 07:59:03 -05:00
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxGLCanvas();
|
2003-11-14 07:59:03 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// implement wxGLCanvasBase methods
|
2007-12-22 10:48:03 -05:00
|
|
|
virtual bool SwapBuffers();
|
2003-11-14 07:59:03 -05:00
|
|
|
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// MSW-specific helpers
|
|
|
|
// --------------------
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// get the HDC used for OpenGL rendering
|
|
|
|
HDC GetHDC() const { return m_hDC; }
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// try to find pixel format matching the given attributes list for the
|
|
|
|
// specified HDC, return 0 on error, otherwise pfd is filled in with the
|
|
|
|
// information from attribList if non-NULL
|
|
|
|
static int ChooseMatchingPixelFormat(HDC hdc, const int *attribList,
|
|
|
|
PIXELFORMATDESCRIPTOR *pfd = NULL);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
#if wxUSE_PALETTE
|
|
|
|
// palette stuff
|
|
|
|
bool SetupPalette(const wxPalette& palette);
|
|
|
|
virtual wxPalette CreateDefaultPalette();
|
2003-11-14 07:59:03 -05:00
|
|
|
void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
|
|
|
|
void OnPaletteChanged(wxPaletteChangedEvent& event);
|
2007-04-10 13:38:55 -04:00
|
|
|
#endif // wxUSE_PALETTE
|
2003-09-18 10:03:09 -04:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// deprecated methods using the implicit wxGLContext, associate the context
|
|
|
|
// explicitly with the window instead
|
|
|
|
#if WXWIN_COMPATIBILITY_2_8
|
|
|
|
wxDEPRECATED(
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette)
|
|
|
|
);
|
|
|
|
|
|
|
|
wxDEPRECATED(
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
|
|
|
const wxGLContext *shared,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette)
|
|
|
|
);
|
|
|
|
|
|
|
|
wxDEPRECATED(
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
|
|
|
const wxGLCanvas *shared,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette)
|
|
|
|
);
|
|
|
|
#endif // WXWIN_COMPATIBILITY_2_8
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
protected:
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2008-06-13 21:44:13 -04:00
|
|
|
// the real window creation function, Create() may reuse it twice as we may
|
|
|
|
// need to create an OpenGL window to query the available extensions and
|
|
|
|
// then potentially delete and recreate it with another pixel format
|
|
|
|
bool CreateWindow(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName);
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// set up the pixel format using the given attributes and palette
|
2008-06-13 21:44:13 -04:00
|
|
|
int DoSetup(PIXELFORMATDESCRIPTOR &pfd, const int *attribList);
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// HDC for this window, we keep it all the time
|
|
|
|
HDC m_hDC;
|
2000-02-28 03:22:57 -05:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
#endif // _WX_GLCANVAS_H_
|