osx new layout
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55419 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
185
src/osx/glcanvas_osx.cpp
Normal file
185
src/osx/glcanvas_osx.cpp
Normal file
@@ -0,0 +1,185 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/mac/carbon/glcanvas.cpp
|
||||
// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id: glcanvas.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_GLCANVAS
|
||||
|
||||
#include "wx/glcanvas.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/frame.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/settings.h"
|
||||
#endif
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGLCanvas
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other)
|
||||
{
|
||||
m_glContext = WXGLCreateContext(win->GetWXGLPixelFormat(),
|
||||
other ? other->m_glContext : NULL);
|
||||
}
|
||||
|
||||
wxGLContext::~wxGLContext()
|
||||
{
|
||||
if ( m_glContext )
|
||||
{
|
||||
WXGLDestroyContext(m_glContext);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGLCanvas
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
|
||||
EVT_SIZE(wxGLCanvas::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const int *attribList,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const wxPalette& palette)
|
||||
{
|
||||
Create(parent, id, pos, size, style, name, attribList, palette);
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const int *attribList,
|
||||
const wxPalette& palette)
|
||||
{
|
||||
if ( Create(parent, id, pos, size, style, name, attribList, palette) )
|
||||
m_glContext = new wxGLContext(this);
|
||||
}
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||
const wxGLContext *shared,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const int *attribList,
|
||||
const wxPalette& palette)
|
||||
{
|
||||
if ( Create(parent, id, pos, size, style, name, attribList, palette) )
|
||||
m_glContext = new wxGLContext(this, shared);
|
||||
}
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||
const wxGLCanvas *shared,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const int *attribList,
|
||||
const wxPalette& palette)
|
||||
{
|
||||
if ( Create(parent, id, pos, size, style, name, attribList, palette) )
|
||||
m_glContext = new wxGLContext(this, shared ? shared->m_glContext : NULL);
|
||||
}
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_8
|
||||
|
||||
/* static */
|
||||
bool wxGLCanvas::IsAGLMultiSampleAvailable()
|
||||
{
|
||||
static int s_isMultiSampleAvailable = -1;
|
||||
if ( s_isMultiSampleAvailable == -1 )
|
||||
s_isMultiSampleAvailable = IsExtensionSupported("GL_ARB_multisample");
|
||||
|
||||
return s_isMultiSampleAvailable != 0;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool wxGLCanvasBase::IsDisplaySupported(const int *attribList)
|
||||
{
|
||||
WXGLPixelFormat glFormat = WXGLChoosePixelFormat(attribList);
|
||||
|
||||
if ( !glFormat )
|
||||
return false;
|
||||
|
||||
WXGLDestroyPixelFormat(glFormat);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxGLCanvas::SwapBuffers()
|
||||
{
|
||||
WXGLContext context = WXGLGetCurrentContext();
|
||||
wxCHECK_MSG(context, false, _T("should have current context"));
|
||||
|
||||
WXGLSwapBuffers(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxGLCanvasBase::IsExtensionSupported(const char *extension)
|
||||
{
|
||||
// we need a valid context to query for extensions.
|
||||
WXGLPixelFormat fmt = WXGLChoosePixelFormat(NULL);
|
||||
WXGLContext ctx = WXGLCreateContext(fmt, NULL);
|
||||
if ( !ctx )
|
||||
return false;
|
||||
|
||||
wxString extensions = wxString::FromAscii(glGetString(GL_EXTENSIONS));
|
||||
|
||||
WXGLDestroyPixelFormat(fmt);
|
||||
WXGLDestroyContext(ctx);
|
||||
|
||||
return IsExtensionInList(extensions, extension);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGLApp
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxGLApp::InitGLVisual(const int *attribList)
|
||||
{
|
||||
WXGLPixelFormat fmt = WXGLChoosePixelFormat(attribList);
|
||||
if ( !fmt )
|
||||
return false;
|
||||
|
||||
WXGLDestroyPixelFormat(fmt);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // wxUSE_GLCANVAS
|
Reference in New Issue
Block a user