VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c@ 44768

Last change on this file since 44768 was 44766, checked in by vboxsync, 12 years ago

crOpenGL: host 3d window repaint impl for Win host; enable offscreen rendering for Win; 3D window repaint generics

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/** @file
2 * VirtualBox OpenGL Cocoa Window System implementation
3 */
4
5/*
6 * Copyright (C) 2009-2012 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#include <OpenGL/OpenGL.h>
18
19#include "renderspu.h"
20#include <iprt/process.h>
21#include <iprt/string.h>
22#include <iprt/path.h>
23
24GLboolean renderspu_SystemInitVisual(VisualInfo *pVisInfo)
25{
26 CRASSERT(pVisInfo);
27
28/* cocoaGLVisualCreate(&pCtxInfo->context);*/
29
30 return GL_TRUE;
31}
32
33GLboolean renderspu_SystemCreateContext(VisualInfo *pVisInfo, ContextInfo *pCtxInfo, ContextInfo *pSharedCtxInfo)
34{
35 CRASSERT(pVisInfo);
36 CRASSERT(pCtxInfo);
37
38 pCtxInfo->currentWindow = NULL;
39
40 cocoaGLCtxCreate(&pCtxInfo->context, pVisInfo->visAttribs, pSharedCtxInfo ? pSharedCtxInfo->context : NULL);
41
42 return GL_TRUE;
43}
44
45void renderspu_SystemDestroyContext(ContextInfo *pCtxInfo)
46{
47 if(!pCtxInfo)
48 return;
49
50 if(pCtxInfo->context)
51 {
52 cocoaGLCtxDestroy(pCtxInfo->context);
53 pCtxInfo->context = NULL;
54 }
55}
56
57void renderspuFullscreen(WindowInfo *pWinInfo, GLboolean fFullscreen)
58{
59 /* Real fullscreen isn't supported by VirtualBox */
60}
61
62GLboolean renderspu_SystemVBoxCreateWindow(VisualInfo *pVisInfo, GLboolean fShowIt, WindowInfo *pWinInfo)
63{
64 CRASSERT(pVisInfo);
65 CRASSERT(pWinInfo);
66
67 /* VirtualBox is the only frontend which support 3D right now. */
68 char pszName[256];
69 if (RTProcGetExecutablePath(pszName, sizeof(pszName)))
70 /* Check for VirtualBox and VirtualBoxVM */
71 if (RTStrNICmp(RTPathFilename(pszName), "VirtualBox", 10) != 0)
72 return GL_FALSE;
73
74 pWinInfo->visual = pVisInfo;
75 pWinInfo->window = NULL;
76 pWinInfo->nativeWindow = NULL;
77 pWinInfo->currentCtx = NULL;
78
79#ifdef __LP64__
80 NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
81#else /* __LP64__ */
82 NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
83#endif /* __LP64__ */
84
85 cocoaViewCreate(&pWinInfo->window, pParentWin, pVisInfo->visAttribs);
86
87 if (fShowIt)
88 renderspu_SystemShowWindow(pWinInfo, fShowIt);
89
90 return GL_TRUE;
91}
92
93void renderspu_SystemReparentWindow(WindowInfo *pWinInfo)
94{
95#ifdef __LP64__
96 NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
97#else /* __LP64__ */
98 NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
99#endif /* __LP64__ */
100 cocoaViewReparent(pWinInfo->window, pParentWin);
101}
102
103void renderspu_SystemDestroyWindow(WindowInfo *pWinInfo)
104{
105 CRASSERT(pWinInfo);
106
107 cocoaViewDestroy(pWinInfo->window);
108}
109
110void renderspu_SystemWindowPosition(WindowInfo *pWinInfo, GLint x, GLint y)
111{
112 CRASSERT(pWinInfo);
113
114#ifdef __LP64__
115 NativeNSViewRef pParentWin = (NativeNSViewRef)render_spu_parent_window_id;
116#else /* __LP64__ */
117 NativeNSViewRef pParentWin = (NativeNSViewRef)(uint32_t)render_spu_parent_window_id;
118#endif /* __LP64__ */
119
120 /*pParentWin is unused in the call, otherwise it might hold incorrect value if for ex. last reparent call was for
121 a different screen*/
122 cocoaViewSetPosition(pWinInfo->window, pParentWin, x, y);
123}
124
125void renderspu_SystemWindowSize(WindowInfo *pWinInfo, GLint w, GLint h)
126{
127 CRASSERT(pWinInfo);
128
129 cocoaViewSetSize(pWinInfo->window, w, h);
130}
131
132void renderspu_SystemGetWindowGeometry(WindowInfo *pWinInfo, GLint *pX, GLint *pY, GLint *pW, GLint *pH)
133{
134 CRASSERT(pWinInfo);
135
136 cocoaViewGetGeometry(pWinInfo->window, pX, pY, pW, pH);
137}
138
139void renderspu_SystemGetMaxWindowSize(WindowInfo *pWinInfo, GLint *pW, GLint *pH)
140{
141 CRASSERT(pWinInfo);
142
143 *pW = 10000;
144 *pH = 10000;
145}
146
147void renderspu_SystemShowWindow(WindowInfo *pWinInfo, GLboolean fShowIt)
148{
149 CRASSERT(pWinInfo);
150
151 cocoaViewShow(pWinInfo->window, fShowIt);
152}
153
154void renderspu_SystemVBoxPresentComposition( WindowInfo *window, struct VBOXVR_SCR_COMPOSITOR * pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
155{
156 cocoaViewPresentComposition(window->window, pCompositor, pChangedEntry);
157}
158
159void renderspu_SystemMakeCurrent(WindowInfo *pWinInfo, GLint nativeWindow, ContextInfo *pCtxInfo)
160{
161/* if(pWinInfo->visual != pCtxInfo->visual)*/
162/* printf ("visual mismatch .....................\n");*/
163
164 if (pWinInfo && pCtxInfo)
165 cocoaViewMakeCurrentContext(pWinInfo->window, pCtxInfo->context);
166 else
167 cocoaViewMakeCurrentContext(NULL, NULL);
168}
169
170void renderspu_SystemSwapBuffers(WindowInfo *pWinInfo, GLint flags)
171{
172 CRASSERT(pWinInfo);
173
174 cocoaViewDisplay(pWinInfo->window);
175}
176
177void renderspu_SystemWindowVisibleRegion(WindowInfo *pWinInfo, GLint cRects, GLint* paRects)
178{
179 CRASSERT(pWinInfo);
180
181 cocoaViewSetVisibleRegion(pWinInfo->window, cRects, paRects);
182}
183
184void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *paRects)
185{
186}
187
188void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *pWinInfo)
189{
190}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette