3
* VBox frontends: Qt GUI ("VirtualBox"):
4
* OpenGL support info used for 2D support detection
8
* Copyright (C) 2009 Sun Microsystems, Inc.
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.
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.
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.
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.
31
#ifndef __VBoxGLSupportInfo_h__
32
#define __VBoxGLSupportInfo_h__
34
#include <iprt/types.h>
38
#ifndef GL_COMPILE_STATUS
39
# define GL_COMPILE_STATUS 0x8b81
41
#ifndef GL_LINK_STATUS
42
# define GL_LINK_STATUS 0x8b82
44
#ifndef GL_FRAGMENT_SHADER
45
# define GL_FRAGMENT_SHADER 0x8b30
47
#ifndef GL_VERTEX_SHADER
48
# define GL_VERTEX_SHADER 0x8b31
51
/* GL_ARB_multitexture */
53
# define GL_TEXTURE0 0x84c0
56
# define GL_TEXTURE1 0x84c1
58
#ifndef GL_MAX_TEXTURE_COORDS
59
# define GL_MAX_TEXTURE_COORDS 0x8871
61
#ifndef GL_MAX_TEXTURE_IMAGE_UNITS
62
# define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
69
typedef GLvoid (APIENTRY *PFNVBOXVHWA_ACTIVE_TEXTURE) (GLenum texture);
70
typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2I) (GLenum texture, GLint v0, GLint v1);
71
typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2F) (GLenum texture, GLfloat v0, GLfloat v1);
72
typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2D) (GLenum texture, GLdouble v0, GLdouble v1);
74
/* GL_ARB_texture_rectangle */
75
#ifndef GL_TEXTURE_RECTANGLE
76
# define GL_TEXTURE_RECTANGLE 0x84F5
79
/* GL_ARB_shader_objects */
80
/* GL_ARB_fragment_shader */
82
typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_SHADER) (GLenum type);
83
typedef GLvoid (APIENTRY *PFNVBOXVHWA_SHADER_SOURCE) (GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
84
typedef GLvoid (APIENTRY *PFNVBOXVHWA_COMPILE_SHADER) (GLuint shader);
85
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_SHADER) (GLuint shader);
87
typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_PROGRAM) ();
88
typedef GLvoid (APIENTRY *PFNVBOXVHWA_ATTACH_SHADER) (GLuint program, GLuint shader);
89
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DETACH_SHADER) (GLuint program, GLuint shader);
90
typedef GLvoid (APIENTRY *PFNVBOXVHWA_LINK_PROGRAM) (GLuint program);
91
typedef GLvoid (APIENTRY *PFNVBOXVHWA_USE_PROGRAM) (GLuint program);
92
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_PROGRAM) (GLuint program);
94
typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_SHADER) (GLuint shader);
95
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADERIV) (GLuint shader, GLenum pname, GLint *params);
96
typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_PROGRAM) (GLuint program);
97
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAMIV) (GLuint program, GLenum pname, GLint *params);
98
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_ATTACHED_SHADERS) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
99
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADER_INFO_LOG) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
100
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAM_INFO_LOG) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
101
typedef GLint (APIENTRY *PFNVBOXVHWA_GET_UNIFORM_LOCATION) (GLint programObj, const GLchar *name);
103
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1F)(GLint location, GLfloat v0);
104
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2F)(GLint location, GLfloat v0, GLfloat v1);
105
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
106
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
108
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1I)(GLint location, GLint v0);
109
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2I)(GLint location, GLint v0, GLint v1);
110
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3I)(GLint location, GLint v0, GLint v1, GLint v2);
111
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4I)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
113
/* GL_ARB_pixel_buffer_object*/
115
/* apears to be defined on mac */
116
typedef ptrdiff_t GLsizeiptr;
120
# define GL_READ_ONLY 0x88B8
122
#ifndef GL_WRITE_ONLY
123
# define GL_WRITE_ONLY 0x88B9
125
#ifndef GL_READ_WRITE
126
# define GL_READ_WRITE 0x88BA
128
#ifndef GL_STREAM_DRAW
129
# define GL_STREAM_DRAW 0x88E0
131
#ifndef GL_STREAM_READ
132
# define GL_STREAM_READ 0x88E1
134
#ifndef GL_STREAM_COPY
135
# define GL_STREAM_COPY 0x88E2
138
#ifndef GL_PIXEL_PACK_BUFFER
139
# define GL_PIXEL_PACK_BUFFER 0x88EB
141
#ifndef GL_PIXEL_UNPACK_BUFFER
142
# define GL_PIXEL_UNPACK_BUFFER 0x88EC
144
#ifndef GL_PIXEL_PACK_BUFFER_BINDING
145
# define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
147
#ifndef GL_PIXEL_UNPACK_BUFFER_BINDING
148
# define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
151
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GEN_BUFFERS)(GLsizei n, GLuint *buffers);
152
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_BUFFERS)(GLsizei n, const GLuint *buffers);
153
typedef GLvoid (APIENTRY *PFNVBOXVHWA_BIND_BUFFER)(GLenum target, GLuint buffer);
154
typedef GLvoid (APIENTRY *PFNVBOXVHWA_BUFFER_DATA)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
155
typedef GLvoid* (APIENTRY *PFNVBOXVHWA_MAP_BUFFER)(GLenum target, GLenum access);
156
typedef GLboolean (APIENTRY *PFNVBOXVHWA_UNMAP_BUFFER)(GLenum target);
163
/* @todo: move those to VBoxGLInfo class instance members ??? */
164
extern PFNVBOXVHWA_ACTIVE_TEXTURE vboxglActiveTexture;
165
extern PFNVBOXVHWA_MULTI_TEX_COORD2I vboxglMultiTexCoord2i;
166
extern PFNVBOXVHWA_MULTI_TEX_COORD2D vboxglMultiTexCoord2d;
167
extern PFNVBOXVHWA_MULTI_TEX_COORD2F vboxglMultiTexCoord2f;
170
extern PFNVBOXVHWA_CREATE_SHADER vboxglCreateShader;
171
extern PFNVBOXVHWA_SHADER_SOURCE vboxglShaderSource;
172
extern PFNVBOXVHWA_COMPILE_SHADER vboxglCompileShader;
173
extern PFNVBOXVHWA_DELETE_SHADER vboxglDeleteShader;
175
extern PFNVBOXVHWA_CREATE_PROGRAM vboxglCreateProgram;
176
extern PFNVBOXVHWA_ATTACH_SHADER vboxglAttachShader;
177
extern PFNVBOXVHWA_DETACH_SHADER vboxglDetachShader;
178
extern PFNVBOXVHWA_LINK_PROGRAM vboxglLinkProgram;
179
extern PFNVBOXVHWA_USE_PROGRAM vboxglUseProgram;
180
extern PFNVBOXVHWA_DELETE_PROGRAM vboxglDeleteProgram;
182
extern PFNVBOXVHWA_IS_SHADER vboxglIsShader;
183
extern PFNVBOXVHWA_GET_SHADERIV vboxglGetShaderiv;
184
extern PFNVBOXVHWA_IS_PROGRAM vboxglIsProgram;
185
extern PFNVBOXVHWA_GET_PROGRAMIV vboxglGetProgramiv;
186
extern PFNVBOXVHWA_GET_ATTACHED_SHADERS vboxglGetAttachedShaders;
187
extern PFNVBOXVHWA_GET_SHADER_INFO_LOG vboxglGetShaderInfoLog;
188
extern PFNVBOXVHWA_GET_PROGRAM_INFO_LOG vboxglGetProgramInfoLog;
190
extern PFNVBOXVHWA_GET_UNIFORM_LOCATION vboxglGetUniformLocation;
192
extern PFNVBOXVHWA_UNIFORM1F vboxglUniform1f;
193
extern PFNVBOXVHWA_UNIFORM2F vboxglUniform2f;
194
extern PFNVBOXVHWA_UNIFORM3F vboxglUniform3f;
195
extern PFNVBOXVHWA_UNIFORM4F vboxglUniform4f;
197
extern PFNVBOXVHWA_UNIFORM1I vboxglUniform1i;
198
extern PFNVBOXVHWA_UNIFORM2I vboxglUniform2i;
199
extern PFNVBOXVHWA_UNIFORM3I vboxglUniform3i;
200
extern PFNVBOXVHWA_UNIFORM4I vboxglUniform4i;
202
extern PFNVBOXVHWA_GEN_BUFFERS vboxglGenBuffers;
203
extern PFNVBOXVHWA_DELETE_BUFFERS vboxglDeleteBuffers;
204
extern PFNVBOXVHWA_BIND_BUFFER vboxglBindBuffer;
205
extern PFNVBOXVHWA_BUFFER_DATA vboxglBufferData;
206
extern PFNVBOXVHWA_MAP_BUFFER vboxglMapBuffer;
207
extern PFNVBOXVHWA_UNMAP_BUFFER vboxglUnmapBuffer;
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),
230
void init(const class QGLContext * pContext);
232
bool isInitialized() const { return mInitialized; }
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; }
242
static int parseVersion(const GLubyte * ver);
244
void initExtSupport(const class QGLContext & context);
247
bool mFragmentShaderSupported;
248
bool mTextureRectangleSupported;
249
bool mTextureNP2Supported;
251
int mMultiTexNumSupported; /* 1 would mean it is not supported */
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;
265
class VBoxGLTmpContext
271
const class QGLContext * makeCurrent();
273
class QGLWidget * mWidget;
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 ))
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
291
mFourccSupportedCount(0),
295
VBoxVHWAInfo(const VBoxGLInfo & glInfo) :
297
mFourccSupportedCount(0),
301
void init(const class QGLContext * pContext);
303
bool isInitialized() const { return mInitialized; }
305
const VBoxGLInfo & getGlInfo() const { return mglInfo; }
307
bool isVHWASupported() const;
309
int getFourccSupportedCount() const { return mFourccSupportedCount; }
310
const uint32_t * getFourccSupportedList() const { return mFourccSupportedList; }
312
static bool checkVHWASupport();
315
uint32_t mFourccSupportedList[VBOXVHWA_NUMFOURCC];
316
int mFourccSupportedCount;
321
#endif /* #ifndef __VBoxGLSupportInfo_h__ */