blob: 14531446a1002d5380685cdd94e4661ecb56b597 (
plain)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | // Copyright (C) 2018 The Qt Company Ltd.// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause#include <QOpenGLFunctions>#include <QtOpenGL/QOpenGLWindow>#include <QSurface>#include <QWidget>#include <QWindow>namespace src_gui_opengl_qopenglfunctions {//! [0]class MyGLWindow :public QWindow,protected QOpenGLFunctions { Q_OBJECT public:explicitMyGLWindow(QScreen *screen =nullptr);protected:voidinitializeGL();voidpaintGL(); QOpenGLContext *m_context;};MyGLWindow::MyGLWindow(QScreen *screen):QWindow(screen){setSurfaceType(OpenGLSurface);create();// Create an OpenGL context m_context =new QOpenGLContext; m_context->create();// Setup scene and render itinitializeGL();paintGL();};voidMyGLWindow::initializeGL(){ m_context->makeCurrent(this);initializeOpenGLFunctions();}//! [0]int textureId =0;//! [1]voidMyGLWindow::paintGL(){ m_context->makeCurrent(this);glActiveTexture(GL_TEXTURE1);glBindTexture(GL_TEXTURE_2D, textureId);// ... m_context->swapBuffers(this); m_context->doneCurrent();}//! [1]voidwrapper0() {//! [2] QOpenGLFunctions glFuncs(QOpenGLContext::currentContext()); glFuncs.glActiveTexture(GL_TEXTURE1);//! [2]}// wrapper0voidwrapper1() {//! [3] QOpenGLFunctions *glFuncs =QOpenGLContext::currentContext()->functions(); glFuncs->glActiveTexture(GL_TEXTURE1);//! [3]//! [4] QOpenGLFunctions funcs(QOpenGLContext::currentContext());bool npot = funcs.hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);//! [4]Q_UNUSED(npot);}// wrapper1}// src_gui_opengl_qopenglfunctions
|