VirtualBox

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

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

include: svn:eol-style.

  • Property svn:eol-style set to native
File size: 13.9 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#ifndef GL_DYNAMIC_DRAW
138# define GL_DYNAMIC_DRAW 0x88E8
139#endif
140
141#ifndef GL_PIXEL_PACK_BUFFER
142# define GL_PIXEL_PACK_BUFFER 0x88EB
143#endif
144#ifndef GL_PIXEL_UNPACK_BUFFER
145# define GL_PIXEL_UNPACK_BUFFER 0x88EC
146#endif
147#ifndef GL_PIXEL_PACK_BUFFER_BINDING
148# define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
149#endif
150#ifndef GL_PIXEL_UNPACK_BUFFER_BINDING
151# define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
152#endif
153
154typedef GLvoid (APIENTRY *PFNVBOXVHWA_GEN_BUFFERS)(GLsizei n, GLuint *buffers);
155typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_BUFFERS)(GLsizei n, const GLuint *buffers);
156typedef GLvoid (APIENTRY *PFNVBOXVHWA_BIND_BUFFER)(GLenum target, GLuint buffer);
157typedef GLvoid (APIENTRY *PFNVBOXVHWA_BUFFER_DATA)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
158typedef GLvoid* (APIENTRY *PFNVBOXVHWA_MAP_BUFFER)(GLenum target, GLenum access);
159typedef GLboolean (APIENTRY *PFNVBOXVHWA_UNMAP_BUFFER)(GLenum target);
160
161/* GL_EXT_framebuffer_object */
162#ifndef GL_FRAMEBUFFER
163# define GL_FRAMEBUFFER 0x8D40
164#endif
165#ifndef GL_COLOR_ATTACHMENT0
166# define GL_COLOR_ATTACHMENT0 0x8CE0
167#endif
168
169typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_FRAMEBUFFER)(GLuint framebuffer);
170typedef GLvoid (APIENTRY *PFNVBOXVHWA_BIND_FRAMEBUFFER)(GLenum target, GLuint framebuffer);
171typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_FRAMEBUFFERS)(GLsizei n, const GLuint *framebuffers);
172typedef GLvoid (APIENTRY *PFNVBOXVHWA_GEN_FRAMEBUFFERS)(GLsizei n, GLuint *framebuffers);
173typedef GLenum (APIENTRY *PFNVBOXVHWA_CHECK_FRAMEBUFFER_STATUS)(GLenum target);
174typedef GLvoid (APIENTRY *PFNVBOXVHWA_FRAMEBUFFER_TEXTURE1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
175typedef GLvoid (APIENTRY *PFNVBOXVHWA_FRAMEBUFFER_TEXTURE2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
176typedef GLvoid (APIENTRY *PFNVBOXVHWA_FRAMEBUFFER_TEXTURE3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
177typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_FRAMEBUFFER_ATTACHMENT_PARAMETRIV)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
178
179
180/*****************/
181
182/* functions */
183
184/* @todo: move those to VBoxGLInfo class instance members ??? */
185extern PFNVBOXVHWA_ACTIVE_TEXTURE vboxglActiveTexture;
186extern PFNVBOXVHWA_MULTI_TEX_COORD2I vboxglMultiTexCoord2i;
187extern PFNVBOXVHWA_MULTI_TEX_COORD2D vboxglMultiTexCoord2d;
188extern PFNVBOXVHWA_MULTI_TEX_COORD2F vboxglMultiTexCoord2f;
189
190
191extern PFNVBOXVHWA_CREATE_SHADER vboxglCreateShader;
192extern PFNVBOXVHWA_SHADER_SOURCE vboxglShaderSource;
193extern PFNVBOXVHWA_COMPILE_SHADER vboxglCompileShader;
194extern PFNVBOXVHWA_DELETE_SHADER vboxglDeleteShader;
195
196extern PFNVBOXVHWA_CREATE_PROGRAM vboxglCreateProgram;
197extern PFNVBOXVHWA_ATTACH_SHADER vboxglAttachShader;
198extern PFNVBOXVHWA_DETACH_SHADER vboxglDetachShader;
199extern PFNVBOXVHWA_LINK_PROGRAM vboxglLinkProgram;
200extern PFNVBOXVHWA_USE_PROGRAM vboxglUseProgram;
201extern PFNVBOXVHWA_DELETE_PROGRAM vboxglDeleteProgram;
202
203extern PFNVBOXVHWA_IS_SHADER vboxglIsShader;
204extern PFNVBOXVHWA_GET_SHADERIV vboxglGetShaderiv;
205extern PFNVBOXVHWA_IS_PROGRAM vboxglIsProgram;
206extern PFNVBOXVHWA_GET_PROGRAMIV vboxglGetProgramiv;
207extern PFNVBOXVHWA_GET_ATTACHED_SHADERS vboxglGetAttachedShaders;
208extern PFNVBOXVHWA_GET_SHADER_INFO_LOG vboxglGetShaderInfoLog;
209extern PFNVBOXVHWA_GET_PROGRAM_INFO_LOG vboxglGetProgramInfoLog;
210
211extern PFNVBOXVHWA_GET_UNIFORM_LOCATION vboxglGetUniformLocation;
212
213extern PFNVBOXVHWA_UNIFORM1F vboxglUniform1f;
214extern PFNVBOXVHWA_UNIFORM2F vboxglUniform2f;
215extern PFNVBOXVHWA_UNIFORM3F vboxglUniform3f;
216extern PFNVBOXVHWA_UNIFORM4F vboxglUniform4f;
217
218extern PFNVBOXVHWA_UNIFORM1I vboxglUniform1i;
219extern PFNVBOXVHWA_UNIFORM2I vboxglUniform2i;
220extern PFNVBOXVHWA_UNIFORM3I vboxglUniform3i;
221extern PFNVBOXVHWA_UNIFORM4I vboxglUniform4i;
222
223extern PFNVBOXVHWA_GEN_BUFFERS vboxglGenBuffers;
224extern PFNVBOXVHWA_DELETE_BUFFERS vboxglDeleteBuffers;
225extern PFNVBOXVHWA_BIND_BUFFER vboxglBindBuffer;
226extern PFNVBOXVHWA_BUFFER_DATA vboxglBufferData;
227extern PFNVBOXVHWA_MAP_BUFFER vboxglMapBuffer;
228extern PFNVBOXVHWA_UNMAP_BUFFER vboxglUnmapBuffer;
229
230extern PFNVBOXVHWA_IS_FRAMEBUFFER vboxglIsFramebuffer;
231extern PFNVBOXVHWA_BIND_FRAMEBUFFER vboxglBindFramebuffer;
232extern PFNVBOXVHWA_DELETE_FRAMEBUFFERS vboxglDeleteFramebuffers;
233extern PFNVBOXVHWA_GEN_FRAMEBUFFERS vboxglGenFramebuffers;
234extern PFNVBOXVHWA_CHECK_FRAMEBUFFER_STATUS vboxglCheckFramebufferStatus;
235extern PFNVBOXVHWA_FRAMEBUFFER_TEXTURE1D vboxglFramebufferTexture1D;
236extern PFNVBOXVHWA_FRAMEBUFFER_TEXTURE2D vboxglFramebufferTexture2D;
237extern PFNVBOXVHWA_FRAMEBUFFER_TEXTURE3D vboxglFramebufferTexture3D;
238extern PFNVBOXVHWA_GET_FRAMEBUFFER_ATTACHMENT_PARAMETRIV vboxglGetFramebufferAttachmentParameteriv;
239
240
241class VBoxGLInfo
242{
243public:
244 VBoxGLInfo() :
245 mGLVersion(0),
246 mFragmentShaderSupported(false),
247 mTextureRectangleSupported(false),
248 mTextureNP2Supported(false),
249 mPBOSupported(false),
250 mFBOSupported(false),
251 mMultiTexNumSupported(1), /* 1 would mean it is not supported */
252 m_GL_ARB_multitexture(false),
253 m_GL_ARB_shader_objects(false),
254 m_GL_ARB_fragment_shader(false),
255 m_GL_ARB_pixel_buffer_object(false),
256 m_GL_ARB_texture_rectangle(false),
257 m_GL_EXT_texture_rectangle(false),
258 m_GL_NV_texture_rectangle(false),
259 m_GL_ARB_texture_non_power_of_two(false),
260 m_GL_EXT_framebuffer_object(false),
261 mInitialized(false)
262 {}
263
264 void init(const class QGLContext * pContext);
265
266 bool isInitialized() const { return mInitialized; }
267
268 int getGLVersion() const { return mGLVersion; }
269 bool isFragmentShaderSupported() const { return mFragmentShaderSupported; }
270 bool isTextureRectangleSupported() const { return mTextureRectangleSupported; }
271 bool isTextureNP2Supported() const { return mTextureNP2Supported; }
272 bool isPBOSupported() const { return mPBOSupported; }
273 /* some ATI drivers do not seem to support non-zero offsets when dealing with PBOs
274 * @todo: add a check for that, always unsupported currently */
275 bool isPBOOffsetSupported() const { return false; }
276 bool isFBOSupported() const { return mFBOSupported; }
277 /* 1 would mean it is not supported */
278 int getMultiTexNumSupported() const { return mMultiTexNumSupported; }
279
280 static int parseVersion(const GLubyte * ver);
281private:
282 void initExtSupport(const class QGLContext & context);
283
284 int mGLVersion;
285 bool mFragmentShaderSupported;
286 bool mTextureRectangleSupported;
287 bool mTextureNP2Supported;
288 bool mPBOSupported;
289 bool mFBOSupported;
290 int mMultiTexNumSupported; /* 1 would mean it is not supported */
291
292 bool m_GL_ARB_multitexture;
293 bool m_GL_ARB_shader_objects;
294 bool m_GL_ARB_fragment_shader;
295 bool m_GL_ARB_pixel_buffer_object;
296 bool m_GL_ARB_texture_rectangle;
297 bool m_GL_EXT_texture_rectangle;
298 bool m_GL_NV_texture_rectangle;
299 bool m_GL_ARB_texture_non_power_of_two;
300 bool m_GL_EXT_framebuffer_object;
301
302 bool mInitialized;
303};
304
305class VBoxGLTmpContext
306{
307public:
308 VBoxGLTmpContext();
309 ~VBoxGLTmpContext();
310
311 const class QGLContext * makeCurrent();
312private:
313 class QGLWidget * mWidget;
314};
315
316
317#define VBOXQGL_MAKEFOURCC(ch0, ch1, ch2, ch3) \
318 ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
319 ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
320
321#define FOURCC_AYUV VBOXQGL_MAKEFOURCC('A', 'Y', 'U', 'V')
322#define FOURCC_UYVY VBOXQGL_MAKEFOURCC('U', 'Y', 'V', 'Y')
323#define FOURCC_YUY2 VBOXQGL_MAKEFOURCC('Y', 'U', 'Y', '2')
324#define FOURCC_YV12 VBOXQGL_MAKEFOURCC('Y', 'V', '1', '2')
325#define VBOXVHWA_NUMFOURCC 4
326
327class VBoxVHWAInfo
328{
329public:
330 VBoxVHWAInfo() :
331 mFourccSupportedCount(0),
332 mInitialized(false)
333 {}
334
335 VBoxVHWAInfo(const VBoxGLInfo & glInfo) :
336 mglInfo(glInfo),
337 mFourccSupportedCount(0),
338 mInitialized(false)
339 {}
340
341 void init(const class QGLContext * pContext);
342
343 bool isInitialized() const { return mInitialized; }
344
345 const VBoxGLInfo & getGlInfo() const { return mglInfo; }
346
347 bool isVHWASupported() const;
348
349 int getFourccSupportedCount() const { return mFourccSupportedCount; }
350 const uint32_t * getFourccSupportedList() const { return mFourccSupportedList; }
351
352 static bool checkVHWASupport();
353private:
354 VBoxGLInfo mglInfo;
355 uint32_t mFourccSupportedList[VBOXVHWA_NUMFOURCC];
356 int mFourccSupportedCount;
357
358 bool mInitialized;
359};
360
361#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