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
10
namespace
src_gui_opengl_qopenglfunctions
{
11
12
//! [0]
13
class
MyGLWindow
:
public
QWindow
,
protected
QOpenGLFunctions
14
{
15
Q_OBJECT
16
public
:
17
explicit
MyGLWindow
(
QScreen
*
screen
=
nullptr
);
18
19
protected
:
20
void
initializeGL
();
21
void
paintGL
();
22
23
QOpenGLContext
*
m_context
;
24
};
25
26
MyGLWindow
::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
37
initializeGL
(
)
;
38
paintGL
(
)
;
39
};
40
41
void
MyGLWindow
::
initializeGL
()
42
{
43
m_context->makeCurrent(
this
);
44
initializeOpenGLFunctions();
45
}
46
//! [0]
47
48
49
int
textureId
= 0;
50
51
//! [1]
52
void
MyGLWindow
::
paintGL
()
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
64
void
wrapper0
() {
65
//! [2]
66
QOpenGLFunctions glFuncs(QOpenGLContext::currentContext());
67
glFuncs.glActiveTexture(GL_TEXTURE1);
68
//! [2]
69
}
// wrapper0
70
71
72
void
wrapper1
() {
73
//! [3]
74
QOpenGLFunctions *glFuncs = QOpenGLContext::currentContext()->functions();
75
glFuncs->glActiveTexture(GL_TEXTURE1);
76
//! [3]
77
78
79
//! [4]
80
QOpenGLFunctions funcs(QOpenGLContext::currentContext());
81
bool
npot = funcs.hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
82
//! [4]
83
84
Q_UNUSED(npot);
85
}
// wrapper1
86
}
// src_gui_opengl_qopenglfunctions
src_gui_opengl_qopenglfunctions::MyGLWindow
[0]
Definition
src_gui_opengl_qopenglfunctions.cpp:14
src_gui_opengl_qopenglfunctions::MyGLWindow::initializeGL
void initializeGL()
Definition
src_gui_opengl_qopenglfunctions.cpp:41
src_gui_opengl_qopenglfunctions::MyGLWindow::paintGL
void paintGL()
[1]
Definition
src_gui_opengl_qopenglfunctions.cpp:52
src_gui_opengl_qopenglfunctions::MyGLWindow::m_context
QOpenGLContext * m_context
Definition
src_gui_opengl_qopenglfunctions.cpp:23
src_gui_opengl_qopenglfunctions
Definition
src_gui_opengl_qopenglfunctions.cpp:10
src_gui_opengl_qopenglfunctions::wrapper1
void wrapper1()
Definition
src_gui_opengl_qopenglfunctions.cpp:72
src_gui_opengl_qopenglfunctions::textureId
int textureId
[0]
Definition
src_gui_opengl_qopenglfunctions.cpp:49
src_gui_opengl_qopenglfunctions::wrapper0
void wrapper0()
[1]
Definition
src_gui_opengl_qopenglfunctions.cpp:64
qtbase
src
gui
doc
snippets
code
src_gui_opengl_qopenglfunctions.cpp
Generated on
for Qt by
1.14.0