VirtualBox

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

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

crOpenGL-OSX: Initial version for the Cocoa port.

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