VirtualBox

source: vbox/trunk/include/VBox/VBoxGL2D.h@ 25149

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

OSE header fixes

File size: 11.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * OpenGL support info used for 2D support detection
5 */
6
7/*
8 * Copyright (C) 2009 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
23 *
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
26 *
27 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
28 * Clara, CA 95054 USA or visit http://www.sun.com if you need
29 * additional information or have any questions.
30 */
31#ifndef __VBoxGLSupportInfo_h__
32#define __VBoxGLSupportInfo_h__
33
34#include <iprt/types.h>
35
36typedef char GLchar;
37
38#ifndef GL_COMPILE_STATUS
39# define GL_COMPILE_STATUS 0x8b81
40#endif
41#ifndef GL_LINK_STATUS
42# define GL_LINK_STATUS 0x8b82
43#endif
44#ifndef GL_FRAGMENT_SHADER
45# define GL_FRAGMENT_SHADER 0x8b30
46#endif
47#ifndef GL_VERTEX_SHADER
48# define GL_VERTEX_SHADER 0x8b31
49#endif
50
51/* GL_ARB_multitexture */
52#ifndef GL_TEXTURE0
53# define GL_TEXTURE0 0x84c0
54#endif
55#ifndef GL_TEXTURE1
56# define GL_TEXTURE1 0x84c1
57#endif
58#ifndef GL_MAX_TEXTURE_COORDS
59# define GL_MAX_TEXTURE_COORDS 0x8871
60#endif
61#ifndef GL_MAX_TEXTURE_IMAGE_UNITS
62# define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
63#endif
64
65#ifndef APIENTRY
66# define APIENTRY
67#endif
68
69typedef GLvoid (APIENTRY *PFNVBOXVHWA_ACTIVE_TEXTURE) (GLenum texture);
70typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2I) (GLenum texture, GLint v0, GLint v1);
71typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2F) (GLenum texture, GLfloat v0, GLfloat v1);
72typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2D) (GLenum texture, GLdouble v0, GLdouble v1);
73
74/* GL_ARB_texture_rectangle */
75#ifndef GL_TEXTURE_RECTANGLE
76# define GL_TEXTURE_RECTANGLE 0x84F5
77#endif
78
79/* GL_ARB_shader_objects */
80/* GL_ARB_fragment_shader */
81
82typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_SHADER) (GLenum type);
83typedef GLvoid (APIENTRY *PFNVBOXVHWA_SHADER_SOURCE) (GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
84typedef GLvoid (APIENTRY *PFNVBOXVHWA_COMPILE_SHADER) (GLuint shader);
85typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_SHADER) (GLuint shader);
86
87typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_PROGRAM) ();
88typedef GLvoid (APIENTRY *PFNVBOXVHWA_ATTACH_SHADER) (GLuint program, GLuint shader);
89typedef GLvoid (APIENTRY *PFNVBOXVHWA_DETACH_SHADER) (GLuint program, GLuint shader);
90typedef GLvoid (APIENTRY *PFNVBOXVHWA_LINK_PROGRAM) (GLuint program);
91typedef GLvoid (APIENTRY *PFNVBOXVHWA_USE_PROGRAM) (GLuint program);
92typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_PROGRAM) (GLuint program);
93
94typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_SHADER) (GLuint shader);
95typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADERIV) (GLuint shader, GLenum pname, GLint *params);
96typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_PROGRAM) (GLuint program);
97typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAMIV) (GLuint program, GLenum pname, GLint *params);
98typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_ATTACHED_SHADERS) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
99typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADER_INFO_LOG) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
100typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAM_INFO_LOG) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
101typedef GLint (APIENTRY *PFNVBOXVHWA_GET_UNIFORM_LOCATION) (GLint programObj, const GLchar *name);
102
103typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1F)(GLint location, GLfloat v0);
104typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2F)(GLint location, GLfloat v0, GLfloat v1);
105typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
106typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
107
108typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1I)(GLint location, GLint v0);
109typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2I)(GLint location, GLint v0, GLint v1);
110typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3I)(GLint location, GLint v0, GLint v1, GLint v2);
111typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4I)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
112
113/* GL_ARB_pixel_buffer_object*/
114#ifndef Q_WS_MAC
115/* apears to be defined on mac */
116typedef ptrdiff_t GLsizeiptr;
117#endif
118
119#ifndef GL_READ_ONLY
120# define GL_READ_ONLY 0x88B8
121#endif
122#ifndef GL_WRITE_ONLY
123# define GL_WRITE_ONLY 0x88B9
124#endif
125#ifndef GL_READ_WRITE
126# define GL_READ_WRITE 0x88BA
127#endif
128#ifndef GL_STREAM_DRAW
129# define GL_STREAM_DRAW 0x88E0
130#endif
131#ifndef GL_STREAM_READ
132# define GL_STREAM_READ 0x88E1
133#endif
134#ifndef GL_STREAM_COPY
135# define GL_STREAM_COPY 0x88E2
136#endif
137
138#ifndef GL_PIXEL_PACK_BUFFER
139# define GL_PIXEL_PACK_BUFFER 0x88EB
140#endif
141#ifndef GL_PIXEL_UNPACK_BUFFER
142# define GL_PIXEL_UNPACK_BUFFER 0x88EC
143#endif
144#ifndef GL_PIXEL_PACK_BUFFER_BINDING
145# define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
146#endif
147#ifndef GL_PIXEL_UNPACK_BUFFER_BINDING
148# define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
149#endif
150
151typedef GLvoid (APIENTRY *PFNVBOXVHWA_GEN_BUFFERS)(GLsizei n, GLuint *buffers);
152typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_BUFFERS)(GLsizei n, const GLuint *buffers);
153typedef GLvoid (APIENTRY *PFNVBOXVHWA_BIND_BUFFER)(GLenum target, GLuint buffer);
154typedef GLvoid (APIENTRY *PFNVBOXVHWA_BUFFER_DATA)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
155typedef GLvoid* (APIENTRY *PFNVBOXVHWA_MAP_BUFFER)(GLenum target, GLenum access);
156typedef GLboolean (APIENTRY *PFNVBOXVHWA_UNMAP_BUFFER)(GLenum target);
157
158
159/*****************/
160
161/* functions */
162
163/* @todo: move those to VBoxGLInfo class instance members ??? */
164extern PFNVBOXVHWA_ACTIVE_TEXTURE vboxglActiveTexture;
165extern PFNVBOXVHWA_MULTI_TEX_COORD2I vboxglMultiTexCoord2i;
166extern PFNVBOXVHWA_MULTI_TEX_COORD2D vboxglMultiTexCoord2d;
167extern PFNVBOXVHWA_MULTI_TEX_COORD2F vboxglMultiTexCoord2f;
168
169
170extern PFNVBOXVHWA_CREATE_SHADER vboxglCreateShader;
171extern PFNVBOXVHWA_SHADER_SOURCE vboxglShaderSource;
172extern PFNVBOXVHWA_COMPILE_SHADER vboxglCompileShader;
173extern PFNVBOXVHWA_DELETE_SHADER vboxglDeleteShader;
174
175extern PFNVBOXVHWA_CREATE_PROGRAM vboxglCreateProgram;
176extern PFNVBOXVHWA_ATTACH_SHADER vboxglAttachShader;
177extern PFNVBOXVHWA_DETACH_SHADER vboxglDetachShader;
178extern PFNVBOXVHWA_LINK_PROGRAM vboxglLinkProgram;
179extern PFNVBOXVHWA_USE_PROGRAM vboxglUseProgram;
180extern PFNVBOXVHWA_DELETE_PROGRAM vboxglDeleteProgram;
181
182extern PFNVBOXVHWA_IS_SHADER vboxglIsShader;
183extern PFNVBOXVHWA_GET_SHADERIV vboxglGetShaderiv;
184extern PFNVBOXVHWA_IS_PROGRAM vboxglIsProgram;
185extern PFNVBOXVHWA_GET_PROGRAMIV vboxglGetProgramiv;
186extern PFNVBOXVHWA_GET_ATTACHED_SHADERS vboxglGetAttachedShaders;
187extern PFNVBOXVHWA_GET_SHADER_INFO_LOG vboxglGetShaderInfoLog;
188extern PFNVBOXVHWA_GET_PROGRAM_INFO_LOG vboxglGetProgramInfoLog;
189
190extern PFNVBOXVHWA_GET_UNIFORM_LOCATION vboxglGetUniformLocation;
191
192extern PFNVBOXVHWA_UNIFORM1F vboxglUniform1f;
193extern PFNVBOXVHWA_UNIFORM2F vboxglUniform2f;
194extern PFNVBOXVHWA_UNIFORM3F vboxglUniform3f;
195extern PFNVBOXVHWA_UNIFORM4F vboxglUniform4f;
196
197extern PFNVBOXVHWA_UNIFORM1I vboxglUniform1i;
198extern PFNVBOXVHWA_UNIFORM2I vboxglUniform2i;
199extern PFNVBOXVHWA_UNIFORM3I vboxglUniform3i;
200extern PFNVBOXVHWA_UNIFORM4I vboxglUniform4i;
201
202extern PFNVBOXVHWA_GEN_BUFFERS vboxglGenBuffers;
203extern PFNVBOXVHWA_DELETE_BUFFERS vboxglDeleteBuffers;
204extern PFNVBOXVHWA_BIND_BUFFER vboxglBindBuffer;
205extern PFNVBOXVHWA_BUFFER_DATA vboxglBufferData;
206extern PFNVBOXVHWA_MAP_BUFFER vboxglMapBuffer;
207extern PFNVBOXVHWA_UNMAP_BUFFER vboxglUnmapBuffer;
208
209class VBoxGLInfo
210{
211public:
212 VBoxGLInfo() :
213 mGLVersion(0),
214 mFragmentShaderSupported(false),
215 mTextureRectangleSupported(false),
216 mTextureNP2Supported(false),
217 mPBOSupported(false),
218 mMultiTexNumSupported(1), /* 1 would mean it is not supported */
219 m_GL_ARB_multitexture(false),
220 m_GL_ARB_shader_objects(false),
221 m_GL_ARB_fragment_shader(false),
222 m_GL_ARB_pixel_buffer_object(false),
223 m_GL_ARB_texture_rectangle(false),
224 m_GL_EXT_texture_rectangle(false),
225 m_GL_NV_texture_rectangle(false),
226 m_GL_ARB_texture_non_power_of_two(false),
227 mInitialized(false)
228 {}
229
230 void init(const class QGLContext * pContext);
231
232 bool isInitialized() const { return mInitialized; }
233
234 int getGLVersion() const { return mGLVersion; }
235 bool isFragmentShaderSupported() const { return mFragmentShaderSupported; }
236 bool isTextureRectangleSupported() const { return mTextureRectangleSupported; }
237 bool isTextureNP2Supported() const { return mTextureNP2Supported; }
238 bool isPBOSupported() const { return mPBOSupported; }
239 /* 1 would mean it is not supported */
240 int getMultiTexNumSupported() const { return mMultiTexNumSupported; }
241
242 static int parseVersion(const GLubyte * ver);
243private:
244 void initExtSupport(const class QGLContext & context);
245
246 int mGLVersion;
247 bool mFragmentShaderSupported;
248 bool mTextureRectangleSupported;
249 bool mTextureNP2Supported;
250 bool mPBOSupported;
251 int mMultiTexNumSupported; /* 1 would mean it is not supported */
252
253 bool m_GL_ARB_multitexture;
254 bool m_GL_ARB_shader_objects;
255 bool m_GL_ARB_fragment_shader;
256 bool m_GL_ARB_pixel_buffer_object;
257 bool m_GL_ARB_texture_rectangle;
258 bool m_GL_EXT_texture_rectangle;
259 bool m_GL_NV_texture_rectangle;
260 bool m_GL_ARB_texture_non_power_of_two;
261
262 bool mInitialized;
263};
264
265class VBoxGLTmpContext
266{
267public:
268 VBoxGLTmpContext();
269 ~VBoxGLTmpContext();
270
271 const class QGLContext * makeCurrent();
272private:
273 class QGLWidget * mWidget;
274};
275
276
277#define VBOXQGL_MAKEFOURCC(ch0, ch1, ch2, ch3) \
278 ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
279 ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
280
281#define FOURCC_AYUV VBOXQGL_MAKEFOURCC('A', 'Y', 'U', 'V')
282#define FOURCC_UYVY VBOXQGL_MAKEFOURCC('U', 'Y', 'V', 'Y')
283#define FOURCC_YUY2 VBOXQGL_MAKEFOURCC('Y', 'U', 'Y', '2')
284#define FOURCC_YV12 VBOXQGL_MAKEFOURCC('Y', 'V', '1', '2')
285#define VBOXVHWA_NUMFOURCC 4
286
287class VBoxVHWAInfo
288{
289public:
290 VBoxVHWAInfo() :
291 mFourccSupportedCount(0),
292 mInitialized(false)
293 {}
294
295 VBoxVHWAInfo(const VBoxGLInfo & glInfo) :
296 mglInfo(glInfo),
297 mFourccSupportedCount(0),
298 mInitialized(false)
299 {}
300
301 void init(const class QGLContext * pContext);
302
303 bool isInitialized() const { return mInitialized; }
304
305 const VBoxGLInfo & getGlInfo() const { return mglInfo; }
306
307 bool isVHWASupported() const;
308
309 int getFourccSupportedCount() const { return mFourccSupportedCount; }
310 const uint32_t * getFourccSupportedList() const { return mFourccSupportedList; }
311
312 static bool checkVHWASupport();
313private:
314 VBoxGLInfo mglInfo;
315 uint32_t mFourccSupportedList[VBOXVHWA_NUMFOURCC];
316 int mFourccSupportedCount;
317
318 bool mInitialized;
319};
320
321#endif /* #ifndef __VBoxGLSupportInfo_h__ */
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