VirtualBox

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

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

OpenGL-OSX: fix crash on headless when 3D is enabled

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 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
26GLboolean renderspu_SystemInitVisual(VisualInfo *pVisInfo)
27{
28 CRASSERT(pVisInfo);
29
30/* cocoaGLVisualCreate(&pCtxInfo->context);*/
31
32 return GL_TRUE;
33}
34
35GLboolean renderspu_SystemCreateContext(VisualInfo *pVisInfo, ContextInfo *pCtxInfo, ContextInfo *pShharedCtxInfo)
36{
37 CRASSERT(pVisInfo);
38 CRASSERT(pCtxInfo);
39
40 pCtxInfo->currentWindow = NULL;
41
42 cocoaGLCtxCreate(&pCtxInfo->context, pVisInfo->visAttribs);
43
44 return GL_TRUE;
45}
46
47void renderspu_SystemDestroyContext(ContextInfo *pCtxInfo)
48{
49 if(!pCtxInfo)
50 return;
51
52 if(pCtxInfo->context)
53 {
54 cocoaGLCtxDestroy(pCtxInfo->context);
55 pCtxInfo->context = NULL;
56 }
57}
58
59void renderspuFullscreen(WindowInfo *pWinInfo, GLboolean fFullscreen)
60{
61 /* Real fullscreen isn't supported by VirtualBox */
62}
63
64GLboolean renderspu_SystemVBoxCreateWindow(VisualInfo *pVisInfo, GLboolean fShowIt, WindowInfo *pWinInfo)
65{
66 CRASSERT(pVisInfo);
67 CRASSERT(pWinInfo);
68
69 pWinInfo->visual = pVisInfo;
70 pWinInfo->window = NULL;
71 pWinInfo->nativeWindow = NULL;
72 pWinInfo->currentCtx = NULL;
73
74#ifdef __LP64__
75 NativeViewRef pParentWin = (NativeViewRef)render_spu_parent_window_id;
76#else /* __LP64__ */
77 NativeViewRef pParentWin = (NativeViewRef)(uint32_t)render_spu_parent_window_id;
78#endif /* __LP64__ */
79
80 if (!pParentWin)
81 return GL_FALSE;
82
83 cocoaViewCreate(&pWinInfo->window, pParentWin, pVisInfo->visAttribs);
84
85 if (fShowIt)
86 renderspu_SystemShowWindow(pWinInfo, fShowIt);
87
88 return GL_TRUE;
89}
90
91void renderspu_SystemDestroyWindow(WindowInfo *pWinInfo)
92{
93 CRASSERT(pWinInfo);
94
95 cocoaViewDestroy(pWinInfo->window);
96}
97
98void renderspu_SystemWindowPosition(WindowInfo *pWinInfo, GLint x, GLint y)
99{
100 CRASSERT(pWinInfo);
101
102#ifdef __LP64__
103 NativeViewRef pParentWin = (NativeViewRef)render_spu_parent_window_id;
104#else /* __LP64__ */
105 NativeViewRef pParentWin = (NativeViewRef)(uint32_t)render_spu_parent_window_id;
106#endif /* __LP64__ */
107
108 cocoaViewSetPosition(pWinInfo->window, pParentWin, x, y);
109}
110
111void renderspu_SystemWindowSize(WindowInfo *pWinInfo, GLint w, GLint h)
112{
113 CRASSERT(pWinInfo);
114
115 cocoaViewSetSize(pWinInfo->window, w, h);
116}
117
118void renderspu_SystemGetWindowGeometry(WindowInfo *pWinInfo, GLint *pX, GLint *pY, GLint *pW, GLint *pH)
119{
120 CRASSERT(pWinInfo);
121
122 cocoaViewGetGeometry(pWinInfo->window, pX, pY, pW, pH);
123}
124
125void renderspu_SystemGetMaxWindowSize(WindowInfo *pWinInfo, GLint *pW, GLint *pH)
126{
127 CRASSERT(pWinInfo);
128
129 *pW = 10000;
130 *pH = 10000;
131}
132
133void renderspu_SystemShowWindow(WindowInfo *pWinInfo, GLboolean fShowIt)
134{
135 CRASSERT(pWinInfo);
136
137 cocoaViewShow(pWinInfo->window, fShowIt);
138}
139
140void renderspu_SystemMakeCurrent(WindowInfo *pWinInfo, GLint nativeWindow, ContextInfo *pCtxInfo)
141{
142 CRASSERT(pWinInfo);
143 CRASSERT(pCtxInfo);
144
145/* if(pWinInfo->visual != pCtxInfo->visual)*/
146/* printf ("visual mismatch .....................\n");*/
147
148 cocoaViewMakeCurrentContext(pWinInfo->window, pCtxInfo->context);
149}
150
151void renderspu_SystemSwapBuffers(WindowInfo *pWinInfo, GLint flags)
152{
153 CRASSERT(pWinInfo);
154
155 cocoaViewDisplay(pWinInfo->window);
156}
157
158void renderspu_SystemWindowVisibleRegion(WindowInfo *pWinInfo, GLint cRects, GLint* paRects)
159{
160 CRASSERT(pWinInfo);
161
162 cocoaViewSetVisibleRegion(pWinInfo->window, cRects, paRects);
163}
164
165void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *paRects)
166{
167}
168
169void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *pWinInfo)
170{
171}
172
173void renderspu_SystemFlush()
174{
175 cocoaFlush();
176}
177
178void renderspu_SystemFinish()
179{
180 cocoaFinish();
181}
182
183void renderspu_SystemBindFramebufferEXT(GLenum target, GLuint framebuffer)
184{
185 cocoaBindFramebufferEXT(target, framebuffer);
186}
187
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