VirtualBox

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

Last change on this file since 28279 was 28279, checked in by vboxsync, 15 years ago

crOpenGl;FE/Qt4: added initial 3D support on OSX for the mutli-monitor case (the dock still needs some work)

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

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