summaryrefslogtreecommitdiffstats
path: root/examples/opengl/legacy/framebufferobject2
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2020-02-19 12:08:25 +0100
committerJohan Helsing <johan.helsing@qt.io>2020-02-21 09:01:08 +0000
commite3f2e7afbb22069ef3e2bed6017f8fa47909e9f1 (patch)
tree4b89e925ed3b5e74b49f56c18721ad33b610ba16 /examples/opengl/legacy/framebufferobject2
parent8193f9e0ecc0a7592310e1c26310ba502c091374 (diff)
Remove legacy OpenGL examples
They all used QGL (which has been removed). Task-number: QTBUG-74408 Change-Id: Ied003625f14228b4951002a604fce91eaccec102 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'examples/opengl/legacy/framebufferobject2')
-rw-r--r--examples/opengl/legacy/framebufferobject2/CMakeLists.txt47
-rw-r--r--examples/opengl/legacy/framebufferobject2/cubelogo.pngbin2884 -> 0 bytes
-rw-r--r--examples/opengl/legacy/framebufferobject2/framebufferobject2.pro11
-rw-r--r--examples/opengl/legacy/framebufferobject2/framebufferobject2.qrc5
-rw-r--r--examples/opengl/legacy/framebufferobject2/glwidget.cpp257
-rw-r--r--examples/opengl/legacy/framebufferobject2/glwidget.h75
-rw-r--r--examples/opengl/legacy/framebufferobject2/main.cpp71
7 files changed, 0 insertions, 466 deletions
diff --git a/examples/opengl/legacy/framebufferobject2/CMakeLists.txt b/examples/opengl/legacy/framebufferobject2/CMakeLists.txt
deleted file mode 100644
index 550700959d..0000000000
--- a/examples/opengl/legacy/framebufferobject2/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from framebufferobject2.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(framebufferobject2 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/opengl/legacy/framebufferobject2")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(framebufferobject2
- glwidget.cpp glwidget.h
- main.cpp
-)
-target_link_libraries(framebufferobject2 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::Widgets
-)
-
-
-# Resources:
-set(framebufferobject2_resource_files
- "cubelogo.png"
-)
-
-qt6_add_resources(framebufferobject2 "framebufferobject2"
- PREFIX
- "/res"
- FILES
- ${framebufferobject2_resource_files}
-)
-
-install(TARGETS framebufferobject2
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/legacy/framebufferobject2/cubelogo.png b/examples/opengl/legacy/framebufferobject2/cubelogo.png
deleted file mode 100644
index 2ccbede774..0000000000
--- a/examples/opengl/legacy/framebufferobject2/cubelogo.png
+++ /dev/null
Binary files differ
diff --git a/examples/opengl/legacy/framebufferobject2/framebufferobject2.pro b/examples/opengl/legacy/framebufferobject2/framebufferobject2.pro
deleted file mode 100644
index 3f2578bc1f..0000000000
--- a/examples/opengl/legacy/framebufferobject2/framebufferobject2.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-HEADERS += glwidget.h
-SOURCES += glwidget.cpp main.cpp
-RESOURCES += framebufferobject2.qrc
-
-QT += opengl widgets
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/legacy/framebufferobject2
-INSTALLS += target
-
-qtConfig(opengles.|angle|dynamicgl): error("This example requires Qt to be configured with -opengl desktop")
diff --git a/examples/opengl/legacy/framebufferobject2/framebufferobject2.qrc b/examples/opengl/legacy/framebufferobject2/framebufferobject2.qrc
deleted file mode 100644
index 9fc1a56a1a..0000000000
--- a/examples/opengl/legacy/framebufferobject2/framebufferobject2.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/res">
- <file>cubelogo.png</file>
-</qresource>
-</RCC>
diff --git a/examples/opengl/legacy/framebufferobject2/glwidget.cpp b/examples/opengl/legacy/framebufferobject2/glwidget.cpp
deleted file mode 100644
index f14d31aff6..0000000000
--- a/examples/opengl/legacy/framebufferobject2/glwidget.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "glwidget.h"
-#include <QtGui/QImage>
-#include <qmath.h>
-
-static GLint cubeArray[][3] = {
- {0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0},
- {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1},
- {0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1},
- {0, 1, 0}, {0, 1, 1}, {1, 1, 1}, {1, 1, 0},
- {0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1},
- {1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}
-};
-
-static GLint cubeTextureArray[][2] = {
- {0, 0}, {1, 0}, {1, 1}, {0, 1},
- {0, 0}, {0, 1}, {1, 1}, {1, 0},
- {0, 0}, {1, 0}, {1, 1}, {0, 1},
- {1, 0}, {0, 0}, {0, 1}, {1, 1},
- {0, 0}, {1, 0}, {1, 1}, {0, 1},
- {1, 0}, {0, 0}, {0, 1}, {1, 1}
-};
-
-static GLint faceArray[][2] = {
- {1, -1}, {1, 1}, {-1, 1}, {-1, -1}
-};
-
-static GLubyte colorArray[][4] = {
- {102, 176, 54, 255},
- {81, 141, 41, 255},
- {62, 108, 32, 255},
- {45, 79, 23, 255}
-};
-
-GLWidget::GLWidget(QWidget *parent)
- : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
-{
- // create the framebuffer object - make sure to have a current
- // context before creating it
- makeCurrent();
- fbo = new QGLFramebufferObject(512, 512);
- timerId = startTimer(20);
- setWindowTitle(tr("OpenGL framebuffer objects 2"));
-}
-
-GLWidget::~GLWidget()
-{
- glDeleteLists(pbufferList, 1);
- delete fbo;
-}
-
-void GLWidget::initializeGL()
-{
- glMatrixMode(GL_MODELVIEW);
-
- glEnable(GL_CULL_FACE);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glVertexPointer(3, GL_INT, 0, cubeArray);
- glTexCoordPointer(2, GL_INT, 0, cubeTextureArray);
- glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorArray);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_DEPTH_TEST);
-
- glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- pbufferList = glGenLists(1);
- glNewList(pbufferList, GL_COMPILE);
- {
- glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
-
- // draw cube background
- glPushMatrix();
- glLoadIdentity();
- glTranslatef(0.5f, 0.5f, -2.0f);
- glDisable(GL_TEXTURE_2D);
- glEnableClientState(GL_COLOR_ARRAY);
- glVertexPointer(2, GL_INT, 0, faceArray);
- glDrawArrays(GL_QUADS, 0, 4);
- glVertexPointer(3, GL_INT, 0, cubeArray);
- glDisableClientState(GL_COLOR_ARRAY);
- glEnable(GL_TEXTURE_2D);
- glPopMatrix();
-
- // draw cube
- glTranslatef(0.5f, 0.5f, 0.5f);
- glRotatef(3.0f, 1.0f, 1.0f, 1.0f);
- glTranslatef(-0.5f, -0.5f, -0.5f);
- glColor4f(0.9f, 0.9f, 0.9f, 1.0f);
- glDrawArrays(GL_QUADS, 0, 24);
-
- glPushMatrix(); // this state is popped back in the paintGL() function
- }
- glEndList();
-
- for (int i = 0; i < 3; ++i) {
- yOffs[i] = 0.0f;
- xInc[i] = 0.005f;
- rot[i] = 0.0f;
- }
- xOffs[0]= 0.0f;
- xOffs[1]= 0.5f;
- xOffs[2]= 1.0f;
-
- cubeTexture = bindTexture(QImage(":res/cubelogo.png"));
-
- glPushMatrix(); // push to avoid stack underflow in the first paintGL() call
-}
-
-void GLWidget::resizeGL(int w, int h)
-{
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- float aspect = w/(float)(h ? h : 1);
- glFrustum(-aspect, aspect, -1, 1, 10, 100);
- glTranslatef(-0.5f, -0.5f, -0.5f);
- glTranslatef(0.0f, 0.0f, -15.0f);
-}
-
-void GLWidget::paintGL()
-{
- glPopMatrix(); // pop the matrix pushed in the pbuffer list
-
- // push the projection matrix and the entire GL state before
- // doing any rendering into our framebuffer object
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
-
- glViewport(0, 0, fbo->size().width(), fbo->size().height());
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1, 1, -1, 1, -99, 99);
- glTranslatef(-0.5f, -0.5f, 0.0f);
- glMatrixMode(GL_MODELVIEW);
-
- // render to the framebuffer object
- fbo->bind();
- glBindTexture(GL_TEXTURE_2D, cubeTexture);
- glCallList(pbufferList);
- fbo->release();
-
- // pop the projection matrix and GL state back for rendering
- // to the actual widget
- glPopAttrib();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- // draw the background
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glVertexPointer(2, GL_INT, 0, faceArray);
- glTranslatef(-1.2f, -0.8f, 0.0f);
- glScalef(0.2f, 0.2f, 0.2f);
- for (int y = 0; y < 5; ++y) {
- for (int x = 0; x < 5; ++x) {
- glTranslatef(2.0f, 0, 0);
- glColor4f(0.8f, 0.8f, 0.8f, 1.0f);
- glDrawArrays(GL_QUADS, 0, 4);
- }
- glTranslatef(-10.0f, 2.0f, 0);
- }
- glVertexPointer(3, GL_INT, 0, cubeArray);
-
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
-
- // draw the bouncing cubes
- drawCube(0, 0.0f, 1.5f, 2.5f, 1.5f);
- drawCube(1, 1.0f, 2.0f, 2.5f, 2.0f);
- drawCube(2, 2.0f, 3.5f, 2.5f, 2.5f);
- glPopMatrix();
-}
-
-void GLWidget::drawCube(int i, GLfloat z, GLfloat rotation, GLfloat jmp, GLfloat amp)
-{
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(xOffs[i], yOffs[i], z);
- glTranslatef(0.5f, 0.5f, 0.5f);
- GLfloat scale = 0.75 + i*(0.25f/2);
- glScalef(scale, scale, scale);
- glRotatef(rot[i], 1.0f, 1.0f, 1.0f);
- glTranslatef(-0.5f, -0.5f, -0.5f);
-
- glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
- glDrawArrays(GL_QUADS, 0, 24);
-
- if (xOffs[i] > 1.0f || xOffs[i] < -1.0f) {
- xInc[i] = -xInc[i];
- xOffs[i] = xOffs[i] > 1.0f ? 1.0f : -1.0f;
- }
- xOffs[i] += xInc[i];
- yOffs[i] = qAbs(cos((-GLfloat(M_PI) * jmp) * xOffs[i]) * amp) - 1;
- rot[i] += rotation;
-}
diff --git a/examples/opengl/legacy/framebufferobject2/glwidget.h b/examples/opengl/legacy/framebufferobject2/glwidget.h
deleted file mode 100644
index d3e4aa5af5..0000000000
--- a/examples/opengl/legacy/framebufferobject2/glwidget.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtOpenGL>
-
-class GLWidget : public QGLWidget
-{
-public:
- GLWidget(QWidget *parent);
- ~GLWidget();
- void initializeGL() override;
- void resizeGL(int w, int h) override;
- void paintGL() override;
- void timerEvent(QTimerEvent *) override { update(); }
- void mousePressEvent(QMouseEvent *) override { killTimer(timerId); }
- void mouseReleaseEvent(QMouseEvent *) override { timerId = startTimer(20); }
-
- void drawCube(int i, GLfloat z, GLfloat ri, GLfloat jmp, GLfloat amp);
-
-private:
- GLfloat rot[3], xOffs[3], yOffs[3], xInc[3];
- GLuint pbufferList;
- GLuint cubeTexture;
- int timerId;
-
- QGLFramebufferObject *fbo;
-};
-
diff --git a/examples/opengl/legacy/framebufferobject2/main.cpp b/examples/opengl/legacy/framebufferobject2/main.cpp
deleted file mode 100644
index ae7447c2a5..0000000000
--- a/examples/opengl/legacy/framebufferobject2/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QMessageBox>
-#include "glwidget.h"
-
-int main(int argc, char **argv)
-{
- Q_INIT_RESOURCE(framebufferobject2);
-
- QApplication a(argc, argv);
- if (!QGLFormat::hasOpenGL() || !QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
- QMessageBox::information(0, "OpenGL framebuffer objects 2",
- "This system does not support OpenGL/framebuffer objects.");
- return -1;
- }
-
- GLWidget widget(0);
- widget.resize(640, 480);
- widget.show();
- return a.exec();
-}
-