Functional .. OSX mouse, gl, keyboard and window wrappers....

This commit is contained in:
Roger Hughston 2006-03-09 20:23:54 +00:00
parent 5f0febd8e8
commit 0752ccb35e
11 changed files with 2063 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#define BUILD_DIRECTORY $[IS_OSX]]
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
dtoolutil:c dtoolbase:c dtool:m prc:c
#define OSX_SYS_FRAMEWORKS ApplicationServices Carbon AGL CoreServices
#define USE_PACKAGES gl cggl
#begin lib_target
#define TARGET osxdisplay
#define LOCAL_LIBS \
display putil glgsg
#define INSTALL_HEADERS \
config_osxdisplay.h \
osxGraphicsPipe.h \
osxGraphicsWindow.h \
osxGraphicsStateGuardian.h
#define INCLUDED_SOURCES \
config_osxdisplay.cxx osxGraphicsPipe.cxx osxGraphicsWindow.cxx osxGraphicsStateGuardian.cxx osxGraphicsBuffer.cxx
#define SOURCES \
osxDisplay.xx $[INCLUDED_SOURCES] $[INSTALL_HEADERS]
#end lib_target

View File

@ -0,0 +1,76 @@
// Filename: config_glxdisplay.cxx
// Created by: cary (07Oct99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include <Carbon/Carbon.h>
#include "config_osxdisplay.h"
#include "osxGraphicsBuffer.h"
#include "osxGraphicsPipe.h"
#include "osxGraphicsStateGuardian.h"
#include "osxGraphicsWindow.h"
#include "graphicsPipeSelection.h"
#include "dconfig.h"
#include "pandaSystem.h"
Configure(config_osxdisplay);
NotifyCategoryDef( osxdisplay , "display");
ConfigureFn(config_osxdisplay) {
init_libosxdisplay();
}
ConfigVariableString display_cfg
("display", "");
////////////////////////////////////////////////////////////////////
// Function: init_libosxdisplay
// Description: Initializes the library. This must be called at
// least once before any of the functions or classes in
// this library can be used. Normally it will be
// called by the static initializers and need not be
// called explicitly, but special cases exist.
////////////////////////////////////////////////////////////////////
void
init_libosxdisplay() {
static bool initialized = false;
if (initialized) {
return;
}
initialized = true;
printf("****** In libosx init \n");
osxGraphicsStateGuardian::init_type();
osxGraphicsPipe::init_type();
osxGraphicsWindow::init_type();
osxGraphicsStateGuardian::init_type();
GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
selection->add_pipe_type(osxGraphicsPipe::get_class_type(), osxGraphicsPipe::pipe_constructor);
PandaSystem *ps = PandaSystem::get_global_ptr();
ps->set_system_tag("OpenGL", "window_system", "OSX");
printf("****** out libosx init \n");
}

View File

@ -0,0 +1,31 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef __CONFIG_OSXDISPLAY_H__
#define __CONFIG_OSXDISPLAY_H__
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include "configVariableString.h"
#include "configVariableBool.h"
NotifyCategoryDecl( osxdisplay , EXPCL_PANDAGL, EXPTP_PANDAGL);
extern EXPCL_PANDAGL void init_libosxdisplay();
extern ConfigVariableString display_cfg;
extern ConfigVariableBool osx_error_abort;
#endif /* __CONFIG_OSXDISPLAY_H__ */

View File

