renderspu_agl.c revision e4dec40ee9c070be42661febd9ae047056007ec5
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include <stdio.h>
#include "cr_environment.h"
#include "cr_error.h"
#include "cr_string.h"
#include "cr_mem.h"
#include "renderspu.h"
/* Some necessary global defines */
uint64_t gDockUpdateTS = 0;
enum
{
/* Event classes */
kEventClassVBox = 'vbox',
/* Event kinds */
kEventVBoxShowWindow = 'swin',
kEventVBoxMoveWindow = 'mwin',
kEventVBoxResizeWindow = 'rwin',
kEventVBoxUpdateDock = 'udck'
};
#ifdef __LP64__ /** @todo port to 64-bit darwin. */
# define renderspuSetWindowContext(w, c) \
# define renderspuGetWindowContext(w) \
#else
# define renderspuSetWindowContext(w, c) \
( SetWRefCon( (w), (unsigned long) (c) ) )
# define renderspuGetWindowContext(w) \
#endif
/* Debug macros */
{ \
return ret; \
}
if(!(result)) \
{ \
}
/* Window event handler */
{
/* Currently this is *NOT* used */
if( window )
switch (class) {
case kEventClassWindow:
switch (kind) {
case kEventWindowActivated:
#ifndef __LP64__ /* not available for 64-bit processes? */
case kEventWindowDrawContent:
#endif
break;
case kEventWindowClose:
HideWindow( window );
#ifdef __LP64__ /** @todo port to 64-bit darwin. */
#else
#endif
crWarning( "Render SPU: caught kEventWindowClose -- quitting." );
break;
case kEventWindowShown:
/* build gl */
#ifndef __LP64__ /** @todo port to 64-bit darwin! Need to cehck if this event is generated or not (it probably isn't). */
if( window == FrontWindow() )
#endif
break;
/* resize
update */
break;
case kEventWindowZoomed:
/* zoom button */
break;
}
break;
}
return result;
}
{
return GL_TRUE;
}
{
/* ATTR_ADDV(AGL_RED_SIZE, 1);
ATTR_ADDV(AGL_GREEN_SIZE, 1);
ATTR_ADDV(AGL_BLUE_SIZE, 1); */
/* if( render_spu.fullscreen )*/
/* ATTR_ADD(AGL_FULLSCREEN);*/
if( visAttribs & CR_ALPHA_BIT )
if( visAttribs & CR_DOUBLE_BIT )
if( visAttribs & CR_STEREO_BIT )
if( visAttribs & CR_DEPTH_BIT )
if( visAttribs & CR_STENCIL_BIT )
if( visAttribs & CR_ACCUM_BIT ) {
if( visAttribs & CR_ALPHA_BIT )
}
if( visAttribs & CR_MULTISAMPLE_BIT ) {
}
if( visAttribs & CR_OVERLAY_BIT )
}
void
{
}
{
(void) sharedContext;
crError( "Render SPU: Unable to create pixel format" );
return GL_FALSE;
}
crError( "Render SPU: Could not create rendering context" );
return GL_FALSE;
}
return GL_TRUE;
}
void
{
if(!context)
return;
{
}
}
void
{
/* Real fullscreen isn't supported by VirtualBox */
}
{
/* Flush old context first */
/* If the window buffer name is uninitialized we have to create a new
* dummy context. */
{
/* Use the same visual bits as those in the context structure */
{
crError( "Render SPU: Unable to create pixel format" );
return GL_FALSE;
}
/* Create the dummy context */
if( !wi->dummyContext )
{
crError( "Render SPU: Could not create rendering context" );
return GL_FALSE;
}
#ifdef __LP64__ /** @todo port to 64-bit darwin. */
#else
#endif
/* New global buffer name */
/* Set the new buffer name to the dummy context. This enable the
* sharing of the same hardware buffer afterwards. */
/* Assign the dummy context to the window */
}
#ifdef __LP64__ /** @todo port to 64-bit darwin. */
#else
#endif
/* Only switch the context if the drawable has changed */
if (oldDrawable != newDrawable)
{
/* Reset the current context */
/* Set the buffer name of the dummy context to the current context
* also. After that both share the same hardware buffer. */
/* Set the new drawable */
#ifdef __LP64__ /** @todo port to 64-bit darwin. */
result = -1;
#else
#endif
}
return result;
}
{
return GL_TRUE;
}
void
{
if(!window->nativeWindow)
/* Delete the dummy context */
if(window->dummyContext)
{
}
/* Reset some values */
}
void
{
/* Send a event to the main thread, cause some function of Carbon aren't
* thread safe */
status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof(window->window), &window->window);
HISize s = CGSizeMake (w, h);
/* Update the context */
if (context &&
{
}
/* save the new size */
}
void
{
Rect r;
*x = (int) r.left;
*y = (int) r.top;
}
void
{
HISize s;
#ifdef __LP64__ /** @todo port to 64-bit darwin. */
status = -1;
#else
#endif
*w = s.width;
*h = s.height;
}
void
{
/* Send a event to the main thread, cause some function of Carbon aren't
* thread safe */
status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof(window->window), &window->window);
HIPoint p = CGPointMake (x, y);
/* Update the context */
if (context &&
{
}
}
/* Either show or hide the render SPU's window. */
void
{
return;
if(showIt)
{
/* Force moving the win to the right position before we show it */
/* Send a event to the main thread, cause some function of Carbon
* aren't thread safe */
status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
}
else
/* Update the context */
if (context &&
{
}
}
void
{
/* crDebug( "renderspu_SystemMakeCurrent( %x, %i, %x )", window, nativeWindow, context );*/
{
{
crDebug("Render SPU: MakeCurrent visual mismatch (0x%x != 0x%x); remaking window.",
/*
* XXX have to revisit this issue!!!
*
* But for now we destroy the current window
* and re-create it with the context's visual abilities
*/
window);
}
/* This is the normal case: rendering to the render SPU's own window */
context);
/* XXX this is a total hack to work around an NVIDIA driver bug */
{
GLfloat f[4];
{
crDebug("Render SPU: Resetting raster pos");
}
}
}
else
renderspuWindowAttachContext (0, 0, 0);
}
void
{
if(!context)
crError("Render SPU: SwapBuffers got a null context from the window");
/* This method seems called very often. To prevent the dock using all free
* resources we update the dock only two times per second. */
{
/* Send a event to the main thread, cause some function of Carbon aren't
* thread safe */
}
}
{
ContextInfo *c;
c = renderspuGetWindowContext (window);
if (c &&
c->context)
{
int i;
/* Create some temporary regions */
SetEmptyRgn (rgn);
for (i=0; i<cRects; ++i)
{
}
DisposeRgn (tmpRgn);
/* Set the clip region to the context */
/* Clear the region structure */
DisposeRgn (rgn);
}
}
{
WindowAttributes winAttr = kWindowNoShadowAttribute | kWindowCompositingAttribute | kWindowIgnoreClicksAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute;
/* Destroy the old one */
/* We set a title for debugging purposes */
/* We need grouping so create a master group for this & all following
* windows & one group for the parent. */
if(!gMasterGroup || !gParentGroup)
{
status = CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrFixedLevel, &gMasterGroup);
status = CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrFixedLevel, &gParentGroup);
/* Make the correct z-layering */
/* and set the gParentGroup as parent for gMasterGroup. */
#ifdef __LP64__ /** @todo port to 64-bit darwin. */
#else
#endif
}
/* The parent has to be in its own group */
{
}
/* Add the new window to the master group */
/* Own handler needed? */
{
/* Even though there are still issues with the windows themselves,
install the event handlers */
/*InstallWindowEventHandler(window->window, window->event_handler,
GetEventTypeCount(event_list), event_list,
NULL, NULL);*/
}
/* This will be initialized on the first attempt to attach the global
* context to this new window */
if(showIt)
crDebug("Render SPU: actual window (x, y, width, height): %d, %d, %d, %d",
return GL_TRUE;
}