Ejemplo n.º 1
0
static void RENDER_APIENTRY
renderspuWindowShow( GLint win, GLint flag )
{
    WindowInfo *window;
    CRASSERT(win >= 0);
    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
    if (window) {
        GLboolean visible;
        if (window->nativeWindow) {
            /* We're rendering back to the native app window instead of the
             * new window which we (the Render SPU) created earlier.
             * So, we never want to show the Render SPU's window.
             */
            flag = 0;
        }
        
        visible = !!flag;
        
        if (window->visible != visible)
        {
            renderspu_SystemShowWindow( window, visible );
            window->visible = visible;
        }
    }
    else {
        crDebug("Render SPU: Attempt to hide/show invalid window (%d)", win);
    }
}
Ejemplo n.º 2
0
GLboolean renderspu_SystemVBoxCreateWindow(VisualInfo *pVisInfo, GLboolean fShowIt, WindowInfo *pWinInfo)
{
    CRASSERT(pVisInfo);
    CRASSERT(pWinInfo);

    /* VirtualBox is the only frontend which support 3D right now. */
    char pszName[256];
    if (RTProcGetExecutablePath(pszName, sizeof(pszName)))
        /* Check for VirtualBox and VirtualBoxVM */
        if (RTStrNICmp(RTPathFilename(pszName), "VirtualBox", 10) != 0)
            return GL_FALSE;

    pWinInfo->visual = pVisInfo;
    pWinInfo->window = NULL;
    pWinInfo->nativeWindow = NULL;
    pWinInfo->currentCtx = NULL;

#ifdef __LP64__
    NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
#else /* __LP64__ */
    NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
#endif /* __LP64__ */

    cocoaViewCreate(&pWinInfo->window, pWinInfo, pParentWin, pVisInfo->visAttribs);

    if (fShowIt)
        renderspu_SystemShowWindow(pWinInfo, fShowIt);

    return GL_TRUE;
}
Ejemplo n.º 3
0
void RENDER_APIENTRY
renderspuMakeCurrent(GLint crWindow, GLint nativeWindow, GLint ctx)
{
	WindowInfo *window;
	ContextInfo *context;

	/*
	crDebug("%s win=%d native=0x%x ctx=%d", __FUNCTION__, crWindow, (int) nativeWindow, ctx);
	*/

	window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, crWindow);
	context = (ContextInfo *) crHashtableSearch(render_spu.contextTable, ctx);

	if (window && context)
	{
#ifdef CHROMIUM_THREADSAFE
		crSetTSD(&_RenderTSD, context);
#else
		render_spu.currentContext = context;
#endif
		context->currentWindow = window;
		if (!window)
		{
			crDebug("Render SPU: MakeCurrent invalid window id: %d", crWindow);
			return;
		}
		if (!context)
		{
			crDebug("Render SPU: MakeCurrent invalid context id: %d", ctx);
			return;
		}

		renderspu_SystemMakeCurrent( window, nativeWindow, context );
		if (!context->everCurrent) {
			/* print OpenGL info */
			const char *extString = (const char *) render_spu.ws.glGetString( GL_EXTENSIONS );
			/*
			crDebug( "Render SPU: GL_EXTENSIONS:   %s", render_spu.ws.glGetString( GL_EXTENSIONS ) );
			*/
			crDebug( "Render SPU: GL_VENDOR:   %s", render_spu.ws.glGetString( GL_VENDOR ) );
			crDebug( "Render SPU: GL_RENDERER: %s", render_spu.ws.glGetString( GL_RENDERER ) );
			crDebug( "Render SPU: GL_VERSION:  %s", render_spu.ws.glGetString( GL_VERSION ) );
			if (crStrstr(extString, "GL_ARB_window_pos"))
				context->haveWindowPosARB = GL_TRUE;
			else
				context->haveWindowPosARB = GL_FALSE;
			context->everCurrent = GL_TRUE;
		}
		if (crWindow == 0 && window->mapPending &&
				!render_spu.render_to_app_window && !render_spu.render_to_crut_window) {
			/* Window[0] is special, it's the default window and normally hidden.
			 * If the mapPending flag is set, then we should now make the window
			 * visible.
			 */
			renderspu_SystemShowWindow( window, GL_TRUE );
			window->mapPending = GL_FALSE;
		}
		window->everCurrent = GL_TRUE;
	}
	else
	{
#ifdef CHROMIUM_THREADSAFE
		crSetTSD(&_RenderTSD, NULL);
#else
		render_spu.currentContext = NULL;
#endif
	}
}
Ejemplo n.º 4
0
GLboolean
renderspu_SystemVBoxCreateWindow(VisualInfo *visual, GLboolean showIt,
                                 WindowInfo *window)
{
    CRASSERT(visual);
    CRASSERT(window);

    WindowAttributes winAttr = kWindowNoShadowAttribute | kWindowCompositingAttribute | kWindowIgnoreClicksAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute;
    WindowClass winClass = kOverlayWindowClass;
    Rect windowRect;
    OSStatus status = noErr;

    window->visual = visual;
    window->nativeWindow = NULL;

    if(window->window && IsValidWindowPtr(window->window))
    {
        EventRef evt;
        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxDisposeWindow, 0, kEventAttributeNone, &evt);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateEvent Failed", false);
        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): SetEventParameter Failed", false);
        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): PostEventToQueue Failed", false);
    }

    windowRect.left = window->x;
    windowRect.top = window->y;
    windowRect.right = window->x + window->BltInfo.width;
    windowRect.bottom = window->y + window->BltInfo.height;

    status = CreateNewWindow(winClass, winAttr, &windowRect, &window->window);
    CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateNewWindow Failed", GL_FALSE);

    /* We set a title for debugging purposes */
    CFStringRef title_string;
    title_string = CFStringCreateWithCStringNoCopy(NULL, window->title,
                                                   kCFStringEncodingMacRoman, NULL);
    SetWindowTitleWithCFString(window->BltInfo.window, title_string);
    CFRelease(title_string);

    /* The parent has to be in its own group */
    WindowRef parent = NULL;
    if (render_spu_parent_window_id)
    {
        parent = HIViewGetWindow ((HIViewRef)render_spu_parent_window_id);
        SetWindowGroup (parent, render_spu.pParentGroup);

    }

    /* Add the new window to the master group */
    SetWindowGroup(window->window, render_spu.pMasterGroup);

    /* This will be initialized on the first attempt to attach the global
     * context to this new window */
    window->bufferName = -1;
    window->dummyContext = NULL;
    window->hVisibleRegion = 0;

    if(showIt)
        renderspu_SystemShowWindow(window, GL_TRUE);

    crDebug("Render SPU (renderspu_SystemVBoxCreateWindow): actual window (x, y, width, height): %d, %d, %d, %d",
            window->x, window->y, window->BltInfo.width, window->BltInfo.height);

    return GL_TRUE;
}