QGLFunctions Class
The QGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API. More...
Header: | #include <QGLFunctions> |
qmake: | QT += opengl |
Since: | Qt 4.8 |
This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Public Types
enum | OpenGLFeature { Multitexture, Shaders, Buffers, Framebuffers, ..., NPOTTextures } |
flags | OpenGLFeatures |
Public Functions
QGLFunctions() | |
QGLFunctions(const QGLContext *context) | |
~QGLFunctions() | |
void | glActiveTexture(GLenum texture) |
void | glAttachShader(GLuint program, GLuint shader) |
void | glBindAttribLocation(GLuint program, GLuint index, const char *name) |
void | glBindBuffer(GLenum target, GLuint buffer) |
void | glBindFramebuffer(GLenum target, GLuint framebuffer) |
void | glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
void | glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
void | glBlendEquation(GLenum mode) |
void | glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
void | glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
void | glBufferData(GLenum target, qopengl_GLsizeiptr size, const void *data, GLenum usage) |
void | glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void *data) |
GLenum | glCheckFramebufferStatus(GLenum target) |
void | glClearDepthf(GLclampf depth) |
void | glCompileShader(GLuint shader) |
void | glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data) |
void | glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) |
GLuint | glCreateProgram() |
GLuint | glCreateShader(GLenum type) |
void | glDeleteBuffers(GLsizei n, const GLuint *buffers) |
void | glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers) |
void | glDeleteProgram(GLuint program) |
void | glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) |
void | glDeleteShader(GLuint shader) |
void | glDepthRangef(GLclampf zNear, GLclampf zFar) |
void | glDetachShader(GLuint program, GLuint shader) |
void | glDisableVertexAttribArray(GLuint index) |
void | glEnableVertexAttribArray(GLuint index) |
void | glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
void | glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
void | glGenBuffers(GLsizei n, GLuint *buffers) |
void | glGenFramebuffers(GLsizei n, GLuint *framebuffers) |
void | glGenRenderbuffers(GLsizei n, GLuint *renderbuffers) |
void | glGenerateMipmap(GLenum target) |
void | glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name) |
void | glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name) |
void | glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) |
int | glGetAttribLocation(GLuint program, const char *name) |
void | glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) |
void | glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params) |
void | glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, char *infolog) |
void | glGetProgramiv(GLuint program, GLenum pname, GLint *params) |
void | glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) |
void | glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, char *infolog) |
void | glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision) |
void | glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, char *source) |
void | glGetShaderiv(GLuint shader, GLenum pname, GLint *params) |
int | glGetUniformLocation(GLuint program, const char *name) |
void | glGetUniformfv(GLuint program, GLint location, GLfloat *params) |
void | glGetUniformiv(GLuint program, GLint location, GLint *params) |
void | glGetVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) |
void | glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) |
void | glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params) |
GLboolean | glIsBuffer(GLuint buffer) |
GLboolean | glIsFramebuffer(GLuint framebuffer) |
GLboolean | glIsProgram(GLuint program) |
GLboolean | glIsRenderbuffer(GLuint renderbuffer) |
GLboolean | glIsShader(GLuint shader) |
void | glLinkProgram(GLuint program) |
void | glReleaseShaderCompiler() |
void | glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
void | glSampleCoverage(GLclampf value, GLboolean invert) |
void | glShaderBinary(GLint n, const GLuint *shaders, GLenum binaryformat, const void *binary, GLint length) |
void | glShaderSource(GLuint shader, GLsizei count, const char **string, const GLint *length) |
void | glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
void | glStencilMaskSeparate(GLenum face, GLuint mask) |
void | glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
void | glUniform1f(GLint location, GLfloat x) |
void | glUniform1fv(GLint location, GLsizei count, const GLfloat *v) |
void | glUniform1i(GLint location, GLint x) |
void | glUniform1iv(GLint location, GLsizei count, const GLint *v) |
void | glUniform2f(GLint location, GLfloat x, GLfloat y) |
void | glUniform2fv(GLint location, GLsizei count, const GLfloat *v) |
void | glUniform2i(GLint location, GLint x, GLint y) |
void | glUniform2iv(GLint location, GLsizei count, const GLint *v) |
void | glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
void | glUniform3fv(GLint location, GLsizei count, const GLfloat *v) |
void | glUniform3i(GLint location, GLint x, GLint y, GLint z) |
void | glUniform3iv(GLint location, GLsizei count, const GLint *v) |
void | glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
void | glUniform4fv(GLint location, GLsizei count, const GLfloat *v) |
void | glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
void | glUniform4iv(GLint location, GLsizei count, const GLint *v) |
void | glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
void | glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
void | glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
void | glUseProgram(GLuint program) |
void | glValidateProgram(GLuint program) |
void | glVertexAttrib1f(GLuint indx, GLfloat x) |
void | glVertexAttrib1fv(GLuint indx, const GLfloat *values) |
void | glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) |
void | glVertexAttrib2fv(GLuint indx, const GLfloat *values) |
void | glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) |
void | glVertexAttrib3fv(GLuint indx, const GLfloat *values) |
void | glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
void | glVertexAttrib4fv(GLuint indx, const GLfloat *values) |
void | glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *ptr) |
bool | hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const |
void | initializeGLFunctions(const QGLContext *context = nullptr) |
QGLFunctions::OpenGLFeatures | openGLFeatures() const |
Detailed Description
The QGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
OpenGL ES 2.0 defines a subset of the OpenGL specification that is common across many desktop and embedded OpenGL implementations. However, it can be difficult to use the functions from that subset because they need to be resolved manually on desktop systems.
QGLFunctions provides a guaranteed API that is available on all OpenGL systems and takes care of function resolution on systems that need it. The recommended way to use QGLFunctions is by direct inheritance:
class MyGLWidget : public QGLWidget, protected QGLFunctions { Q_OBJECT public: MyGLWidget(QWidget *parent = 0) : QGLWidget(parent) {} protected: void initializeGL(); void paintGL(); }; void MyGLWidget::initializeGL() { initializeGLFunctions(); }
The paintGL()
function can then use any of the OpenGL ES 2.0 functions without explicit resolution, such as glActiveTexture() in the following example:
void MyGLWidget::paintGL() { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureId); ... }
QGLFunctions can also be used directly for ad-hoc invocation of OpenGL ES 2.0 functions on all platforms:
QGLFunctions glFuncs(QGLContext::currentContext()); glFuncs.glActiveTexture(GL_TEXTURE1);
QGLFunctions provides wrappers for all OpenGL ES 2.0 functions, except those like glDrawArrays()
, glViewport()
, and glBindTexture()
that don't have portability issues.
Including the header for QGLFunctions will also define all of the OpenGL ES 2.0 macro constants that are not already defined by the system's OpenGL headers, such as GL_TEXTURE1
above.
The hasOpenGLFeature() and openGLFeatures() functions can be used to determine if the OpenGL implementation has a major OpenGL ES 2.0 feature. For example, the following checks if non power of two textures are available:
QGLFunctions funcs(QGLContext::currentContext()); bool npot = funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures);
Note: This class has been deprecated in favor of QOpenGLFunctions.
Member Type Documentation
enum QGLFunctions::OpenGLFeature
flags QGLFunctions::OpenGLFeatures
This enum defines OpenGL ES 2.0 features that may be optional on other platforms.
Constant | Value | Description |
---|---|---|
QGLFunctions::Multitexture | 0x0001 | glActiveTexture() function is available. |
QGLFunctions::Shaders | 0x0002 | Shader functions are available. |
QGLFunctions::Buffers | 0x0004 | Vertex and index buffer functions are available. |
QGLFunctions::Framebuffers | 0x0008 | Framebuffer object functions are available. |
QGLFunctions::BlendColor | 0x0010 | glBlendColor() is available. |
QGLFunctions::BlendEquation | 0x0020 | glBlendEquation() is available. |
QGLFunctions::BlendEquationSeparate | 0x0040 | glBlendEquationSeparate() is available. |
QGLFunctions::BlendFuncSeparate | 0x0080 | glBlendFuncSeparate() is available. |
QGLFunctions::BlendSubtract | 0x0100 | Blend subtract mode is available. |
QGLFunctions::CompressedTextures | 0x0200 | Compressed texture functions are available. |
QGLFunctions::Multisample | 0x0400 | glSampleCoverage() function is available. |
QGLFunctions::StencilSeparate | 0x0800 | Separate stencil functions are available. |
QGLFunctions::NPOTTextures | 0x1000 | Non power of two textures are available. |
The OpenGLFeatures type is a typedef for QFlags<OpenGLFeature>. It stores an OR combination of OpenGLFeature values.
Member Function Documentation
QGLFunctions::QGLFunctions()
Constructs a default function resolver. The resolver cannot be used until initializeGLFunctions() is called to specify the context.
See also initializeGLFunctions().
QGLFunctions::QGLFunctions(const QGLContext *context)
Constructs a function resolver for context. If context is null, then the resolver will be created for the current QGLContext.
An object constructed in this way can only be used with context and other contexts that share with it. Use initializeGLFunctions() to change the object's context association.
See also initializeGLFunctions().
QGLFunctions::~QGLFunctions()
Destroys the instance of QGLFunctions.
void QGLFunctions::glActiveTexture(GLenum texture)
void QGLFunctions::glAttachShader(GLuint program, GLuint shader)
void QGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char *name)
void QGLFunctions::glBindBuffer(GLenum target, GLuint buffer)
void QGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer)
void QGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer)
void QGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
void QGLFunctions::glBlendEquation(GLenum mode)
void QGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
void QGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
void QGLFunctions::glBufferData(GLenum target, qopengl_GLsizeiptr size, const void *data, GLenum usage)
void QGLFunctions::glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void *data)
GLenum QGLFunctions::glCheckFramebufferStatus(GLenum target)
void QGLFunctions::glClearDepthf(GLclampf depth)
void QGLFunctions::glCompileShader(GLuint shader)
void QGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data)
void QGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data)
GLuint QGLFunctions::glCreateProgram()
GLuint QGLFunctions::glCreateShader(GLenum type)
void QGLFunctions::glDeleteBuffers(GLsizei n, const GLuint *buffers)
void QGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
void QGLFunctions::glDeleteProgram(GLuint program)
void QGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
void QGLFunctions::glDeleteShader(GLuint shader)
void QGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar)
void QGLFunctions::glDetachShader(GLuint program, GLuint shader)
void QGLFunctions::glDisableVertexAttribArray(GLuint index)
void QGLFunctions::glEnableVertexAttribArray(GLuint index)
void QGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
void QGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
void QGLFunctions::glGenBuffers(GLsizei n, GLuint *buffers)
void QGLFunctions::glGenFramebuffers(GLsizei n, GLuint *framebuffers)
void QGLFunctions::glGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
void QGLFunctions::glGenerateMipmap(GLenum target)
void QGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name)
void QGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name)
void QGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders)
int QGLFunctions::glGetAttribLocation(GLuint program, const char *name)
void QGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
void QGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params)
void QGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, char *infolog)
void QGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint *params)
void QGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
void QGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, char *infolog)
void QGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision)
void QGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, char *source)
void QGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
int QGLFunctions::glGetUniformLocation(GLuint program, const char *name)
void QGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat *params)
void QGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint *params)
void QGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void **pointer)
void QGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
void QGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
GLboolean QGLFunctions::glIsBuffer(GLuint buffer)
GLboolean QGLFunctions::glIsFramebuffer(GLuint framebuffer)
GLboolean QGLFunctions::glIsProgram(GLuint program)
GLboolean QGLFunctions::glIsRenderbuffer(GLuint renderbuffer)
GLboolean QGLFunctions::glIsShader(GLuint shader)
void QGLFunctions::glLinkProgram(GLuint program)
void QGLFunctions::glReleaseShaderCompiler()
void QGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
void QGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert)
void QGLFunctions::glShaderBinary(GLint n, const GLuint *shaders, GLenum binaryformat, const void *binary, GLint length)
void QGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char **string, const GLint *length)
void QGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
void QGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask)
void QGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
void QGLFunctions::glUniform1f(GLint location, GLfloat x)
void QGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat *v)
void QGLFunctions::glUniform1i(GLint location, GLint x)
void QGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint *v)
void QGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y)
void QGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat *v)
void QGLFunctions::glUniform2i(GLint location, GLint x, GLint y)
void QGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint *v)
void QGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
void QGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat *v)
void QGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z)
void QGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint *v)
void QGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
void QGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat *v)
void QGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
void QGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint *v)
void QGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
void QGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
void QGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
void QGLFunctions::glUseProgram(GLuint program)
void QGLFunctions::glValidateProgram(GLuint program)
void QGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x)
void QGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat *values)
void QGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
void QGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat *values)
void QGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
void QGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat *values)
void QGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
void QGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat *values)
void QGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *ptr)
bool QGLFunctions::hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const
Returns true
if feature is present on this system's OpenGL implementation; false otherwise.
It is assumed that the QGLContext associated with this function resolver is current.
See also openGLFeatures().
void QGLFunctions::initializeGLFunctions(const QGLContext *context = nullptr)
Initializes GL function resolution for context. If context is null, then the current QGLContext will be used.
After calling this function, the QGLFunctions object can only be used with context and other contexts that share with it. Call initializeGLFunctions() again to change the object's context association.
QGLFunctions::OpenGLFeatures QGLFunctions::openGLFeatures() const
Returns the set of features that are present on this system's OpenGL implementation.
It is assumed that the QGLContext associated with this function resolver is current.
See also hasOpenGLFeature().