Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickopenglutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qquickopenglutils.h"
5
6#include <QOpenGLContext>
7#include <QOpenGLFunctions>
8#include <QOpenGLFramebufferObject>
9#include <private/qopenglvertexarrayobject_p.h>
10
12
42{
44 if (!ctx)
45 return;
46
47 QOpenGLFunctions *gl = ctx->functions();
48
51
53 if (vaoHelper->isValid())
54 vaoHelper->glBindVertexArray(0);
55
56 if (ctx->isOpenGLES() || (gl->openGLFeatures() & QOpenGLFunctions::FixedFunctionPipeline)) {
57 int maxAttribs;
58 gl->glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
59 for (int i=0; i<maxAttribs; ++i) {
60 gl->glVertexAttribPointer(i, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
62 }
63 }
64
66 gl->glBindTexture(GL_TEXTURE_2D, 0);
67
68 gl->glDisable(GL_DEPTH_TEST);
69 gl->glDisable(GL_STENCIL_TEST);
70 gl->glDisable(GL_SCISSOR_TEST);
71
72 gl->glColorMask(true, true, true, true);
73 gl->glClearColor(0, 0, 0, 0);
74
75 gl->glDepthMask(true);
76 gl->glDepthFunc(GL_LESS);
77 gl->glClearDepthf(1);
78
79 gl->glStencilMask(0xff);
80 gl->glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
81 gl->glStencilFunc(GL_ALWAYS, 0, 0xff);
82
83 gl->glDisable(GL_BLEND);
84 gl->glBlendFunc(GL_ONE, GL_ZERO);
85
86 gl->glUseProgram(0);
87
89}
90
\inmodule QtGui
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
static bool bindDefault()
Switches rendering back to the default, windowing system provided framebuffer.
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
void glStencilFunc(GLenum func, GLint ref, GLuint mask)
Convenience function that calls glStencilFunc(func, ref, mask).
void glBlendFunc(GLenum sfactor, GLenum dfactor)
Convenience function that calls glBlendFunc(sfactor, dfactor).
void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
Convenience function that calls glClearColor(red, green, blue, alpha).
void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *ptr)
Convenience function that calls glVertexAttribPointer(indx, size, type, normalized,...
void glClearDepthf(GLclampf depth)
Convenience function that calls glClearDepth(depth) on desktop OpenGL systems and glClearDepthf(depth...
void glUseProgram(GLuint program)
Convenience function that calls glUseProgram(program).
void glBindBuffer(GLenum target, GLuint buffer)
Convenience function that calls glBindBuffer(target, buffer).
void glDisableVertexAttribArray(GLuint index)
Convenience function that calls glDisableVertexAttribArray(index).
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
Convenience function that calls glColorMask(red, green, blue, alpha).
void glBindTexture(GLenum target, GLuint texture)
Convenience function that calls glBindTexture(target, texture).
void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
Convenience function that calls glStencilOp(fail, zfail, zpass).
void glDepthMask(GLboolean flag)
Convenience function that calls glDepthMask(flag).
void glActiveTexture(GLenum texture)
Convenience function that calls glActiveTexture(texture).
void glDisable(GLenum cap)
Convenience function that calls glDisable(cap).
void glStencilMask(GLuint mask)
Convenience function that calls glStencilMask(mask).
void glGetIntegerv(GLenum pname, GLint *params)
Convenience function that calls glGetIntegerv(pname, params).
QOpenGLFunctions::OpenGLFeatures openGLFeatures() const
Returns the set of features that are present on this system's OpenGL implementation.
void glDepthFunc(GLenum func)
Convenience function that calls glDepthFunc(func).
static Q_OPENGL_EXPORT QOpenGLVertexArrayObjectHelper * vertexArrayObjectHelperForContext(QOpenGLContext *context)
EGLContext ctx
Q_QUICK_EXPORT void resetOpenGLState()
Call this function to reset the current OpenGL context its default state.
Combined button and popup list for selecting options.
#define GL_TEXTURE0
Definition qopenglext.h:129
#define GL_MAX_VERTEX_ATTRIBS
Definition qopenglext.h:606
#define GL_ARRAY_BUFFER
Definition qopenglext.h:487
#define GL_ELEMENT_ARRAY_BUFFER
Definition qopenglext.h:488
#define GL_FLOAT