renderspu_cocoa.c revision 213c5dfc7af9761148fff0e821ce2b8f5ab2f60d
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * VirtualBox OpenGL Cocoa Window System implementation
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Copyright (C) 2009 Oracle Corporation
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * This file is part of VirtualBox Open Source Edition (OSE), as
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * available from http://www.virtualbox.org. This file is free software;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * you can redistribute it and/or modify it under the terms of the GNU
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * General Public License (GPL) as published by the Free Software
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * Foundation, in version 2 as it comes in the "COPYING" file of the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. MaskeyGLboolean renderspu_SystemInitVisual(VisualInfo *pVisInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/* cocoaGLVisualCreate(&pCtxInfo->context);*/
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. MaskeyGLboolean renderspu_SystemCreateContext(VisualInfo *pVisInfo, ContextInfo *pCtxInfo, ContextInfo *pSharedCtxInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaGLCtxCreate(&pCtxInfo->context, pVisInfo->visAttribs, pSharedCtxInfo ? pSharedCtxInfo->context : NULL);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemDestroyContext(ContextInfo *pCtxInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspuFullscreen(WindowInfo *pWinInfo, GLboolean fFullscreen)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey /* Real fullscreen isn't supported by VirtualBox */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. MaskeyGLboolean renderspu_SystemVBoxCreateWindow(VisualInfo *pVisInfo, GLboolean fShowIt, WindowInfo *pWinInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey /* VirtualBox is the only frontend which support 3D right now. */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if (RTProcGetExecutablePath(pszName, sizeof(pszName)))
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey /* Check for VirtualBox and VirtualBoxVM */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey if (RTStrNICmp(RTPathFilename(pszName), "VirtualBox", 10) != 0)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#else /* __LP64__ */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#endif /* __LP64__ */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaViewCreate(&pWinInfo->window, pParentWin, pVisInfo->visAttribs);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey renderspu_SystemShowWindow(pWinInfo, fShowIt);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemReparentWindow(WindowInfo *pWinInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#else /* __LP64__ */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#endif /* __LP64__ */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaViewReparent(pWinInfo->window, pParentWin);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemDestroyWindow(WindowInfo *pWinInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemWindowPosition(WindowInfo *pWinInfo, GLint x, GLint y)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#else /* __LP64__ */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey#endif /* __LP64__ */
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey /*pParentWin is unused in the call, otherwise it might hold incorrect value if for ex. last reparent call was for
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey a different screen*/
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaViewSetPosition(pWinInfo->window, pParentWin, x, y);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemWindowSize(WindowInfo *pWinInfo, GLint w, GLint h)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemGetWindowGeometry(WindowInfo *pWinInfo, GLint *pX, GLint *pY, GLint *pW, GLint *pH)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaViewGetGeometry(pWinInfo->window, pX, pY, pW, pH);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemGetMaxWindowSize(WindowInfo *pWinInfo, GLint *pW, GLint *pH)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemShowWindow(WindowInfo *pWinInfo, GLboolean fShowIt)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemMakeCurrent(WindowInfo *pWinInfo, GLint nativeWindow, ContextInfo *pCtxInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/* if(pWinInfo->visual != pCtxInfo->visual)*/
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey/* printf ("visual mismatch .....................\n");*/
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaViewMakeCurrentContext(pWinInfo->window, pCtxInfo->context);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemSwapBuffers(WindowInfo *pWinInfo, GLint flags)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemWindowVisibleRegion(WindowInfo *pWinInfo, GLint cRects, GLint* paRects)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaViewSetVisibleRegion(pWinInfo->window, cRects, paRects);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *paRects)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemWindowApplyVisibleRegion(WindowInfo *pWinInfo)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemBindFramebufferEXT(GLenum target, GLuint framebuffer)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaBindFramebufferEXT(target, framebuffer);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskey cocoaCopyPixels(x, y, width, height, type);
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemGetIntegerv(GLenum pname, GLint * params)
6ba597c56d749c61b4f783157f63196d7b2445f0Anurag S. Maskeyvoid renderspu_SystemReadBuffer(GLenum mode)