applied (slightly modified) wxGLApp patch for MSW
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11717 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a6f5aa49cf
commit
a308135449
@ -1,6 +1,10 @@
|
||||
#ifndef _WX_GLCANVAS_H_BASE_
|
||||
#define _WX_GLCANVAS_H_BASE_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_GLCANVAS
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/glcanvas.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
@ -15,5 +19,22 @@
|
||||
#include "wx/stubs/glcanvas.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxGLApp : public wxApp
|
||||
{
|
||||
public:
|
||||
wxGLApp() : wxApp() { }
|
||||
virtual ~wxGLApp();
|
||||
|
||||
// use this in the constructor of the user-derived wxGLApp class to
|
||||
// determine if an OpenGL rendering context with these attributes
|
||||
// is available - returns TRUE if so, FALSE if not.
|
||||
bool InitGLVisual(int *attribList);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxGLApp)
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_GLCANVAS
|
||||
#endif
|
||||
// _WX_GLCANVAS_H_BASE_
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef _WX_GLCANVAS_H_
|
||||
#define _WX_GLCANVAS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_GLCANVAS
|
||||
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/app.h"
|
||||
|
||||
@ -178,30 +174,6 @@ private:
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGLApp
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxGLApp: public wxApp
|
||||
{
|
||||
public:
|
||||
wxGLApp() : wxApp() { }
|
||||
~wxGLApp();
|
||||
|
||||
// use this in the constructor of the user-derived wxGLApp class to select
|
||||
// an appropriate X visual for GL. Returns TRUE if an appropriate visual
|
||||
// is found - and sets m_glVisualInfo; FALSE otherwise.
|
||||
bool InitGLVisual(int *attribList);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxGLApp)
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
// wxUSE_GLCANVAS
|
||||
|
||||
#endif
|
||||
// _WX_GLCANVAS_H_
|
||||
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef _WX_GLCANVAS_H_
|
||||
#define _WX_GLCANVAS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_GLCANVAS
|
||||
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/app.h"
|
||||
|
||||
@ -178,30 +174,6 @@ private:
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGLApp
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxGLApp: public wxApp
|
||||
{
|
||||
public:
|
||||
wxGLApp() : wxApp() { }
|
||||
~wxGLApp();
|
||||
|
||||
// use this in the constructor of the user-derived wxGLApp class to select
|
||||
// an appropriate X visual for GL. Returns TRUE if an appropriate visual
|
||||
// is found - and sets m_glVisualInfo; FALSE otherwise.
|
||||
bool InitGLVisual(int *attribList);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxGLApp)
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
// wxUSE_GLCANVAS
|
||||
|
||||
#endif
|
||||
// _WX_GLCANVAS_H_
|
||||
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef _WX_GLCANVAS_H_
|
||||
#define _WX_GLCANVAS_H_
|
||||
|
||||
#include <wx/setup.h>
|
||||
|
||||
#if wxUSE_GLCANVAS
|
||||
|
||||
#include <wx/palette.h>
|
||||
#include <wx/scrolwin.h>
|
||||
|
||||
@ -128,11 +124,9 @@ protected:
|
||||
wxPalette m_palette;
|
||||
WXHDC m_hDC;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_GLCANVAS
|
||||
#endif
|
||||
// _WX_GLCANVAS_H_
|
||||
|
||||
|
@ -334,30 +334,8 @@ bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
|
||||
static void AdjustPFDForAttributes(PIXELFORMATDESCRIPTOR& pfd, int *attribList)
|
||||
{
|
||||
int pixelFormat;
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), /* size */
|
||||
1, /* version */
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_DOUBLEBUFFER, /* support double-buffering */
|
||||
PFD_TYPE_RGBA, /* color type */
|
||||
16, /* prefered color depth */
|
||||
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
|
||||
0, /* no alpha buffer */
|
||||
0, /* alpha bits (ignored) */
|
||||
0, /* no accumulation buffer */
|
||||
0, 0, 0, 0, /* accum bits (ignored) */
|
||||
16, /* depth buffer */
|
||||
0, /* no stencil buffer */
|
||||
0, /* no auxiliary buffers */
|
||||
PFD_MAIN_PLANE, /* main layer */
|
||||
0, /* reserved */
|
||||
0, 0, 0, /* no layer, visible, damage masks */
|
||||
};
|
||||
|
||||
if (attribList) {
|
||||
pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_COLORINDEX;
|
||||
@ -430,17 +408,42 @@ void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
|
||||
{
|
||||
int pixelFormat;
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), /* size */
|
||||
1, /* version */
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_DOUBLEBUFFER, /* support double-buffering */
|
||||
PFD_TYPE_RGBA, /* color type */
|
||||
16, /* prefered color depth */
|
||||
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
|
||||
0, /* no alpha buffer */
|
||||
0, /* alpha bits (ignored) */
|
||||
0, /* no accumulation buffer */
|
||||
0, 0, 0, 0, /* accum bits (ignored) */
|
||||
16, /* depth buffer */
|
||||
0, /* no stencil buffer */
|
||||
0, /* no auxiliary buffers */
|
||||
PFD_MAIN_PLANE, /* main layer */
|
||||
0, /* reserved */
|
||||
0, 0, 0, /* no layer, visible, damage masks */
|
||||
};
|
||||
|
||||
AdjustPFDForAttributes(pfd, attribList);
|
||||
|
||||
pixelFormat = ChoosePixelFormat((HDC) m_hDC, &pfd);
|
||||
if (pixelFormat == 0) {
|
||||
MessageBox(WindowFromDC((HDC) m_hDC), wxT("ChoosePixelFormat failed."), wxT("Error"),
|
||||
MB_ICONERROR | MB_OK);
|
||||
exit(1);
|
||||
wxLogWarning(_("ChoosePixelFormat failed."));
|
||||
}
|
||||
|
||||
if (SetPixelFormat((HDC) m_hDC, pixelFormat, &pfd) != TRUE) {
|
||||
MessageBox(WindowFromDC((HDC) m_hDC), wxT("SetPixelFormat failed."), wxT("Error"),
|
||||
MB_ICONERROR | MB_OK);
|
||||
exit(1);
|
||||
else {
|
||||
if (SetPixelFormat((HDC) m_hDC, pixelFormat, &pfd) != TRUE) {
|
||||
wxLogWarning(_("SetPixelFormat failed."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,5 +716,53 @@ void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGLApp
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxGLApp, wxApp)
|
||||
|
||||
bool wxGLApp::InitGLVisual(int *attribList)
|
||||
{
|
||||
int pixelFormat;
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), /* size */
|
||||
1, /* version */
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_DOUBLEBUFFER, /* support double-buffering */
|
||||
PFD_TYPE_RGBA, /* color type */
|
||||
16, /* prefered color depth */
|
||||
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
|
||||
0, /* no alpha buffer */
|
||||
0, /* alpha bits (ignored) */
|
||||
0, /* no accumulation buffer */
|
||||
0, 0, 0, 0, /* accum bits (ignored) */
|
||||
16, /* depth buffer */
|
||||
0, /* no stencil buffer */
|
||||
0, /* no auxiliary buffers */
|
||||
PFD_MAIN_PLANE, /* main layer */
|
||||
0, /* reserved */
|
||||
0, 0, 0, /* no layer, visible, damage masks */
|
||||
};
|
||||
|
||||
AdjustPFDForAttributes(pfd, attribList);
|
||||
|
||||
// use DC for whole (root) screen, since no windows have yet been created
|
||||
pixelFormat = ChoosePixelFormat((HDC) ::GetDC(NULL), &pfd);
|
||||
|
||||
if (pixelFormat == 0) {
|
||||
wxLogError(_("Failed to initialize OpenGL"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxGLApp::~wxGLApp()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
// wxUSE_GLCANVAS
|
||||
|
Loading…
Reference in New Issue
Block a user