mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
native OSX support
This commit is contained in:
parent
abc56fdc8d
commit
6c81c213c1
@ -1,6 +1,7 @@
|
||||
#define BUILD_DIRECTORY $[HAVE_TINYDISPLAY]
|
||||
#define BUILDING_DLL BUILDING_TINYDISPLAY
|
||||
|
||||
#define OSX_SYS_FRAMEWORKS ApplicationServices Carbon CoreServices Cocoa
|
||||
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||
dtoolutil:c dtoolbase:c dtool:m prc:c
|
||||
|
||||
@ -24,6 +25,9 @@
|
||||
tinyWinGraphicsWindow.h tinyWinGraphicsWindow.I tinyWinGraphicsWindow.cxx \
|
||||
tinyXGraphicsPipe.I tinyXGraphicsPipe.cxx tinyXGraphicsPipe.h \
|
||||
tinyXGraphicsWindow.h tinyXGraphicsWindow.I tinyXGraphicsWindow.cxx \
|
||||
tinyOsxGraphicsPipe.I tinyOsxGraphicsPipe.cxx tinyOsxGraphicsPipe.h \
|
||||
tinyOsxGraphicsWindow.h tinyOsxGraphicsWindow.I \
|
||||
$[if $[IS_OSX],tinyOsxGraphicsWindow.mm,] \
|
||||
clip.cxx error.cxx \
|
||||
image_util.cxx init.cxx light.cxx \
|
||||
memory.cxx msghandling.cxx msghandling.h \
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "tinyXGraphicsWindow.h"
|
||||
#include "tinyWinGraphicsPipe.h"
|
||||
#include "tinyWinGraphicsWindow.h"
|
||||
#include "tinyOsxGraphicsPipe.h"
|
||||
#include "tinyOsxGraphicsWindow.h"
|
||||
#include "tinySDLGraphicsPipe.h"
|
||||
#include "tinySDLGraphicsWindow.h"
|
||||
#include "tinyGraphicsStateGuardian.h"
|
||||
@ -60,6 +62,26 @@ ConfigVariableInt x_wheel_down_button
|
||||
"mouse button number does the system report when the mouse wheel "
|
||||
"is rolled one notch down?"));
|
||||
|
||||
ConfigVariableBool show_resize_box
|
||||
("show-resize-box", true,
|
||||
PRC_DESC("When this variable is true, then resizable OSX Panda windows will "
|
||||
"be rendered with a resize control in the lower-right corner. "
|
||||
"This is specially handled by Panda, since otherwise the 3-d "
|
||||
"window would completely hide any resize control drawn by the "
|
||||
"OS. Set this variable false to allow this control to be hidden."));
|
||||
|
||||
ConfigVariableBool osx_disable_event_loop
|
||||
("osx-disable-event-loop", false,
|
||||
PRC_DESC("Set this true to disable the window event loop for the Panda "
|
||||
"windows. This makes sense only in a publish environment where "
|
||||
"the window event loop is already handled by another part of the "
|
||||
"app."));
|
||||
|
||||
ConfigVariableInt osx_mouse_wheel_scale
|
||||
("osx-mouse-wheel-scale", 1,
|
||||
PRC_DESC("Specify the number of units to spin the Mac mouse wheel to "
|
||||
"represent a single wheel_up or wheel_down message."));
|
||||
|
||||
ConfigVariableInt td_texture_ram
|
||||
("td-texture-ram", -1,
|
||||
PRC_DESC("This specifies the maximum amount of RAM to devote to keeping "
|
||||
@ -122,6 +144,14 @@ init_libtinydisplay() {
|
||||
ps->set_system_tag("TinyGL", "native_window_system", "Win");
|
||||
#endif
|
||||
|
||||
#ifdef IS_OSX
|
||||
TinyOsxGraphicsPipe::init_type();
|
||||
TinyOsxGraphicsWindow::init_type();
|
||||
selection->add_pipe_type(TinyOsxGraphicsPipe::get_class_type(),
|
||||
TinyOsxGraphicsPipe::pipe_constructor);
|
||||
ps->set_system_tag("TinyGL", "OSX", "OSX");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
TinySDLGraphicsPipe::init_type();
|
||||
TinySDLGraphicsWindow::init_type();
|
||||
|
@ -34,6 +34,10 @@ extern ConfigVariableBool x_error_abort;
|
||||
extern ConfigVariableInt x_wheel_up_button;
|
||||
extern ConfigVariableInt x_wheel_down_button;
|
||||
|
||||
extern ConfigVariableBool show_resize_box;
|
||||
extern ConfigVariableBool osx_disable_event_loop;
|
||||
extern ConfigVariableInt osx_mouse_wheel_scale;
|
||||
|
||||
extern ConfigVariableInt td_texture_ram;
|
||||
extern ConfigVariableBool td_ignore_mipmaps;
|
||||
extern ConfigVariableBool td_perspective_textures;
|
||||
|
@ -434,6 +434,11 @@ end_frame(Thread *current_thread) {
|
||||
|
||||
// Evict any textures that exceed our texture memory.
|
||||
_textures_lru.begin_epoch();
|
||||
|
||||
// Clear these pointers so we don't have floating pointers between
|
||||
// frames.
|
||||
_current_frame_buffer = NULL;
|
||||
_c->zb = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
18
panda/src/tinydisplay/tinyOsxGraphicsPipe.I
Normal file
18
panda/src/tinydisplay/tinyOsxGraphicsPipe.I
Normal file
@ -0,0 +1,18 @@
|
||||
// Filename: tinyOsxGraphicsPipe.I
|
||||
// Created by: drose (12May08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
247
panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx
Normal file
247
panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx
Normal file
@ -0,0 +1,247 @@
|
||||
// Filename: tinyOsxGraphicsPipe.cxx
|
||||
// Created by: drose (12May08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "pandabase.h"
|
||||
|
||||
#ifdef IS_OSX
|
||||
|
||||
#include "tinyOsxGraphicsPipe.h"
|
||||
#include "config_tinydisplay.h"
|
||||
#include "tinyOsxGraphicsWindow.h"
|
||||
#include "pnmImage.h"
|
||||
|
||||
TypeHandle TinyOsxGraphicsPipe::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyOsxGraphicsPipe::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TinyOsxGraphicsPipe::
|
||||
TinyOsxGraphicsPipe() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyOsxGraphicsPipe::Destructor
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TinyOsxGraphicsPipe::
|
||||
~TinyOsxGraphicsPipe() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyOsxGraphicsPipe::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 TinyOsxGraphicsPipe::
|
||||
get_interface_name() const {
|
||||
return "TinyGL Windows";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyOsxGraphicsPipe::pipe_constructor
|
||||
// Access: Public, Static
|
||||
// Description: This function is passed to the GraphicsPipeSelection
|
||||
// object to allow the user to make a default
|
||||
// TinyOsxGraphicsPipe.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(GraphicsPipe) TinyOsxGraphicsPipe::
|
||||
pipe_constructor() {
|
||||
return new TinyOsxGraphicsPipe;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyOsxGraphicsPipe::create_cg_image
|
||||
// Access: Public, Static
|
||||
// Description: Creates a new Quartz bitmap image with the data in
|
||||
// the indicated PNMImage. The caller should eventually
|
||||
// free this image via CGImageRelease.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CGImageRef TinyOsxGraphicsPipe::
|
||||
create_cg_image(const PNMImage &pnm_image) {
|
||||
size_t width = pnm_image.get_x_size();
|
||||
size_t height = pnm_image.get_y_size();
|
||||
|
||||
#ifdef PGM_BIGGRAYS
|
||||
size_t bytes_per_component = 2;
|
||||
#else
|
||||
size_t bytes_per_component = 1;
|
||||
#endif
|
||||
size_t bits_per_component = bytes_per_component * 8;
|
||||
size_t num_components = pnm_image.get_num_channels();
|
||||
|
||||
size_t bits_per_pixel = num_components * bits_per_component;
|
||||
size_t bytes_per_row = num_components * bytes_per_component * width;
|
||||
|
||||
size_t num_bytes = bytes_per_row * height;
|
||||
bool has_alpha;
|
||||
bool is_grayscale;
|
||||
|
||||
CFStringRef color_space_name = NULL;
|
||||
switch (pnm_image.get_color_type()) {
|
||||
case PNMImage::CT_grayscale:
|
||||
color_space_name = kCGColorSpaceGenericGray;
|
||||
has_alpha = false;
|
||||
is_grayscale = true;
|
||||
break;
|
||||
|
||||
case PNMImage::CT_two_channel:
|
||||
color_space_name = kCGColorSpaceGenericGray;
|
||||
has_alpha = true;
|
||||
is_grayscale = true;
|
||||
break;
|
||||
|
||||
case PNMImage::CT_color:
|
||||
color_space_name = kCGColorSpaceGenericRGB;
|
||||
has_alpha = false;
|
||||
is_grayscale = false;
|
||||
break;
|
||||
|
||||
case PNMImage::CT_four_channel:
|
||||
color_space_name = kCGColorSpaceGenericRGB;
|
||||
has_alpha = true;
|
||||
is_grayscale = false;
|
||||
break;
|
||||
|
||||
case PNMImage::CT_invalid:
|
||||
// Shouldn't get here.
|
||||
nassertr(false, NULL);
|
||||
break;
|
||||
}
|
||||
nassertr(color_space_name != NULL, NULL);
|
||||
|
||||
CGColorSpaceRef color_space = CGColorSpaceCreateWithName(color_space_name);
|
||||
nassertr(color_space != NULL, NULL);
|
||||
|
||||
CGBitmapInfo bitmap_info = 0;
|
||||
#ifdef PGM_BIGGRAYS
|
||||
bitmap_info |= kCGBitmapByteOrder16Host;
|
||||
#endif
|
||||
if (has_alpha) {
|
||||
bitmap_info |= kCGImageAlphaLast;
|
||||
}
|
||||
|
||||
// Now convert the pixel data to a format friendly to
|
||||
// CGImageCreate().
|
||||
char *char_array = (char *)PANDA_MALLOC_ARRAY(num_bytes);
|
||||
|
||||
xelval *dp = (xelval *)char_array;
|
||||
for (size_t yi = 0; yi < height; ++yi) {
|
||||
for (size_t xi = 0; xi < width; ++xi) {
|
||||
if (is_grayscale) {
|
||||
*dp++ = (xelval)(pnm_image.get_gray(xi, yi) * PGM_MAXMAXVAL);
|
||||
} else {
|
||||
*dp++ = (xelval)(pnm_image.get_red(xi, yi) * PGM_MAXMAXVAL);
|
||||
*dp++ = (xelval)(pnm_image.get_green(xi, yi) * PGM_MAXMAXVAL);
|
||||
*dp++ = (xelval)(pnm_image.get_blue(xi, yi) * PGM_MAXMAXVAL);
|
||||
}
|
||||
if (has_alpha) {
|
||||
*dp++ = (xelval)(pnm_image.get_alpha(xi, yi) * PGM_MAXMAXVAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
nassertr((void *)dp == (void *)(char_array + num_bytes), NULL);
|
||||
|
||||
CGDataProviderRef provider =
|
||||
CGDataProviderCreateWithData(NULL, char_array, num_bytes, release_data);
|
||||
nassertr(provider != NULL, NULL);
|
||||
|
||||
CGImageRef image = CGImageCreate
|
||||
(width, height, bits_per_component, bits_per_pixel, bytes_per_row,
|
||||
color_space, bitmap_info, provider,
|
||||
NULL, false, kCGRenderingIntentDefault);
|
||||
nassertr(image != NULL, NULL);
|
||||
|
||||
CGColorSpaceRelease(color_space);
|
||||
CGDataProviderRelease(provider);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyOsxGraphicsPipe::release_data
|
||||
// Access: Private, Static
|
||||
// Description: This callback is assigned to delete the data array
|
||||
// allocated within create_cg_image().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void TinyOsxGraphicsPipe::
|
||||
release_data(void *info, const void *data, size_t size) {
|
||||
char *char_array = (char *)data;
|
||||
PANDA_FREE_ARRAY(char_array);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TinyOsxGraphicsPipe::make_output
|
||||
// Access: Protected, Virtual
|
||||
// Description: Creates a new window or buffer on the pipe, if possible.
|
||||
// This routine is only called from GraphicsEngine::make_output.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(GraphicsOutput) TinyOsxGraphicsPipe::
|
||||
make_output(const string &name,
|
||||
const FrameBufferProperties &fb_prop,
|
||||
const WindowProperties &win_prop,
|
||||
int flags,
|
||||
GraphicsStateGuardian *gsg,
|
||||
GraphicsOutput *host,
|
||||
int retry,
|
||||
bool &precertify) {
|
||||
|
||||
if (!_is_valid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TinyGraphicsStateGuardian *tinygsg = 0;
|
||||
if (gsg != 0) {
|
||||
DCAST_INTO_R(tinygsg, gsg, NULL);
|
||||
}
|
||||
|
||||
// First thing to try: a TinyOsxGraphicsWindow
|
||||
|
||||
if (retry == 0) {
|
||||
if (((flags&BF_require_parasite)!=0)||
|
||||
((flags&BF_refuse_window)!=0)||
|
||||
((flags&BF_resizeable)!=0)||
|
||||
((flags&BF_size_track_host)!=0)||
|
||||
((flags&BF_rtt_cumulative)!=0)||
|
||||
((flags&BF_can_bind_color)!=0)||
|
||||
((flags&BF_can_bind_every)!=0)) {
|
||||
return NULL;
|
||||
}
|
||||
if ((flags & BF_fb_props_optional)==0) {
|
||||
if ((fb_prop.get_aux_rgba() > 0)||
|
||||
(fb_prop.get_aux_hrgba() > 0)||
|
||||
(fb_prop.get_aux_float() > 0)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return new TinyOsxGraphicsWindow(this, name, fb_prop, win_prop,
|
||||
flags, gsg, host);
|
||||
}
|
||||
|
||||
// Nothing else left to try.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // IS_OSX
|
85
panda/src/tinydisplay/tinyOsxGraphicsPipe.h
Normal file
85
panda/src/tinydisplay/tinyOsxGraphicsPipe.h
Normal file
@ -0,0 +1,85 @@
|
||||
// Filename: tinyOsxGraphicsPipe.h
|
||||
// Created by: drose (12May08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 TINYOSXGRAPHICSPIPE_H
|
||||
#define TINYOSXGRAPHICSPIPE_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef IS_OSX
|
||||
|
||||
// We have to include this early, before anyone includes
|
||||
// netinet/tcp.h, which will define TCP_NODELAY and other symbols and
|
||||
// confuse the Apply system headers.
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#include "graphicsPipe.h"
|
||||
#include "tinyGraphicsStateGuardian.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : TinyOsxGraphicsPipe
|
||||
// Description : This graphics pipe represents the interface for
|
||||
// creating TinyGL graphics windows on a Windows-based
|
||||
// client.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_TINYDISPLAY TinyOsxGraphicsPipe : public GraphicsPipe {
|
||||
public:
|
||||
TinyOsxGraphicsPipe();
|
||||
virtual ~TinyOsxGraphicsPipe();
|
||||
|
||||
virtual string get_interface_name() const;
|
||||
static PT(GraphicsPipe) pipe_constructor();
|
||||
|
||||
static CGImageRef create_cg_image(const PNMImage &pnm_image);
|
||||
|
||||
private:
|
||||
static void release_data(void *info, const void *data, size_t size);
|
||||
|
||||
protected:
|
||||
virtual PT(GraphicsOutput) make_output(const string &name,
|
||||
const FrameBufferProperties &fb_prop,
|
||||
const WindowProperties &win_prop,
|
||||
int flags,
|
||||
GraphicsStateGuardian *gsg,
|
||||
GraphicsOutput *host,
|
||||
int retry,
|
||||
bool &precertify);
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
GraphicsPipe::init_type();
|
||||
register_type(_type_handle, "TinyOsxGraphicsPipe",
|
||||
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;
|
||||
};
|
||||
|
||||
#include "tinyOsxGraphicsPipe.I"
|
||||
|
||||
#endif // IS_OSX
|
||||
|
||||
#endif
|
27
panda/src/tinydisplay/tinyOsxGraphicsWindow.I
Normal file
27
panda/src/tinydisplay/tinyOsxGraphicsWindow.I
Normal file
@ -0,0 +1,27 @@
|
||||
// Filename: tinyOsxGraphicsWindow.I
|
||||
// Created by: drose (12May08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
inline void TinyOsxGraphicsWindow::SendKeyEvent( ButtonHandle key, bool down)
|
||||
{
|
||||
if(down)
|
||||
_input_devices[0].button_down(key);
|
||||
else
|
||||
_input_devices[0].button_up(key);
|
||||
}
|
155
panda/src/tinydisplay/tinyOsxGraphicsWindow.h
Normal file
155
panda/src/tinydisplay/tinyOsxGraphicsWindow.h
Normal file
@ -0,0 +1,155 @@
|
||||
// Filename: tinyOsxGraphicsWindow.h
|
||||
// Created by: drose (12May08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 TINYOSXGRAPHICSWINDOW_H
|
||||
#define TINYOSXGRAPHICSWINDOW_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef IS_OSX
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#include "graphicsWindow.h"
|
||||
#include "buttonHandle.h"
|
||||
#include "tinyGraphicsStateGuardian.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : TinyOsxGraphicsWindow
|
||||
// Description : Opens a window on OS X to display the TinyGL software
|
||||
// rendering.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class TinyOsxGraphicsWindow : public GraphicsWindow {
|
||||
public:
|
||||
TinyOsxGraphicsWindow(GraphicsPipe *pipe,
|
||||
const string &name,
|
||||
const FrameBufferProperties &fb_prop,
|
||||
const WindowProperties &win_prop,
|
||||
int flags,
|
||||
GraphicsStateGuardian *gsg,
|
||||
GraphicsOutput *host);
|
||||
virtual ~TinyOsxGraphicsWindow();
|
||||
|
||||
virtual bool move_pointer(int device, int x, int y);
|
||||
|
||||
virtual bool begin_frame(FrameMode mode, Thread *current_thread);
|
||||
virtual void end_frame(FrameMode mode, Thread *current_thread);
|
||||
virtual void begin_flip();
|
||||
virtual void end_flip();
|
||||
virtual void process_events();
|
||||
|
||||
virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
|
||||
int x_size, int y_size);
|
||||
|
||||
virtual void mouse_mode_absolute();
|
||||
virtual void mouse_mode_relative();
|
||||
|
||||
virtual void set_properties_now(WindowProperties &properties);
|
||||
|
||||
private:
|
||||
void ReleaseSystemResources();
|
||||
inline void SendKeyEvent( ButtonHandle key, bool down);
|
||||
|
||||
protected:
|
||||
virtual void close_window();
|
||||
virtual bool open_window();
|
||||
|
||||
private:
|
||||
|
||||
bool OSOpenWindow(WindowProperties &properties);
|
||||
|
||||
//
|
||||
// a singleton .. for the events to find the right pipe to push the event into
|
||||
//
|
||||
|
||||
|
||||
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);
|
||||
ButtonHandle OSX_TranslateKey( UInt32 key, EventRef event );
|
||||
static TinyOsxGraphicsWindow * GetCurrentOSxWindow (WindowRef hint);
|
||||
|
||||
void HandleModifireDeleta(UInt32 modifiers);
|
||||
void HandleButtonDelta(UInt32 new_buttons);
|
||||
void DoResize(void);
|
||||
|
||||
OSStatus event_handler(EventHandlerCallRef myHandler, EventRef event);
|
||||
|
||||
virtual void user_close_request();
|
||||
void SystemCloseWindow();
|
||||
void SystemSetWindowForground(bool forground);
|
||||
void SystemPointToLocalPoint(Point &qdGlobalPoint);
|
||||
void LocalPointToSystemPoint(Point &qdLocalPoint);
|
||||
bool set_icon_filename(const Filename &icon_filename);
|
||||
|
||||
void set_pointer_in_window(int x, int y);
|
||||
void set_pointer_out_of_window();
|
||||
|
||||
private:
|
||||
void create_frame_buffer();
|
||||
|
||||
private:
|
||||
ZBuffer *_frame_buffer;
|
||||
|
||||
private:
|
||||
UInt32 _last_key_modifiers;
|
||||
UInt32 _last_buttons;
|
||||
WindowRef _osx_window;
|
||||
bool _is_fullscreen;
|
||||
|
||||
CGImageRef _pending_icon;
|
||||
CGImageRef _current_icon;
|
||||
|
||||
int _ID;
|
||||
static TinyOsxGraphicsWindow *FullScreenWindow;
|
||||
|
||||
CFDictionaryRef _originalMode;
|
||||
|
||||
// True if _properties.get_cursor_hidden() is true.
|
||||
bool _cursor_hidden;
|
||||
|
||||
// True if the cursor is actually hidden right now via system calls.
|
||||
bool _display_hide_cursor;
|
||||
|
||||
SInt32 _wheel_delta;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
GraphicsWindow::init_type();
|
||||
register_type(_type_handle, "TinyOsxGraphicsWindow",
|
||||
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;
|
||||
};
|
||||
|
||||
#include "tinyOsxGraphicsWindow.I"
|
||||
|
||||
#endif // IS_OSX
|
||||
|
||||
#endif
|
||||
|
1791
panda/src/tinydisplay/tinyOsxGraphicsWindow.mm
Normal file
1791
panda/src/tinydisplay/tinyOsxGraphicsWindow.mm
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user