VirtualBox

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

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

OpenGL-OSX: better fix of r57145 (#4438 still remains)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 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.virtualbox.org. 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_SystemDestroyWindow(WindowInfo *pWinInfo)
99{
100 CRASSERT(pWinInfo);
101
102 cocoaViewDestroy(pWinInfo->window);
103}
104
105void renderspu_SystemWindowPosition(WindowInfo *pWinInfo, GLint x, GLint y)
106{
107 CRASSERT(pWinInfo);
108
109#ifdef __LP64__
110 NativeViewRef pParentWin = (NativeViewRef)render_spu_parent_window_id;
111#else /* __LP64__ */
112 NativeViewRef pParentWin = (NativeViewRef)(uint32_t)render_spu_parent_window_id;
113#endif /* __LP64__ */
114
115 cocoaViewSetPosition(pWinInfo->window, pParentWin, x, y);
116}
117
118void renderspu_SystemWindowSize(WindowInfo *pWinInfo, GLint w, GLint h)
119{
120 CRASSERT(pWinInfo);
121
122 cocoaViewSetSize(pWinInfo->window, w, h);
123}
124
125void renderspu_SystemGetWindowGeometry(WindowInfo *pWinInfo, GLint *pX, GLint *pY, GLint *pW, GLint *pH)
126{
127 CRASSERT(pWinInfo);
128
129 cocoaViewGetGeometry(pWinInfo->window, pX, pY, pW, pH);
130}
131
132void renderspu_SystemGetMaxWindowSize(WindowInfo *pWinInfo, GLint *pW, GLint *pH)
133{
134 CRASSERT(pWinInfo);
135
136 *pW = 10000;
137 *pH = 10000;
138}
139
140void renderspu_SystemShowWindow(WindowInfo *pWinInfo, GLboolean fShowIt)
141{
142 CRASSERT(pWinInfo);
143
144 cocoaViewShow(pWinInfo->window, fShowIt);
145}
146
147void renderspu_SystemMakeCurrent(WindowInfo *pWinInfo, GLint nativeWindow, ContextInfo *pCtxInfo)
148{
149 CRASSERT(pWinInfo);
150 CRASSERT(pCtxInfo);
151
152/* if(pWinInfo->visual != pCtxInfo->visual)*/
153/* printf ("visual mismatch .....................\n");*/
154
155 cocoaViewMakeCurrentContext(pWinInfo->window, pCtxInfo->context);
156}
157
158void renderspu_SystemSwapBuffers(WindowInfo *pWinInfo, GLint flags)
159{
160 CRASSERT(pWinInfo);
161
162 cocoaViewDisplay(pWinInfo->window);
163}
164
165void renderspu_SystemWindowVisibleRegion(WindowInfo *pWinInfo, GLint cRects, GLint* paRects)
166{
167 CRASSERT(pWinInfo);
168
169 cocoaViewSetVisibleRegion(pWinInfo->window, cRects, paRects);
170}
171
172void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *paRects)
173{
174}
175
176void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *pWinInfo)
177{
178}
179
180void renderspu_SystemFlush()
181{
182 cocoaFlush();
183}
184
185void renderspu_SystemFinish()
186{
187 cocoaFinish();
188}
189
190void renderspu_SystemBindFramebufferEXT(GLenum target, GLuint framebuffer)
191{
192 cocoaBindFramebufferEXT(target, framebuffer);
193}
194
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