reformat for panda conventions

This commit is contained in:
David Rose 2009-03-11 20:43:40 +00:00
parent 2820bca34b
commit 4a70282208
8 changed files with 1461 additions and 1499 deletions

View File

@ -23,7 +23,7 @@
Configure(config_osxdisplay);
NotifyCategoryDef( osxdisplay , "display");
NotifyCategoryDef(osxdisplay, "display");
ConfigureFn(config_osxdisplay) {
init_libosxdisplay();
@ -70,8 +70,6 @@ init_libosxdisplay() {
osxGraphicsWindow::init_type();
osxGraphicsStateGuardian::init_type();
GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
selection->add_pipe_type(osxGraphicsPipe::get_class_type(), osxGraphicsPipe::pipe_constructor);

View File

@ -77,12 +77,12 @@ begin_frame(FrameMode mode, Thread *current_thread) {
osxGraphicsStateGuardian *osxgsg;
DCAST_INTO_R(osxgsg, _gsg, false);
if (!aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0)) {
aglReportError("aglSetPBuffer");
report_agl_error("aglSetPBuffer");
return false;
}
if (!aglSetCurrentContext(osxgsg->get_context())) {
aglReportError("aglSetCurrentContext");
report_agl_error("aglSetCurrentContext");
return false;
}
@ -170,7 +170,7 @@ open_buffer() {
target = GL_TEXTURE_2D;
}
if (!aglCreatePBuffer(_x_size, _y_size, target, GL_RGBA, 0, &_pbuffer)) {
aglReportError("aglCreatePBuffer");
report_agl_error("aglCreatePBuffer");
close_buffer();
return false;
}
@ -178,19 +178,20 @@ open_buffer() {
osxGraphicsStateGuardian *osxgsg;
DCAST_INTO_R(osxgsg, _gsg, false);
OSStatus stat = osxgsg->buildGL(false, true, _fb_properties);
OSStatus stat = osxgsg->build_gl(false, true, _fb_properties);
if (stat != noErr) {
return false;
}
if (!aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0)) {
aglReportError("aglSetPBuffer");
report_agl_error("aglSetPBuffer");
close_buffer();
return false;
}
if (!aglSetCurrentContext(osxgsg->get_context())) {
aglReportError("aglSetCurrentContext");
report_agl_error("aglSetCurrentContext");
return false;
}

View File

@ -51,8 +51,7 @@ protected:
int retry,
bool &precertify);
private:
public:
public:
static TypeHandle get_class_type() {
return _type_handle;
}

View File

@ -28,7 +28,6 @@
TypeHandle osxGraphicsStateGuardian::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::get_extension_func
// Access: Public, Virtual
@ -39,20 +38,21 @@ TypeHandle osxGraphicsStateGuardian::_type_handle;
// 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());
if (osxdisplay_cat.is_debug())
{
osxdisplay_cat.debug() << " Looking Up Symbol " << fullname <<" \n" ;
}
return symbol ? NSAddressOfSymbol (symbol) : NULL;
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());
}
if (osxdisplay_cat.is_debug()) {
osxdisplay_cat.debug()
<< "Looking up symbol " << fullname << "\n" ;
}
return symbol ? NSAddressOfSymbol(symbol) : NULL;
}
////////////////////////////////////////////////////////////////////
@ -77,13 +77,12 @@ osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
osxGraphicsStateGuardian::~osxGraphicsStateGuardian()
{
if(_aglcontext != (AGLContext)NULL)
{
aglDestroyContext(_aglcontext);
aglReportError("osxGraphicsStateGuardian::~osxGraphicsStateGuardian() aglDestroyContext");
_aglcontext = (AGLContext)NULL;
osxGraphicsStateGuardian::
~osxGraphicsStateGuardian() {
if (_aglcontext != (AGLContext)NULL) {
aglDestroyContext(_aglcontext);
report_agl_error("aglDestroyContext");
_aglcontext = (AGLContext)NULL;
}
}
@ -99,8 +98,8 @@ void osxGraphicsStateGuardian::reset()
if(_aglcontext != (AGLContext)NULL)
{
aglDestroyContext(_aglcontext);
aglReportError();
_aglcontext = (AGLContext)NULL;
report_agl_error();
_aglcontext = (AGLContext)NULL;
}
*/
@ -179,20 +178,20 @@ draw_resize_box() {
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::buildGL
// Function: osxGraphicsStateGuardian::build_gl
// Access: Public, Virtual
// Description: This function will build up a context for a gsg..
////////////////////////////////////////////////////////////////////
OSStatus osxGraphicsStateGuardian::
buildGL(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
if (_aglcontext) {
describe_pixel_format(fb_props);
return noErr; // already built
}
OSStatus err = noErr;
GDHandle display = GetMainDevice ();
GDHandle display = GetMainDevice();
pvector<GLint> attrib;
if (!fb_props.get_indexed_color()) {
@ -248,14 +247,14 @@ buildGL(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
// build context
_aglcontext = NULL;
_aglPixFmt = aglChoosePixelFormat(&display, 1, &attrib[0]);
err = aglReportError ("aglChoosePixelFormat");
err = report_agl_error ("aglChoosePixelFormat");
if (_aglPixFmt) {
if(_share_with == NULL) {
_aglcontext = aglCreateContext(_aglPixFmt, NULL);
} else {
_aglcontext = aglCreateContext(_aglPixFmt, ((osxGraphicsStateGuardian *)_share_with)->_aglcontext);
}
err = aglReportError ("aglCreateContext");
err = report_agl_error ("aglCreateContext");
if (_aglcontext == NULL) {
osxdisplay_cat.error()
@ -264,10 +263,10 @@ buildGL(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
err = -1;
}
} else {
aglSetInteger (_aglcontext, AGL_BUFFER_NAME, &SharedBuffer);
err = aglReportError ("aglSetInteger AGL_BUFFER_NAME");
aglSetInteger (_aglcontext, AGL_BUFFER_NAME, &SharedBuffer);
err = report_agl_error("aglSetInteger AGL_BUFFER_NAME");
}
} else {
osxdisplay_cat.error()
<< "osxGraphicsStateGuardian::buildG Error Getting Pixel Format\n" ;
@ -281,10 +280,10 @@ buildGL(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
if (err == noErr) {
describe_pixel_format(fb_props);
}
if (osxdisplay_cat.is_debug()) {
osxdisplay_cat.debug()
<< "osxGraphicsStateGuardian::buildGL Returning :" << err << "\n";
<< "osxGraphicsStateGuardian::build_gl Returning :" << err << "\n";
osxdisplay_cat.debug()
<< fb_props << "\n";
}
@ -383,15 +382,16 @@ describe_pixel_format(FrameBufferProperties &fb_props) {
}
}
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::get_gamma_table
// Access: Public, Static
// Description: Static function for getting the orig gamma tables
////////////////////////////////////////////////////////////////////
bool osxGraphicsStateGuardian::get_gamma_table(void) {
CGDisplayRestoreColorSyncSettings();
_cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
bool osxGraphicsStateGuardian::
get_gamma_table() {
CGDisplayRestoreColorSyncSettings();
_cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
}
////////////////////////////////////////////////////////////////////
@ -402,56 +402,53 @@ bool osxGraphicsStateGuardian::get_gamma_table(void) {
////////////////////////////////////////////////////////////////////
bool osxGraphicsStateGuardian::
static_set_gamma(bool restore, float gamma) {
bool set;
set = false;
bool set;
set = false;
if (restore) {
CGDisplayRestoreColorSyncSettings();
set = true;
return set;
}
// CGDisplayRestoreColorSyncSettings();
// CGGammaValue gOriginalRedTable[ 256 ];
// CGGammaValue gOriginalGreenTable[ 256 ];
// CGGammaValue gOriginalBlueTable[ 256 ];
// CGTableCount sampleCount;
// CGDisplayErr cgErr;
// cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
CGGammaValue redTable[ 256 ];
CGGammaValue greenTable[ 256 ];
CGGammaValue blueTable[ 256 ];
short j, i;
short y[3];
for (j = 0; j < 3; j++)
{
y[j] = 255;
};
y[0] = 256 * gamma;
y[1] = 256 * gamma;
y[2] = 256 * gamma;
for (i = 0; i < 256; i++)
{
redTable[i] = _gOriginalRedTable[ i ] * (y[ 0 ] ) / 256;
greenTable[ i ] = _gOriginalGreenTable[ i ] * (y[ 1 ] ) / 256;
blueTable[ i ] = _gOriginalBlueTable[ i ] * (y[ 2 ] ) / 256;
};
_cgErr = CGSetDisplayTransferByTable( 0, 256, redTable, greenTable, blueTable);
if (_cgErr == 0){
set = true;
}
if (restore) {
CGDisplayRestoreColorSyncSettings();
set = true;
return set;
}
// CGDisplayRestoreColorSyncSettings();
// CGGammaValue gOriginalRedTable[ 256 ];
// CGGammaValue gOriginalGreenTable[ 256 ];
// CGGammaValue gOriginalBlueTable[ 256 ];
// CGTableCount sampleCount;
// CGDisplayErr cgErr;
// cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
CGGammaValue redTable[ 256 ];
CGGammaValue greenTable[ 256 ];
CGGammaValue blueTable[ 256 ];
short j, i;
short y[3];
for (j = 0; j < 3; j++) {
y[j] = 255;
}
y[0] = 256 * gamma;
y[1] = 256 * gamma;
y[2] = 256 * gamma;
for (i = 0; i < 256; i++) {
redTable[i] = _gOriginalRedTable[ i ] * (y[ 0 ] ) / 256;
greenTable[ i ] = _gOriginalGreenTable[ i ] * (y[ 1 ] ) / 256;
blueTable[ i ] = _gOriginalBlueTable[ i ] * (y[ 2 ] ) / 256;
}
_cgErr = CGSetDisplayTransferByTable( 0, 256, redTable, greenTable, blueTable);
if (_cgErr == 0) {
set = true;
}
return set;
}
////////////////////////////////////////////////////////////////////
@ -485,7 +482,7 @@ restore_gamma() {
// Description: This function is passed to the atexit function.
////////////////////////////////////////////////////////////////////
void osxGraphicsStateGuardian::
atexit_function(void) {
atexit_function() {
static_set_gamma(true, 1.0);
}

View File

@ -40,20 +40,20 @@ public:
void draw_resize_box();
bool get_gamma_table(void);
bool get_gamma_table();
bool static_set_gamma(bool restore, float gamma);
bool set_gamma(float gamma);
void atexit_function(void);
void atexit_function();
void restore_gamma();
protected:
virtual void *get_extension_func(const char *prefix, const char *name);
public:
OSStatus buildGL(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props);
OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props);
AGLContext get_context(void) { return _aglcontext; };
const AGLPixelFormat getAGlPixelFormat() const { return _aglPixFmt; };
const AGLPixelFormat get_agl_pixel_format() const { return _aglPixFmt; };
private:
void describe_pixel_format(FrameBufferProperties &fb_props);

View File

@ -13,11 +13,16 @@
////////////////////////////////////////////////////////////////////
inline void osxGraphicsWindow::SendKeyEvent( ButtonHandle key, bool down)
{
if(down)
_input_devices[0].button_down(key);
else
_input_devices[0].button_up(key);
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsWindow::send_key_event
// Access: Private
// Description:
////////////////////////////////////////////////////////////////////
inline void osxGraphicsWindow::
send_key_event(ButtonHandle key, bool down) {
if (down) {
_input_devices[0].button_down(key);
} else {
_input_devices[0].button_up(key);
}
}

View File

@ -24,7 +24,7 @@
#include <AGL/agl.h>
#define HACK_SCREEN_HASH_CONTEXT true
OSStatus aglReportError (const std::string &);
OSStatus report_agl_error(const string &comment);
////////////////////////////////////////////////////////////////////
// Class : osxGraphicsWindow
@ -59,43 +59,42 @@ public:
virtual void set_properties_now(WindowProperties &properties);
private:
void ReleaseSystemResources();
inline void SendKeyEvent( ButtonHandle key, bool down);
void release_system_resources();
inline void send_key_event(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
//
bool os_open_window(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 osxGraphicsWindow * GetCurrentOSxWindow (WindowRef hint);
OSStatus handle_key_input(EventHandlerCallRef myHandler, EventRef event,
Boolean keyDown);
OSStatus handle_text_input(EventHandlerCallRef myHandler, EventRef event);
OSStatus handle_window_mouse_events(EventHandlerCallRef myHandler, EventRef event);
ButtonHandle osx_translate_key(UInt32 key, EventRef event);
static osxGraphicsWindow *get_current_osx_window(WindowRef hint);
void HandleModifireDeleta(UInt32 modifiers);
void HandleButtonDelta(UInt32 new_buttons);
void DoResize(void);
void handle_modifier_delta(UInt32 new_modifiers);
void handle_button_delta(UInt32 new_buttons);
void do_resize();
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);
AGLContext get_ggs_context(void);
AGLContext get_context(void);
OSStatus buildGL(bool full_screen);
void system_close_window();
void system_set_window_foreground(bool foreground);
void system_point_to_local_point(Point &global_point);
void local_point_to_system_point(Point &local_point);
AGLContext get_gsg_context();
AGLContext get_context();
OSStatus build_gl(bool full_screen);
bool set_icon_filename(const Filename &icon_filename);
void set_pointer_in_window(int x, int y);
@ -111,7 +110,7 @@ private:
CGImageRef _current_icon;
int _ID;
static osxGraphicsWindow *FullScreenWindow;
static osxGraphicsWindow *full_screen_window;
#ifdef HACK_SCREEN_HASH_CONTEXT
AGLContext _holder_aglcontext;

File diff suppressed because it is too large Load Diff