@ -0,0 +1,156 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include "osxGraphicsBuffer.h"
#include "osxGraphicsStateGuardian.h"
#include "config_osxdisplay.h"
#include "osxGraphicsPipe.h"
#include "graphicsPipe.h"
#include "glgsg.h"
#include "pStatTimer.h"
TypeHandle osxGraphicsBuffer::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsBuffer::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
osxGraphicsBuffer::
osxGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
const string &name,
int x_size, int y_size) :
GraphicsBuffer(pipe, gsg, name, x_size, y_size)
{
osxGraphicsPipe *osx_pipe;
DCAST_INTO_V(osx_pipe, _pipe);
// Since the pbuffer never gets flipped, we get screenshots from the
// same buffer we draw into.
_screenshot_buffer_type = _draw_buffer_type;
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsBuffer::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
osxGraphicsBuffer::
~osxGraphicsBuffer() {
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsBuffer::begin_frame
// Access: Public, Virtual
// Description: This function will be called within the draw thread
// before beginning rendering for a given frame. It
// should do whatever setup is required, and return true
// if the frame should be rendered, or false if it
// should be skipped.
////////////////////////////////////////////////////////////////////
bool osxGraphicsBuffer::
begin_frame(FrameMode mode) {
PStatTimer timer(_make_current_pcollector);
begin_frame_spam();
if (_gsg == (GraphicsStateGuardian *)NULL) {
return false;
}
osxGraphicsStateGuardian *osxgsg;
DCAST_INTO_R(osxgsg, _gsg, false);
// osxMakeCurrent(_display, _pbuffer, osxgsg->_context);
// Now that we have made the context current to a window, we can
// reset the GSG state if this is the first time it has been used.
// (We can't just call reset() when we construct the GSG, because
// reset() requires having a current context.)
osxgsg->reset_if_new();
if (mode == FM_render) {
// begin_render_texture();
clear_cube_map_selection();
}
return _gsg->begin_frame();
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsBuffer::end_frame
// Access: Public, Virtual
// Description: This function will be called within the draw thread
// after rendering is completed for a given frame. It
// should do whatever finalization is required.
////////////////////////////////////////////////////////////////////
void osxGraphicsBuffer::
end_frame(FrameMode mode) {
end_frame_spam();
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
if (mode == FM_render) {
// end_render_texture();
copy_to_textures();
}
_gsg->end_frame();
if (mode == FM_render) {
trigger_flip();
if (_one_shot) {
prepare_for_deletion();
}
clear_cube_map_selection();
}
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsBuffer::release_gsg
// Access: Public
// Description: Releases the current GSG pointer, if it is currently
// held, and resets the GSG to NULL. The window will be
// permanently unable to render; this is normally called
// only just before destroying the window. This should
// only be called from within the draw thread.
////////////////////////////////////////////////////////////////////
void osxGraphicsBuffer::
release_gsg() {
//osxMakeCurrent(_display, None, NULL);
GraphicsBuffer::release_gsg();
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsBuffer::close_buffer
// Access: Protected, Virtual
// Description: Closes the buffer right now. Called from the window
// thread.
////////////////////////////////////////////////////////////////////
void osxGraphicsBuffer::
close_buffer() {
// _is_valid = false;
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsBuffer::open_buffer
// Access: Protected, Virtual
// Description: Opens the buffer right now. Called from the window
// thread. Returns true if the buffer is successfully
// opened, or false if there was a problem.
////////////////////////////////////////////////////////////////////
bool osxGraphicsBuffer::
open_buffer() {
return false;
}

View File

@ -0,0 +1,81 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef OSXGRAPHICSBUFFER_H
#define OSXGRAPHICSBUFFER_H
#include <Carbon/Carbon.h>
#define __glext_h_
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <AGL/agl.h>
#include "pandabase.h"
#include "graphicsBuffer.h"
#include "glgsg.h"
// This must be included after we have included glgsg.h (which
// includes gl.h).
//#include "wglext.h"
//#include <windows.h>
////////////////////////////////////////////////////////////////////
// Class : OSXGraphicsBuffer
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAGL osxGraphicsBuffer : public GraphicsBuffer {
public:
osxGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
const string &name,
int x_size, int y_size);
virtual ~osxGraphicsBuffer();
virtual bool begin_frame(FrameMode mode);
virtual void end_frame(FrameMode mode);
virtual void release_gsg();
// virtual void begin_render_texture();
// virtual void end_render_texture();
protected:
virtual void close_buffer();
virtual bool open_buffer();
private:
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
GraphicsBuffer::init_type();
register_type(_type_handle, "owsGraphicsBuffer",
GraphicsBuffer::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
friend class osxGraphicsStateGuardian;
};
#endif

View File

@ -0,0 +1,133 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include "osxGraphicsPipe.h"
#include "config_osxdisplay.h"
#include "osxGraphicsWindow.h"
#include "osxGraphicsBuffer.h"
#include "osxGraphicsStateGuardian.h"
//typedef enum {Software, MCD, ICD} OGLDriverType;
TypeHandle osxGraphicsPipe::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsPipe::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
osxGraphicsPipe::
osxGraphicsPipe() {
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsPipe::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
osxGraphicsPipe::
~osxGraphicsPipe() {
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsPipe::get_interface_name
// Access: Published, Virtual
// Description: Returns the name of the rendering interface
// associated with this GraphicsPipe. This is used to
// present to the user to allow him/her to choose
// between several possible GraphicsPipes available on a
// particular platform, so the name should be meaningful
// and unique for a given platform.
////////////////////////////////////////////////////////////////////
string osxGraphicsPipe::
get_interface_name() const {
return "OpenGL";
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsPipe::pipe_constructor
// Access: Public, Static
// Description: This function is passed to the GraphicsPipeSelection
// object to allow the user to make a default
// osxGraphicsPipe.
////////////////////////////////////////////////////////////////////
PT(GraphicsPipe) osxGraphicsPipe::
pipe_constructor() {
return new osxGraphicsPipe;
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsPipe::make_gsg
// Access: Protected, Virtual
// Description: Creates a new GSG to use the pipe (but no windows
// have been created yet for the GSG). This method will
// be called in the draw thread for the GSG.
////////////////////////////////////////////////////////////////////
PT(GraphicsStateGuardian) osxGraphicsPipe::
make_gsg(const FrameBufferProperties &properties,
GraphicsStateGuardian *share_with) {
if (!_is_valid) {
return NULL;
}
osxGraphicsStateGuardian *share_gsg = NULL;
if (share_with != (GraphicsStateGuardian *)NULL) {
if (!share_with->is_exact_type(osxGraphicsStateGuardian::get_class_type()))
{
osxdisplay_cat.error()
<< "Cannot share context between osxGraphicsStateGuardian and "
<< share_with->get_type() << "\n";
return NULL;
}
DCAST_INTO_R(share_gsg, share_with, NULL);
}
int frame_buffer_mode = 0;
if (properties.has_frame_buffer_mode()) {
frame_buffer_mode = properties.get_frame_buffer_mode();
}
PT(osxGraphicsStateGuardian) gsg1 = new osxGraphicsStateGuardian(properties,(osxGraphicsStateGuardian *) share_with, 1);
return gsg1.p();
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsPipe::make_window
// Access: Protected, Virtual
// Description: Creates a new window on the pipe, if possible.
////////////////////////////////////////////////////////////////////
PT(GraphicsWindow) osxGraphicsPipe::
make_window(GraphicsStateGuardian *gsg, const string &name) {
return new osxGraphicsWindow(this, gsg, name);
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsPipe::make_buffer
// Access: Protected, Virtual
// Description: Creates a new offscreen buffer on the pipe, if possible.
////////////////////////////////////////////////////////////////////
PT(GraphicsBuffer) osxGraphicsPipe::
make_buffer(GraphicsStateGuardian *gsg, const string &name,
int x_size, int y_size) {
return new osxGraphicsBuffer(this, gsg, name, x_size, y_size);
}

View File

@ -0,0 +1,69 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef OSXGRAPHICSPIPE_H
#define OSXGRAPHICSPIPE_H
#include "pandabase.h"
#include "graphicspipe.h"
class osxGraphicsStateGuardian;
////////////////////////////////////////////////////////////////////
// Class : osxGraphicsPipe
// Description : This graphics pipe represents the interface for
// creating OpenGL graphics windows on the various
// OSX's.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAGL osxGraphicsPipe : public GraphicsPipe {
public:
osxGraphicsPipe();
virtual ~osxGraphicsPipe();
virtual string get_interface_name() const;
static PT(GraphicsPipe) pipe_constructor();
protected:
virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties,
GraphicsStateGuardian *share_with);
virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg,
const string &name);
virtual PT(GraphicsBuffer) make_buffer(GraphicsStateGuardian *gsg,
const string &name,
int x_size, int y_size);
private:
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
GraphicsPipe::init_type();
register_type(_type_handle, "osxGraphicsPipe",
GraphicsPipe::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
friend class osxGraphicsBuffer;
};
//#include "osxGraphicsPipe.I"
#endif

View File

@ -0,0 +1,134 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include "osxGraphicsStateGuardian.h"
#include "osxGraphicsBuffer.h"
#include "string_utils.h"
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#import <mach-o/dyld.h>
TypeHandle osxGraphicsStateGuardian::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::get_extension_func
// Access: Public, Virtual
// Description: Returns the pointer to the GL extension function with
// the indicated name. It is the responsibility of the
// caller to ensure that the required extension is
// defined in the OpenGL runtime prior to calling this;
// it is an error to call this for a function that is
// not defined.
////////////////////////////////////////////////////////////////////
void *osxGraphicsStateGuardian::get_extension_func(const char *prefix, const char *name)
{
string fullname = "_" + string(prefix) + string(name);
NSSymbol symbol = NULL;
if (NSIsSymbolNameDefined (fullname.c_str()))
symbol = NSLookupAndBindSymbol (fullname.c_str());
return symbol ? NSAddressOfSymbol (symbol) : NULL;
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
osxGraphicsStateGuardian::
osxGraphicsStateGuardian(const FrameBufferProperties &properties,
osxGraphicsStateGuardian *share_with,
int pfnum) :
GLGraphicsStateGuardian(properties),
_share_with(share_with),
_aglPixFmt(NULL),
_aglcontext(NULL)
{
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
osxGraphicsStateGuardian::
~osxGraphicsStateGuardian()
{
if(_aglcontext != (AGLContext)NULL)
{
aglDestroyContext(_aglcontext);
aglReportError();
_aglcontext = (AGLContext)NULL;
}
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::reset
// Access: Public, Virtual
// Description: Resets all internal state as if the gsg were newly
// created.
////////////////////////////////////////////////////////////////////
void osxGraphicsStateGuardian::reset()
{
/*
if(_aglcontext != (AGLContext)NULL)
{
aglDestroyContext(_aglcontext);
aglReportError();
_aglcontext = (AGLContext)NULL;
}
*/
GLGraphicsStateGuardian::reset();
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::buildGL
// Access: Public, Virtual
// Description:
//
////////////////////////////////////////////////////////////////////
OSStatus osxGraphicsStateGuardian::buildGL (osxGraphicsWindow &window)
{
OSStatus err = noErr;
// GLint attrib[] = { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16, AGL_NONE };
GLint attrib[] = { AGL_RGBA, AGL_NO_RECOVERY, AGL_FULLSCREEN, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 32, AGL_SAMPLE_BUFFERS_ARB, 1, AGL_SAMPLES_ARB, 0, 0 };
if (_aglcontext)
return noErr; // already built
// build context
_aglcontext = NULL;
_aglPixFmt = aglChoosePixelFormat(NULL, 0, attrib);
err = aglReportError ();
if (_aglPixFmt)
{
if(_share_with == NULL)
_aglcontext = aglCreateContext(_aglPixFmt, NULL);
else
_aglcontext = aglCreateContext(_aglPixFmt, ((osxGraphicsStateGuardian *)_share_with)->_aglcontext);
err = aglReportError ();
}
return err;
}

View File

@ -0,0 +1,87 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef OSXGRAPHICSSTATEGUARDIAN_H
#define OSXGRAPHICSSTATEGUARDIAN_H
#include <Carbon/Carbon.h>
#define __glext_h_
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <AGL/agl.h>
#include "pandabase.h"
#include "glgsg.h"
#include "osxGraphicsWindow.h"
class osxGraphicsWindow;
////////////////////////////////////////////////////////////////////
// Class : wglGraphicsStateGuardian
// Description : A tiny specialization on GLGraphicsStateGuardian to
// add some wgl-specific information.
////////////////////////////////////////////////////////////////////
class osxGraphicsStateGuardian : public GLGraphicsStateGuardian {
public:
osxGraphicsStateGuardian(const FrameBufferProperties &properties,
osxGraphicsStateGuardian *share_with,
int pfnum);
virtual ~osxGraphicsStateGuardian();
virtual void reset();
AGLContext get_context(void) { return _aglcontext; };
OSStatus buildGL (osxGraphicsWindow &window);
protected:
virtual void *get_extension_func(const char *prefix, const char *name);
private:
// We have to save a pointer to the GSG we intend to share texture
// context with, since we don't create our own context in the
// constructor.
PT(osxGraphicsStateGuardian) _share_with;
AGLPixelFormat _aglPixFmt;
AGLContext _aglcontext;
public:
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
GLGraphicsStateGuardian::init_type();
register_type(_type_handle, "osxGraphicsStateGuardian",
GLGraphicsStateGuardian::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
friend class osxGraphicsBuffer;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef OSXGRAPHICSWINDOW_H
#define OSXGRAPHICSWINDOW_H
#include <Carbon/Carbon.h>
#define __glext_h_
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <AGL/agl.h>
#include "pandabase.h"
#include "graphicsWindow.h"
#include "buttonHandle.h"
#define HACK_SCREEN_HASH_CONTEXT true
OSStatus aglReportError (void);
////////////////////////////////////////////////////////////////////
// Class : osxGraphicsWindow
// Description : An interface to the osx/ system for managing GL
// windows under X.
////////////////////////////////////////////////////////////////////
class osxGraphicsWindow : public GraphicsWindow {
public:
osxGraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
const string &name);
virtual ~osxGraphicsWindow();
// virtual bool move_pointer(int device, int x, int y);
//virtual bool make_context();
virtual void make_current();
virtual void release_gsg();
virtual bool begin_frame(FrameMode mode);
virtual void end_frame(FrameMode mode);
virtual void begin_flip();
virtual void process_events();
void ReleaseSystemResources();
protected:
virtual void close_window();
virtual bool open_window();
private:
public: // do not call direct ..
OSStatus handleKeyInput (EventHandlerCallRef myHandler, EventRef event, Boolean keyDown);
OSStatus handleTextInput (EventHandlerCallRef myHandler, EventRef event);
OSStatus handleWindowMouseEvents (EventHandlerCallRef myHandler, EventRef event);
void HandleModifireDeleta(UInt32 modifiers);
void DoResize(void);
void SystemCloseWindow();
void SystemSetWindowForground(bool forground);
void SystemPointToLocalPoint(Point &qdGlobalPoint);
AGLContext osxGraphicsWindow::get_ggs_context(void);
AGLContext get_context(void);
OSStatus buildGL(void);
inline void SendKeyEvent( ButtonHandle key, bool down)
{
if(down)
_input_devices[0].button_down(key);
else
_input_devices[0].button_up(key);
}
inline bool IsAlive(void)
{
return (_is_fullsreen || _osx_window != NULL);
}
WindowProperties & properties() { return _properties; };
private:
UInt32 _last_key_modifiers;
WindowRef _osx_window;
bool _is_fullsreen;
#ifdef HACK_SCREEN_HASH_CONTEXT
AGLPixelFormat _aglPixFmt;
AGLContext _aglcontext;
#endif
CFDictionaryRef _originalMode;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
GraphicsWindow::init_type();
register_type(_type_handle, "osxGraphicsWindow",
GraphicsWindow::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#endif