Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_opengl_qopenglfunctions.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QOpenGLFunctions>
4#include <QtOpenGL/QOpenGLWindow>
5
6#include <QSurface>
7#include <QWidget>
8#include <QWindow>
9
11
12//! [0]
13class MyGLWindow : public QWindow, protected QOpenGLFunctions
14{
16public:
17 explicit MyGLWindow(QScreen *screen = nullptr);
18
19protected:
21 void paintGL();
22
24};
25
26MyGLWindow::MyGLWindow(QScreen *screen)
27 : QWindow(screen)
28{
29 setSurfaceType(OpenGLSurface);
30 create();
31
32 // Create an OpenGL context
33 m_context = new QOpenGLContext;
34 m_context->create();
35
36 // Setup scene and render it
39};
40
42{
43 m_context->makeCurrent(this);
44 initializeOpenGLFunctions();
45}
46//! [0]
47
48
49int textureId = 0;
50
51//! [1]
53{
54 m_context->makeCurrent(this);
55 glActiveTexture(GL_TEXTURE1);
56 glBindTexture(GL_TEXTURE_2D, textureId);
57 // ...
58 m_context->swapBuffers(this);
59 m_context->doneCurrent();
60}
61//! [1]
62
63
64void wrapper0() {
65//! [2]
66QOpenGLFunctions glFuncs(QOpenGLContext::currentContext());
67glFuncs.glActiveTexture(GL_TEXTURE1);
68//! [2]
69} // wrapper0
70
71
72void wrapper1() {
73//! [3]
74QOpenGLFunctions *glFuncs = QOpenGLContext::currentContext()->functions();
75glFuncs->glActiveTexture(GL_TEXTURE1);
76//! [3]
77
78
79//! [4]
80QOpenGLFunctions funcs(QOpenGLContext::currentContext());
81bool npot = funcs.hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
82//! [4]
83
84Q_UNUSED(npot);
85} // wrapper1
86} // src_gui_opengl_qopenglfunctions