From 8f4738859276dd7af66999a7416c2ae17f2e6a64 Mon Sep 17 00:00:00 2001 From: ccolin Date: Sun, 8 Mar 2020 21:18:21 +0100 Subject: [PATCH] archivage initial --- Makefile | 633 +++++++++++++++++++++++++++++++++++++++++++++ basic.fsh | 5 + basic.vsh | 9 + cylinder.cpp | 68 +++++ cylinder.h | 69 +++++ glarea.cpp | 182 +++++++++++++ glarea.h | 102 ++++++++ main.cpp | 13 + princ.cpp | 16 ++ princ.h | 22 ++ princ.ui | 110 ++++++++ propslider.cpp | 63 +++++ propslider.h | 42 +++ scene.cpp | 91 +++++++ scene.h | 31 +++ settingsdialog.cpp | 63 +++++ settingsdialog.h | 34 +++ settingsdialog.ui | 152 +++++++++++ tp3.pro | 36 +++ tp3.qrc | 6 + 20 files changed, 1747 insertions(+) create mode 100644 Makefile create mode 100644 basic.fsh create mode 100644 basic.vsh create mode 100644 cylinder.cpp create mode 100644 cylinder.h create mode 100644 glarea.cpp create mode 100644 glarea.h create mode 100644 main.cpp create mode 100644 princ.cpp create mode 100644 princ.h create mode 100644 princ.ui create mode 100644 propslider.cpp create mode 100644 propslider.h create mode 100644 scene.cpp create mode 100644 scene.h create mode 100644 settingsdialog.cpp create mode 100644 settingsdialog.h create mode 100644 settingsdialog.ui create mode 100644 tp3.pro create mode 100644 tp3.qrc diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7f45247 --- /dev/null +++ b/Makefile @@ -0,0 +1,633 @@ +############################################################################# +# Makefile for building: tp3 +# Generated by qmake (3.1) (Qt 5.13.2) +# Project: tp3.pro +# Template: app +# Command: /usr/lib/qt5/bin/qmake -o Makefile tp3.pro +############################################################################# + +MAKEFILE = Makefile + +EQ = = + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB +CFLAGS = -pipe -g -Wall -W -D_REENTRANT -fPIC $(DEFINES) +CXXFLAGS = -pipe -g -std=gnu++1y -Wall -W -D_REENTRANT -fPIC $(DEFINES) +INCPATH = -I. -I /usr/include/qt5 -I /usr/include/qt5/QtWidgets -I /usr/include/qt5/QtGui -I /usr/include/qt5/QtCore -I. -I /usr/include/libdrm -I. -I/usr/lib/qt5/mkspecs/linux-g++ +QMAKE = /usr/lib/qt5/bin/qmake +DEL_FILE = rm -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p +COPY = cp -f +COPY_FILE = cp -f +COPY_DIR = cp -f -R +INSTALL_FILE = install -m 644 -p +INSTALL_PROGRAM = install -m 755 -p +INSTALL_DIR = cp -f -R +QINSTALL = /usr/lib/qt5/bin/qmake -install qinstall +QINSTALL_PROGRAM = /usr/lib/qt5/bin/qmake -install qinstall -exe +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +TAR = tar -cf +COMPRESS = gzip -9f +DISTNAME = tp31.0.0 +DISTDIR = /home/papush/m1/pg/tp3/tp3/.tmp/tp31.0.0 +LINK = g++ +LFLAGS = -Wl,-rpath,/usr/lib +LIBS = $(SUBLIBS) /usr/lib/libQt5Widgets.so /usr/lib/libQt5Gui.so /usr/lib/libQt5Core.so -lGL -lpthread +AR = ar cqs +RANLIB = +SED = sed +STRIP = strip + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + princ.cpp \ + glarea.cpp \ + cylinder.cpp \ + scene.cpp \ + settingsdialog.cpp \ + propslider.cpp qrc_tp3.cpp \ + moc_princ.cpp \ + moc_glarea.cpp \ + moc_settingsdialog.cpp \ + moc_propslider.cpp +OBJECTS = main.o \ + princ.o \ + glarea.o \ + cylinder.o \ + scene.o \ + settingsdialog.o \ + propslider.o \ + qrc_tp3.o \ + moc_princ.o \ + moc_glarea.o \ + moc_settingsdialog.o \ + moc_propslider.o +DIST = /usr/lib/qt5/mkspecs/features/spec_pre.prf \ + /usr/lib/qt5/mkspecs/common/unix.conf \ + /usr/lib/qt5/mkspecs/common/linux.conf \ + /usr/lib/qt5/mkspecs/common/sanitize.conf \ + /usr/lib/qt5/mkspecs/common/gcc-base.conf \ + /usr/lib/qt5/mkspecs/common/gcc-base-unix.conf \ + /usr/lib/qt5/mkspecs/common/g++-base.conf \ + /usr/lib/qt5/mkspecs/common/g++-unix.conf \ + /usr/lib/qt5/mkspecs/qconfig.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3danimation.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3danimation_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dcore.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dcore_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dextras.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dextras_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dinput.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dinput_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dlogic.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dlogic_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquick.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquick_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickanimation.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickanimation_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickextras.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickextras_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickinput.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickinput_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickrender.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickrender_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickscene2d.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickscene2d_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3drender.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3drender_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_accessibility_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_concurrent.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_core.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_core_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_dbus.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_dbus_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_edid_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_egl_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_eglfsdeviceintegration_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_fb_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_fontdatabase_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_glx_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_gui.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_gui_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_input_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_kms_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_linuxaccessibility_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_network.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_network_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_opengl.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_packetprotocol_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_printsupport.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qml.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qml_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmldebug_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmldevtools_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmltest.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmltest_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quick.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quick_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickparticles_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickshapes_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickwidgets.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickwidgets_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_service_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_sql.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_sql_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_testlib.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_testlib_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_theme_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_widgets.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xkbcommon_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xml.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xml_private.pri \ + /usr/lib/qt5/mkspecs/features/qt_functions.prf \ + /usr/lib/qt5/mkspecs/features/qt_config.prf \ + /usr/lib/qt5/mkspecs/linux-g++/qmake.conf \ + /usr/lib/qt5/mkspecs/features/spec_post.prf \ + .qmake.stash \ + /usr/lib/qt5/mkspecs/features/exclusive_builds.prf \ + /usr/lib/qt5/mkspecs/features/toolchain.prf \ + /usr/lib/qt5/mkspecs/features/default_pre.prf \ + /usr/lib/qt5/mkspecs/features/resolve_config.prf \ + /usr/lib/qt5/mkspecs/features/default_post.prf \ + /usr/lib/qt5/mkspecs/features/warn_on.prf \ + /usr/lib/qt5/mkspecs/features/qt.prf \ + /usr/lib/qt5/mkspecs/features/resources.prf \ + /usr/lib/qt5/mkspecs/features/moc.prf \ + /usr/lib/qt5/mkspecs/features/unix/opengl.prf \ + /usr/lib/qt5/mkspecs/features/uic.prf \ + /usr/lib/qt5/mkspecs/features/unix/thread.prf \ + /usr/lib/qt5/mkspecs/features/qmake_use.prf \ + /usr/lib/qt5/mkspecs/features/file_copies.prf \ + /usr/lib/qt5/mkspecs/features/testcase_targets.prf \ + /usr/lib/qt5/mkspecs/features/exceptions.prf \ + /usr/lib/qt5/mkspecs/features/yacc.prf \ + /usr/lib/qt5/mkspecs/features/lex.prf \ + tp3.pro princ.h \ + glarea.h \ + scene.h \ + cylinder.h \ + settingsdialog.h \ + propslider.h main.cpp \ + princ.cpp \ + glarea.cpp \ + cylinder.cpp \ + scene.cpp \ + settingsdialog.cpp \ + propslider.cpp +QMAKE_TARGET = tp3 +DESTDIR = +TARGET = tp3 + + +first: all +####### Build rules + +tp3: ui_princ.h ui_settingsdialog.h $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: tp3.pro /usr/lib/qt5/mkspecs/linux-g++/qmake.conf /usr/lib/qt5/mkspecs/features/spec_pre.prf \ + /usr/lib/qt5/mkspecs/common/unix.conf \ + /usr/lib/qt5/mkspecs/common/linux.conf \ + /usr/lib/qt5/mkspecs/common/sanitize.conf \ + /usr/lib/qt5/mkspecs/common/gcc-base.conf \ + /usr/lib/qt5/mkspecs/common/gcc-base-unix.conf \ + /usr/lib/qt5/mkspecs/common/g++-base.conf \ + /usr/lib/qt5/mkspecs/common/g++-unix.conf \ + /usr/lib/qt5/mkspecs/qconfig.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3danimation.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3danimation_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dcore.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dcore_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dextras.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dextras_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dinput.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dinput_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dlogic.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dlogic_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquick.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquick_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickanimation.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickanimation_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickextras.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickextras_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickinput.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickinput_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickrender.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickrender_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickscene2d.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3dquickscene2d_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3drender.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_3drender_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_accessibility_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_concurrent.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_core.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_core_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_dbus.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_dbus_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_edid_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_egl_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_eglfsdeviceintegration_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_fb_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_fontdatabase_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_glx_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_gui.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_gui_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_input_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_kms_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_linuxaccessibility_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_network.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_network_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_opengl.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_packetprotocol_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_printsupport.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qml.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qml_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmldebug_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmldevtools_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmltest.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_qmltest_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quick.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quick_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickparticles_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickshapes_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickwidgets.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_quickwidgets_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_service_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_sql.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_sql_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_testlib.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_testlib_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_theme_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_widgets.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xkbcommon_support_private.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xml.pri \ + /usr/lib/qt5/mkspecs/modules/qt_lib_xml_private.pri \ + /usr/lib/qt5/mkspecs/features/qt_functions.prf \ + /usr/lib/qt5/mkspecs/features/qt_config.prf \ + /usr/lib/qt5/mkspecs/linux-g++/qmake.conf \ + /usr/lib/qt5/mkspecs/features/spec_post.prf \ + .qmake.stash \ + /usr/lib/qt5/mkspecs/features/exclusive_builds.prf \ + /usr/lib/qt5/mkspecs/features/toolchain.prf \ + /usr/lib/qt5/mkspecs/features/default_pre.prf \ + /usr/lib/qt5/mkspecs/features/resolve_config.prf \ + /usr/lib/qt5/mkspecs/features/default_post.prf \ + /usr/lib/qt5/mkspecs/features/warn_on.prf \ + /usr/lib/qt5/mkspecs/features/qt.prf \ + /usr/lib/qt5/mkspecs/features/resources.prf \ + /usr/lib/qt5/mkspecs/features/moc.prf \ + /usr/lib/qt5/mkspecs/features/unix/opengl.prf \ + /usr/lib/qt5/mkspecs/features/uic.prf \ + /usr/lib/qt5/mkspecs/features/unix/thread.prf \ + /usr/lib/qt5/mkspecs/features/qmake_use.prf \ + /usr/lib/qt5/mkspecs/features/file_copies.prf \ + /usr/lib/qt5/mkspecs/features/testcase_targets.prf \ + /usr/lib/qt5/mkspecs/features/exceptions.prf \ + /usr/lib/qt5/mkspecs/features/yacc.prf \ + /usr/lib/qt5/mkspecs/features/lex.prf \ + tp3.pro \ + tp3.qrc + $(QMAKE) -o Makefile tp3.pro +/usr/lib/qt5/mkspecs/features/spec_pre.prf: +/usr/lib/qt5/mkspecs/common/unix.conf: +/usr/lib/qt5/mkspecs/common/linux.conf: +/usr/lib/qt5/mkspecs/common/sanitize.conf: +/usr/lib/qt5/mkspecs/common/gcc-base.conf: +/usr/lib/qt5/mkspecs/common/gcc-base-unix.conf: +/usr/lib/qt5/mkspecs/common/g++-base.conf: +/usr/lib/qt5/mkspecs/common/g++-unix.conf: +/usr/lib/qt5/mkspecs/qconfig.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3danimation.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3danimation_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dcore.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dcore_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dextras.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dextras_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dinput.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dinput_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dlogic.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dlogic_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquick.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquick_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickanimation.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickanimation_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickextras.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickextras_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickinput.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickinput_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickrender.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickrender_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickscene2d.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3dquickscene2d_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3drender.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_3drender_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_accessibility_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_concurrent.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_concurrent_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_core.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_core_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_dbus.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_dbus_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_edid_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_egl_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_eglfsdeviceintegration_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_fb_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_fontdatabase_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_glx_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_gui.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_gui_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_input_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_kms_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_linuxaccessibility_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_network.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_network_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_opengl.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_opengl_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_openglextensions.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_packetprotocol_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_printsupport.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_printsupport_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_qml.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_qml_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_qmldebug_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_qmldevtools_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_qmltest.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_qmltest_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_quick.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_quick_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_quickparticles_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_quickshapes_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_quickwidgets.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_quickwidgets_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_service_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_sql.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_sql_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_testlib.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_testlib_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_theme_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_widgets.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_widgets_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_xkbcommon_support_private.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_xml.pri: +/usr/lib/qt5/mkspecs/modules/qt_lib_xml_private.pri: +/usr/lib/qt5/mkspecs/features/qt_functions.prf: +/usr/lib/qt5/mkspecs/features/qt_config.prf: +/usr/lib/qt5/mkspecs/linux-g++/qmake.conf: +/usr/lib/qt5/mkspecs/features/spec_post.prf: +.qmake.stash: +/usr/lib/qt5/mkspecs/features/exclusive_builds.prf: +/usr/lib/qt5/mkspecs/features/toolchain.prf: +/usr/lib/qt5/mkspecs/features/default_pre.prf: +/usr/lib/qt5/mkspecs/features/resolve_config.prf: +/usr/lib/qt5/mkspecs/features/default_post.prf: +/usr/lib/qt5/mkspecs/features/warn_on.prf: +/usr/lib/qt5/mkspecs/features/qt.prf: +/usr/lib/qt5/mkspecs/features/resources.prf: +/usr/lib/qt5/mkspecs/features/moc.prf: +/usr/lib/qt5/mkspecs/features/unix/opengl.prf: +/usr/lib/qt5/mkspecs/features/uic.prf: +/usr/lib/qt5/mkspecs/features/unix/thread.prf: +/usr/lib/qt5/mkspecs/features/qmake_use.prf: +/usr/lib/qt5/mkspecs/features/file_copies.prf: +/usr/lib/qt5/mkspecs/features/testcase_targets.prf: +/usr/lib/qt5/mkspecs/features/exceptions.prf: +/usr/lib/qt5/mkspecs/features/yacc.prf: +/usr/lib/qt5/mkspecs/features/lex.prf: +tp3.pro: +tp3.qrc: +qmake: FORCE + @$(QMAKE) -o Makefile tp3.pro + +qmake_all: FORCE + + +all: Makefile tp3 + +dist: distdir FORCE + (cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar) && $(MOVE) `dirname $(DISTDIR)`/$(DISTNAME).tar.gz . && $(DEL_FILE) -r $(DISTDIR) + +distdir: FORCE + @test -d $(DISTDIR) || mkdir -p $(DISTDIR) + $(COPY_FILE) --parents $(DIST) $(DISTDIR)/ + $(COPY_FILE) --parents tp3.qrc $(DISTDIR)/ + $(COPY_FILE) --parents /usr/lib/qt5/mkspecs/features/data/dummy.cpp $(DISTDIR)/ + $(COPY_FILE) --parents princ.h glarea.h scene.h cylinder.h settingsdialog.h propslider.h $(DISTDIR)/ + $(COPY_FILE) --parents main.cpp princ.cpp glarea.cpp cylinder.cpp scene.cpp settingsdialog.cpp propslider.cpp $(DISTDIR)/ + $(COPY_FILE) --parents princ.ui settingsdialog.ui $(DISTDIR)/ + + +clean: compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) .qmake.stash + -$(DEL_FILE) Makefile + + +####### Sub-libraries + +mocclean: compiler_moc_header_clean compiler_moc_objc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_objc_header_make_all compiler_moc_source_make_all + +check: first + +benchmark: first + +compiler_rcc_make_all: qrc_tp3.cpp +compiler_rcc_clean: + -$(DEL_FILE) qrc_tp3.cpp +qrc_tp3.cpp: tp3.qrc \ + /usr/lib/qt5/bin/rcc \ + basic.vsh \ + basic.fsh + /usr/lib/qt5/bin/rcc -name tp3 tp3.qrc -o qrc_tp3.cpp + +compiler_moc_predefs_make_all: moc_predefs.h +compiler_moc_predefs_clean: + -$(DEL_FILE) moc_predefs.h +moc_predefs.h: /usr/lib/qt5/mkspecs/features/data/dummy.cpp + g++ -pipe -g -std=gnu++1y -Wall -W -dM -E -o moc_predefs.h /usr/lib/qt5/mkspecs/features/data/dummy.cpp + +compiler_moc_header_make_all: moc_princ.cpp moc_glarea.cpp moc_settingsdialog.cpp moc_propslider.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_princ.cpp moc_glarea.cpp moc_settingsdialog.cpp moc_propslider.cpp +moc_princ.cpp: princ.h \ + ui_princ.h \ + glarea.h \ + scene.h \ + cylinder.h \ + settingsdialog.h \ + ui_settingsdialog.h \ + propslider.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include /home/papush/m1/pg/tp3/tp3/moc_predefs.h -I/usr/lib/qt5/mkspecs/linux-g++ -I/home/papush/m1/pg/tp3/tp3 -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I/usr/include/c++/9.2.0 -I/usr/include/c++/9.2.0/x86_64-unknown-linux-gnu -I/usr/include/c++/9.2.0/backward -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include-fixed -I/usr/include princ.h -o moc_princ.cpp + +moc_glarea.cpp: glarea.h \ + scene.h \ + cylinder.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include /home/papush/m1/pg/tp3/tp3/moc_predefs.h -I/usr/lib/qt5/mkspecs/linux-g++ -I/home/papush/m1/pg/tp3/tp3 -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I/usr/include/c++/9.2.0 -I/usr/include/c++/9.2.0/x86_64-unknown-linux-gnu -I/usr/include/c++/9.2.0/backward -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include-fixed -I/usr/include glarea.h -o moc_glarea.cpp + +moc_settingsdialog.cpp: settingsdialog.h \ + ui_settingsdialog.h \ + propslider.h \ + glarea.h \ + scene.h \ + cylinder.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include /home/papush/m1/pg/tp3/tp3/moc_predefs.h -I/usr/lib/qt5/mkspecs/linux-g++ -I/home/papush/m1/pg/tp3/tp3 -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I/usr/include/c++/9.2.0 -I/usr/include/c++/9.2.0/x86_64-unknown-linux-gnu -I/usr/include/c++/9.2.0/backward -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include-fixed -I/usr/include settingsdialog.h -o moc_settingsdialog.cpp + +moc_propslider.cpp: propslider.h \ + moc_predefs.h \ + /usr/lib/qt5/bin/moc + /usr/lib/qt5/bin/moc $(DEFINES) --include /home/papush/m1/pg/tp3/tp3/moc_predefs.h -I/usr/lib/qt5/mkspecs/linux-g++ -I/home/papush/m1/pg/tp3/tp3 -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I/usr/include/c++/9.2.0 -I/usr/include/c++/9.2.0/x86_64-unknown-linux-gnu -I/usr/include/c++/9.2.0/backward -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-unknown-linux-gnu/9.2.0/include-fixed -I/usr/include propslider.h -o moc_propslider.cpp + +compiler_moc_objc_header_make_all: +compiler_moc_objc_header_clean: +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: ui_princ.h ui_settingsdialog.h +compiler_uic_clean: + -$(DEL_FILE) ui_princ.h ui_settingsdialog.h +ui_princ.h: princ.ui \ + /usr/lib/qt5/bin/uic \ + glarea.h \ + scene.h \ + cylinder.h + /usr/lib/qt5/bin/uic princ.ui -o ui_princ.h + +ui_settingsdialog.h: settingsdialog.ui \ + /usr/lib/qt5/bin/uic \ + propslider.h + /usr/lib/qt5/bin/uic settingsdialog.ui -o ui_settingsdialog.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_rcc_clean compiler_moc_predefs_clean compiler_moc_header_clean compiler_uic_clean + +####### Compile + +main.o: main.cpp princ.h \ + ui_princ.h \ + glarea.h \ + scene.h \ + cylinder.h \ + settingsdialog.h \ + ui_settingsdialog.h \ + propslider.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +princ.o: princ.cpp princ.h \ + ui_princ.h \ + glarea.h \ + scene.h \ + cylinder.h \ + settingsdialog.h \ + ui_settingsdialog.h \ + propslider.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o princ.o princ.cpp + +glarea.o: glarea.cpp glarea.h \ + scene.h \ + cylinder.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o glarea.o glarea.cpp + +cylinder.o: cylinder.cpp cylinder.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cylinder.o cylinder.cpp + +scene.o: scene.cpp scene.h \ + cylinder.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o scene.o scene.cpp + +settingsdialog.o: settingsdialog.cpp settingsdialog.h \ + ui_settingsdialog.h \ + propslider.h \ + glarea.h \ + scene.h \ + cylinder.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o settingsdialog.o settingsdialog.cpp + +propslider.o: propslider.cpp propslider.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o propslider.o propslider.cpp + +qrc_tp3.o: qrc_tp3.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qrc_tp3.o qrc_tp3.cpp + +moc_princ.o: moc_princ.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_princ.o moc_princ.cpp + +moc_glarea.o: moc_glarea.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_glarea.o moc_glarea.cpp + +moc_settingsdialog.o: moc_settingsdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_settingsdialog.o moc_settingsdialog.cpp + +moc_propslider.o: moc_propslider.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_propslider.o moc_propslider.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/basic.fsh b/basic.fsh new file mode 100644 index 0000000..862c7e1 --- /dev/null +++ b/basic.fsh @@ -0,0 +1,5 @@ +varying lowp vec4 col; + +void main() { + gl_FragColor = col; +} diff --git a/basic.vsh b/basic.vsh new file mode 100644 index 0000000..5c642fb --- /dev/null +++ b/basic.vsh @@ -0,0 +1,9 @@ +attribute highp vec4 posAttr; +attribute lowp vec4 colAttr; +varying lowp vec4 col; +uniform highp mat4 matrix; + +void main() { + col = colAttr; + gl_Position = matrix * posAttr; +} diff --git a/cylinder.cpp b/cylinder.cpp new file mode 100644 index 0000000..e1a4b5c --- /dev/null +++ b/cylinder.cpp @@ -0,0 +1,68 @@ +#include +#include + + +void VertexBuf::push(GLfloat x, GLfloat y, GLfloat z, Color &c) +{ + vertices[i] = x; + vertices[i+1] = y; + vertices[i+2] = z; + colors[i] = c.r; + colors[i+1] = c.g; + colors[i+2] = c.b; + i += 3; +} + + +void Cylinder::build_face(float z) +{ + Color color(c); + for (unsigned j = 0; j < nb_fac; j++) { + vb.push(0, 0, z, color); + vb.push(cos(angle*j) * r, sin(angle*j) * r, z, color); + vb.push(cos(angle*(j+1)) * r, sin(angle*(j+1)) * r, z, color); + if (j % (nb_fac/4) == 0) { + if (j % (nb_fac/2) == 0) { + color.r *= .8; + color.g *= .8; + color.b *= .8; + } + else { + color = c; + } + } + } +} + + +void Cylinder::build_faces() +{ + build_face(-ep/2); + build_face(ep/2); +} + + +void Cylinder::build_side() +{ + Color color(c.r*.7, c.g*.7, c.b*.7); + for (unsigned i = 0; i < nb_fac+1; i++) { + vb.push(cos(angle*i) * r, sin(angle*i) * r, -ep/2, color); + vb.push(cos(angle*i) * r, sin(angle*i) * r, ep/2, color); + } +} + + +void Cylinder::draw(QOpenGLFunctions &f, int pos, int col) +{ + f.glVertexAttribPointer(pos, 3, GL_FLOAT, GL_FALSE, 0, vb.vertices); + f.glVertexAttribPointer(col, 3, GL_FLOAT, GL_FALSE, 0, vb.colors); + f.glEnableVertexAttribArray(pos); + f.glEnableVertexAttribArray(col); + f.glDrawArrays(GL_TRIANGLES, 0, face_size); + f.glDrawArrays(GL_TRIANGLES, face_size, face_size); + f.glDrawArrays(GL_QUAD_STRIP, + face_size * 2, + side_size); + f.glDisableVertexAttribArray(pos); + f.glDisableVertexAttribArray(col); +} diff --git a/cylinder.h b/cylinder.h new file mode 100644 index 0000000..a472bc9 --- /dev/null +++ b/cylinder.h @@ -0,0 +1,69 @@ +#ifndef CYLINDER_HPP +#define CYLINDER_HPP + +#include +#include +#include +#include + + +struct Color +{ + float r; + float g; + float b; + + Color(float r, float g, float b) :r(r), g(g), b(b) {}; +}; + + +struct VertexBuf +{ + size_t i = 0; + size_t size; + GLfloat *vertices; + GLfloat *colors; + + VertexBuf(size_t i) + :size(i*3), + vertices(new GLfloat[size]), + colors(new GLfloat[size]) {} + + void push(GLfloat x, GLfloat y, GLfloat z, Color &c); +}; + + +struct Cylinder +{ + float ep; + float r; + unsigned nb_fac; + Color c; + float angle; + + size_t face_size; + size_t side_size; + + VertexBuf vb; + + Cylinder(float ep, float r, unsigned nb_fac, Color c) + :ep(ep), + r(r), + nb_fac(nb_fac), + c(c), + angle(2*M_PI/nb_fac), + face_size(nb_fac*3), + side_size((nb_fac+1) * 2), + vb(2 * face_size + side_size) + { + build_faces(); + build_side(); + } + + void build_face(float z); + void build_faces(); + void build_side(); + void draw(QOpenGLFunctions &f, int pos, int col); +}; + +#endif diff --git a/glarea.cpp b/glarea.cpp new file mode 100644 index 0000000..2356791 --- /dev/null +++ b/glarea.cpp @@ -0,0 +1,182 @@ +// CC-BY Edouard.Thiel@univ-amu.fr - 22/01/2019 + +#include "glarea.h" +#include +#include +#include +#include + +static const QString vertexShaderFile = ":/basic.vsh"; +static const QString fragmentShaderFile = ":/basic.fsh"; + + +GLArea::GLArea(QWidget *parent) : + QOpenGLWidget(parent) +{ + qDebug() << "init GLArea" ; + QSurfaceFormat sf; + sf.setDepthBufferSize(24); + sf.setSamples(16); + setFormat(sf); + qDebug() << "Depth is"<< format().depthBufferSize(); + setEnabled(true); // Événements clavier et souris. + setFocusPolicy(Qt::StrongFocus); // Accepte focus. + setFocus(); // Donne le focus. + timer = new QTimer(this); + timer->setInterval(16); // ms + connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout())); +} + + +GLArea::~GLArea() +{ + qDebug() << "destroy GLArea"; + delete timer; + // Contrairement aux méthodes virtuelles initializeGL, resizeGL et repaintGL, + // dans le destructeur le contexte GL n'est pas automatiquement rendu courant. + makeCurrent(); + // ici destructions de ressources GL + doneCurrent(); +} + + +void GLArea::initializeGL() +{ + qDebug() << __FUNCTION__ ; + initializeOpenGLFunctions(); + glEnable(GL_DEPTH_TEST); + + // Shaders. + program = new QOpenGLShaderProgram(this); + program->addShaderFromSourceFile + (QOpenGLShader::Vertex, vertexShaderFile); + program->addShaderFromSourceFile + (QOpenGLShader::Fragment, fragmentShaderFile); + if (!program->link()) { + qWarning("Failed to compile and link shader program:"); + qWarning() << program->log(); + } + // Récupère identifiants de "variables" dans les shaders. + posAttr = program->attributeLocation("posAttr"); + colAttr = program->attributeLocation("colAttr"); + matrix_uniform = program->uniformLocation("matrix"); +} + + +void GLArea::resizeGL(int w, int h) +{ + qDebug() << __FUNCTION__ << w << h; + // C'est fait par défaut + glViewport(0, 0, w, h); + ratio = (double) w / h; + // doProjection(); +} + + +void GLArea::paintGL() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + program->bind(); // active le shader program + + QMatrix4x4 matrix; + GLfloat hr = focal_length; + GLfloat wr = hr * ratio; + matrix.frustum(-wr, wr, -hr, hr, near_clip, far_clip); + matrix.translate(0, 0, -distance); + matrix.rotate(angle, 0, 1, 0); + matrix.rotate(horiz_angle, 0, + cos(vert_angle * 2*M_PI /360), + sin(vert_angle * 2*M_PI /360)); + matrix.rotate(vert_angle, 1, 0, 0); + program->setUniformValue(matrix_uniform, matrix); + scene.draw((QOpenGLFunctions&) (*this), program, matrix_uniform, + anim * 360, matrix, posAttr, colAttr); + program->release(); +} + + +void GLArea::keyPressEvent(QKeyEvent *ev) +{ + QString text = ev->text(); + switch(ev->key()) { + case Qt::Key_A: + timer->isActive() ? timer->stop() : timer->start(); + break; + case Qt::Key_Z: + setDistance(distance + (text == "z" ? -distance_step : distance_step)); + break; + case Qt::Key_R: + setFocalLength(focal_length + (text == "r" ? -focal_length_step : focal_length_step)); + break; + case Qt::Key_N: + setNearClip(near_clip + (text == "n" ? -near_clip_step : near_clip_step)); + break; + case Qt::Key_F: + setFarClip(far_clip + (text == "f" ? -far_clip_step : far_clip_step)); + break; + case Qt::Key_Space: + setAngle(angle + angle_step); + update(); + break; + } +} + + +void GLArea::mousePressEvent(QMouseEvent *ev) +{ + mouse_last[0] = ev->x() / (float) width(); + mouse_last[1] = ev->y() / (float) height(); +} + + +void GLArea::mouseMoveEvent(QMouseEvent *ev) +{ + float x = ev->x() / (float) width(); + float y = ev->y() / (float) height(); + float dx = x - mouse_last[0]; + float dy = y - mouse_last[1]; + horiz_angle += dx * 200; + vert_angle += dy * 200; + if (vert_angle > 90) vert_angle = 90; + if (vert_angle < -90) vert_angle = -90; + mouse_last[0] = x; + mouse_last[1] = y; + update(); +} + + +void GLArea::wheelEvent(QWheelEvent *ev) +{ + setDistance(distance - ev->angleDelta().y() / 1000.); + update(); +} + + +void GLArea::onTimeout() +{ + anim += 0.0001; + if (anim > 1) anim--; + update(); +} + + +#define SET_VALUE(orig, signal) \ + qDebug() << "GLArea, setting " #orig " from" << orig << "to" << value; \ + if (value > orig##_max) value = orig##_max;\ + if (value < orig##_min) value = orig##_min;\ + if (value != orig) {\ + orig = value;\ + emit signal(orig);\ + update();\ + } +void GLArea::setDistance(double value) { SET_VALUE(distance, distanceChanged); } +void GLArea::setFocalLength(double value) { SET_VALUE(focal_length, focalLengthChanged); } +void GLArea::setNearClip(double value) { SET_VALUE(near_clip, nearClipChanged); } +void GLArea::setFarClip(double value) { SET_VALUE(far_clip, farClipChanged); } +void GLArea::setAngle(double value) +{ + while (value > angle_max) value -= angle_max; + while (value < angle_min) value += angle_min; + SET_VALUE(angle, angleChanged); +} +#undef SET_VALUE diff --git a/glarea.h b/glarea.h new file mode 100644 index 0000000..6ecd684 --- /dev/null +++ b/glarea.h @@ -0,0 +1,102 @@ +// CC-BY Edouard.Thiel@univ-amu.fr - 22/01/2019 + +#ifndef GLAREA_H +#define GLAREA_H + +#include +#include +#include +#include +#include + +#include + + +class GLArea : public QOpenGLWidget, + protected QOpenGLFunctions +{ + Q_OBJECT + +public: + explicit GLArea(QWidget *parent = 0); + ~GLArea(); + + static constexpr double distance_min = 0; + static constexpr double distance_max = 5; + static constexpr double distance_step = .1; + + static constexpr double focal_length_min = 0; + static constexpr double focal_length_max = .2; + static constexpr double focal_length_step = .005; + + static constexpr double near_clip_min = 0; + static constexpr double near_clip_max = 1; + static constexpr double near_clip_step = .05; + + static constexpr double far_clip_min = 2; + static constexpr double far_clip_max = 7; + static constexpr double far_clip_step = .1; + + static constexpr double angle_min = 0; + static constexpr double angle_max = 360; + static constexpr double angle_step = 1; + + double getDistance() const { return distance; } + double getFocalLength() const { return focal_length; } + double getNearClip() const { return near_clip; } + double getFarClip() const { return far_clip; } + double getAngle() const { return angle; } + + +public slots: + void setDistance(double d); + void setFocalLength(double f); + void setNearClip(double n); + void setFarClip(double f); + void setAngle(double a); + +signals: + void distanceChanged(double d); + void focalLengthChanged(double f); + void nearClipChanged(double n); + void farClipChanged(double f); + void angleChanged(double a); + +protected slots: + void onTimeout(); + +protected: + void initializeGL() override; + void doProjection(); + void resizeGL(int w, int h) override; + void paintGL() override; + void keyPressEvent(QKeyEvent *ev) override; + void mousePressEvent(QMouseEvent *ev) override; + void mouseMoveEvent(QMouseEvent *ev) override; + void wheelEvent(QWheelEvent *ev) override; + +private: + QTimer *timer = nullptr; + double anim = 0; + double ratio = 1; + + // Pour utiliser les shaders + QOpenGLShaderProgram *program; + int posAttr; + int colAttr; + int matrix_uniform; + + Scene scene; + + float mouse_last[2] = {0, 0}; + double horiz_angle = 0; + double vert_angle = 0; + + double distance = 3; + double focal_length = .1; + double near_clip = .1; + double far_clip = 5; + double angle = 0; +}; + +#endif // GLAREA_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..473287f --- /dev/null +++ b/main.cpp @@ -0,0 +1,13 @@ +// CC-BY Edouard.Thiel@univ-amu.fr - 22/01/2019 + +#include "princ.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Princ w; + w.show(); + + return a.exec(); +} diff --git a/princ.cpp b/princ.cpp new file mode 100644 index 0000000..44870fa --- /dev/null +++ b/princ.cpp @@ -0,0 +1,16 @@ +// CC-BY Edouard.Thiel@univ-amu.fr - 22/01/2019 + +#include "princ.h" +#include + +Princ::Princ(QWidget *parent) : + QMainWindow(parent) +{ + setupUi(this); + diag.setGLArea(glarea); +} + +void Princ::showDiag() +{ + diag.show(); +} diff --git a/princ.h b/princ.h new file mode 100644 index 0000000..9ce0f4d --- /dev/null +++ b/princ.h @@ -0,0 +1,22 @@ +// CC-BY Edouard.Thiel@univ-amu.fr - 22/01/2019 + +#ifndef PRINC_H +#define PRINC_H + +#include "ui_princ.h" + +#include "settingsdialog.h" + +class Princ : public QMainWindow, private Ui::Princ +{ + Q_OBJECT + SettingsDialog diag; + +protected slots: + void showDiag(); + +public: + explicit Princ(QWidget *parent = 0); +}; + +#endif // PRINC_H diff --git a/princ.ui b/princ.ui new file mode 100644 index 0000000..82fd071 --- /dev/null +++ b/princ.ui @@ -0,0 +1,110 @@ + + + Princ + + + + 0 + 0 + 405 + 292 + + + + Princ + + + + + + + + + + + Réglages + + + + + + + Quit + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + 405 + 20 + + + + + + + + GLArea + QOpenGLWidget +
glarea.h
+
+
+ + + + btn_quit + clicked() + Princ + close() + + + 393 + 53 + + + 353 + 73 + + + + + btn_diag + clicked() + Princ + showDiag() + + + 101 + 45 + + + 538 + 167 + + + + + + showDiag() + +
diff --git a/propslider.cpp b/propslider.cpp new file mode 100644 index 0000000..5307ce4 --- /dev/null +++ b/propslider.cpp @@ -0,0 +1,63 @@ +#include "propslider.h" + +#include + + +PropSlider::PropSlider(QWidget *parent) + :QSlider(parent), + mapped_value(mapValue()) +{ + connect(this, SIGNAL(valueChanged(int)), + this, SLOT(setValue(int))); +} + + +int PropSlider::mapValue() const +{ + return (value - min) * maximum() / (max - min); +} + + +double PropSlider::unmapValue() const +{ + return (double) mapped_value * (max - min) / maximum() + min; +} + + +void PropSlider::setMinimum(double min) +{ + this->min = min; +} + + +void PropSlider::setMaximum(double max) +{ + this->max = max; + ((QSlider *) this)->setMaximum((max-min) / step); +} + + +void PropSlider::setStep(double step) +{ + this->step = step; + setMaximum(max); +} + + +void PropSlider::setValue(double value) +{ + qDebug() << "PropSlider, setting from double" << value; + this->value = value; + ((QSlider *) this)->setValue(mapValue()); +} + + +void PropSlider::setValue(int mapped_value) { + qDebug() << "PropSlider, setting from int" << mapped_value; + if (mapValue() != mapped_value) { + qDebug() << "Mapped value changed, transmitting to GLArea"; + this->mapped_value = mapped_value; + this->value = unmapValue(); + emit valueChanged(this->value); + } +} diff --git a/propslider.h b/propslider.h new file mode 100644 index 0000000..a2b71d0 --- /dev/null +++ b/propslider.h @@ -0,0 +1,42 @@ +#ifndef PROPSLIDER_H +#define PROPSLIDER_H + +#include + + +/* + Widget qui traduit les valeurs entières renvoyées par un QSlider en + double pour contrôler une propriété en fonction d’un minimum, d’un + maximum et d’un pas. + */ +class PropSlider : public QSlider { + Q_OBJECT + + double min = 0; + double max = 1; + double step = .1; + double value = .5; + int mapped_value; + + int mapValue() const; + double unmapValue() const; + + public: + PropSlider(QWidget *parent=nullptr); + void setMinimum(double min); + void setMaximum(double max); + void setStep(double step); + + signals: + void valueChanged(double value); + + public slots: + void setValue(double value); + + private slots: + // Connecté au QSlider + void setValue(int mapped_value); +}; + + +#endif diff --git a/scene.cpp b/scene.cpp new file mode 100644 index 0000000..87a75c4 --- /dev/null +++ b/scene.cpp @@ -0,0 +1,91 @@ +#include "scene.h" +#include +#include + +using namespace std; + + +Scene::Scene() + :volant(.2, .55, 8, Color(.522, .816, 1)), + axe_volant(.6, .06, 6, Color(.522*.5, .816*.5, 1.5)), + manivelle(.2, .115, 8, Color(.078, .718, .078)), + axe_manivelle(.35, .06, 6, Color(.078*.5, .718*.5, .078*.5)), + bague_bielle(.2, .14, 8, Color(.078, .718, .078)), + bague_piston(.2, .115, 8, Color(.69, .11, .69)), + axe_bielle_piston(.36, .06, 6, Color(.69*.5, .11*.5, .69*.5)), + bielle(1.5, .05, 6, Color(.173, .824, .173)), + piston(1.1, .065, 6, Color(.847, .318, .847)), + cylindre(1.2, .15, 8, Color(.702, .424, .286)) {} + + +void Scene::draw(QOpenGLFunctions &f, QOpenGLShaderProgram *prog, int mat_uni, + float alpha, QMatrix4x4 &matrix, int pos, int col) +{ + float gh = .45; + float xh = gh*cos(alpha); + float yh = gh*sin(alpha); + + QMatrix4x4 m, m2; + + /* Volant */ + m = matrix; + matrix.rotate(alpha*360/(2*M_PI), 0, 0, 1); + prog->setUniformValue(mat_uni, matrix); + volant.draw(f, pos, col); + m2 = matrix; + matrix.translate(0, 0, -axe_volant.ep/2 + .125); + prog->setUniformValue(mat_uni, matrix); + axe_volant.draw(f, pos, col); + matrix = m2; + matrix.translate(gh, 0, axe_manivelle.ep/2); + prog->setUniformValue(mat_uni, matrix); + axe_manivelle.draw(f, pos, col); + matrix = m; + + /* Manivelle */ + m = matrix; + matrix.translate(xh, yh, volant.ep/2+manivelle.ep/2); + prog->setUniformValue(mat_uni, matrix); + manivelle.draw(f, pos, col); + matrix = m; + + float hj = bielle.ep; + float xj = xh - sqrtf(hj*hj - powf(gh*sin(alpha), 2)); + float b = atanf(yh / (xj-xh < 0 ? xj-xh : -xj+xh)); + m = matrix; + matrix.translate(xj, 0, volant.ep/2+manivelle.ep/2); + prog->setUniformValue(mat_uni, matrix); + bague_bielle.draw(f, pos, col); + /* Bielle */ + m2 = matrix; + matrix.rotate(90, 0, 1, 0); + matrix.rotate(b*360/(2*M_PI), 1, 0, 0); + matrix.translate(0, 0, bielle.ep/2); + prog->setUniformValue(mat_uni, matrix); + bielle.draw(f, pos, col); + matrix = m2; + /* Piston */ + m2 = matrix; + matrix.translate(0, 0, axe_bielle_piston.ep/2); + prog->setUniformValue(mat_uni, matrix); + axe_bielle_piston.draw(f, pos, col); + matrix.translate(0, 0, axe_bielle_piston.ep/2 - .15); + prog->setUniformValue(mat_uni, matrix); + bague_piston.draw(f, pos, col); + matrix.rotate(90, 0, 1, 0); + matrix.translate(0, 0, -piston.ep/2); + prog->setUniformValue(mat_uni, matrix); + piston.draw(f, pos, col); + matrix = m2; + matrix = m; + + /* Cylindre */ + m = matrix; + matrix.translate(-gh-bielle.ep - piston.ep + .3, 0, volant.ep/2 + + bague_bielle.ep + + bague_piston.ep/2); + matrix.rotate(90, 0, 1, 0); + prog->setUniformValue(mat_uni, matrix); + cylindre.draw(f, pos, col); + matrix = m; +} diff --git a/scene.h b/scene.h new file mode 100644 index 0000000..6aa5687 --- /dev/null +++ b/scene.h @@ -0,0 +1,31 @@ +#ifndef SCENE_H +#define SCENE_H + +#include +#include +#include +#include + + +class Scene +{ +public: + Scene(); + void draw(QOpenGLFunctions &f, QOpenGLShaderProgram *prog, int mat_uni, + float alpha, QMatrix4x4 &matrix, int vertices, int colors); + +private: + Cylinder volant; + Cylinder axe_volant; + Cylinder manivelle; + Cylinder axe_manivelle; + Cylinder bague_bielle; + Cylinder bague_piston; + Cylinder axe_bielle_piston; + Cylinder bielle; + Cylinder piston; + Cylinder cylindre; +}; + + +#endif diff --git a/settingsdialog.cpp b/settingsdialog.cpp new file mode 100644 index 0000000..8cbc32e --- /dev/null +++ b/settingsdialog.cpp @@ -0,0 +1,63 @@ +#include "settingsdialog.h" + + +SettingsDialog::SettingsDialog(QWidget *parent) + :QDialog(parent) +{ + setupUi(this); +} + + +void SettingsDialog::setGLArea(GLArea *area) { + glarea = area; + + // Paramétrage des PropSliders + sli_distance->setMinimum(GLArea::distance_min); + sli_distance->setStep(GLArea::distance_step); + sli_distance->setMaximum(GLArea::distance_max); + sli_distance->setValue(glarea->getDistance()); + + sli_focal_length->setMinimum(GLArea::focal_length_min); + sli_focal_length->setStep(GLArea::focal_length_step); + sli_focal_length->setMaximum(GLArea::focal_length_max); + sli_focal_length->setValue(glarea->getFocalLength()); + + sli_near_clip->setMinimum(GLArea::near_clip_min); + sli_near_clip->setStep(GLArea::near_clip_step); + sli_near_clip->setMaximum(GLArea::near_clip_max); + sli_near_clip->setValue(glarea->getNearClip()); + + sli_far_clip->setMinimum(GLArea::far_clip_min); + sli_far_clip->setStep(GLArea::far_clip_step); + sli_far_clip->setMaximum(GLArea::far_clip_max); + sli_far_clip->setValue(glarea->getFarClip()); + + sli_angle->setMinimum(GLArea::angle_min); + sli_angle->setStep(GLArea::angle_step); + sli_angle->setMaximum(GLArea::angle_max); + sli_angle->setValue(glarea->getAngle()); + + // GLArea -> PropSlider + connect(glarea, SIGNAL(distanceChanged(double)), + sli_distance, SLOT(setValue(double))); + connect(glarea, SIGNAL(focalLengthChanged(double)), + sli_focal_length, SLOT(setValue(double))); + connect(glarea, SIGNAL(nearClipChanged(double)), + sli_near_clip, SLOT(setValue(double))); + connect(glarea, SIGNAL(farClipChanged(double)), + sli_far_clip, SLOT(setValue(double))); + connect(glarea, SIGNAL(angleChanged(double)), + sli_angle, SLOT(setValue(double))); + + // PropSlider -> GLArea + connect(sli_distance, SIGNAL(valueChanged(double)), + glarea, SLOT(setDistance(double))); + connect(sli_focal_length, SIGNAL(valueChanged(double)), + glarea, SLOT(setFocalLength(double))); + connect(sli_near_clip, SIGNAL(valueChanged(double)), + glarea, SLOT(setNearClip(double))); + connect(sli_far_clip, SIGNAL(valueChanged(double)), + glarea, SLOT(setFarClip(double))); + connect(sli_angle, SIGNAL(valueChanged(double)), + glarea, SLOT(setAngle(double))); +} diff --git a/settingsdialog.h b/settingsdialog.h new file mode 100644 index 0000000..b1c2394 --- /dev/null +++ b/settingsdialog.h @@ -0,0 +1,34 @@ +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include "ui_settingsdialog.h" +#include "glarea.h" + +class SettingsDialog : public QDialog, private Ui::SettingsDialog +{ + Q_OBJECT + GLArea *glarea; + // static void setupSlider(const Property &p, QSlider *s); + // static int rawToSlider(const Property &p); + // static double sliderToRaw(const Property &p, int value); + +public: + explicit SettingsDialog(QWidget *parent = nullptr); + void setGLArea(GLArea *area); + +// public slots: +// void setDistance(double raw_value); +// void setFocalLength(double raw_value); +// void setNearClip(double raw_value); +// void setFarClip(double raw_value); +// void setAngle(double raw_value); + +// protected slots: +// void onSliderDistance(int value); +// void onSliderFocalLength(int value); +// void onSliderNearClip(int value); +// void onSliderFarClip(int value); +// void onSliderAngle(int value); +}; + +#endif // SETTINGSDIALOG_H diff --git a/settingsdialog.ui b/settingsdialog.ui new file mode 100644 index 0000000..472d56d --- /dev/null +++ b/settingsdialog.ui @@ -0,0 +1,152 @@ + + + SettingsDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + + + Qt::Horizontal + + + + + + + Distance (zZ) + + + + + + + Qt::Horizontal + + + + + + + Focale (rR) + + + + + + + Qt::Horizontal + + + + + + + Coupe avant (nN) + + + + + + + Qt::Horizontal + + + + + + + Coupe arrière (fF) + + + + + + + Qt::Horizontal + + + + + + + Angle (spc) + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + PropSlider + QSlider +
propslider.h
+
+
+ + + + buttonBox + accepted() + SettingsDialog + accept() + + + 227 + 281 + + + 157 + 274 + + + + + buttonBox + rejected() + SettingsDialog + reject() + + + 295 + 287 + + + 286 + 274 + + + + + + onSliderDistance(int) + onSliderFocalLength(int) + onSliderNearClip(int) + onSliderFarClip(int) + onSliderAngle(int) + +
diff --git a/tp3.pro b/tp3.pro new file mode 100644 index 0000000..09d0af9 --- /dev/null +++ b/tp3.pro @@ -0,0 +1,36 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2019-01-12T12:27:11 +# +#------------------------------------------------- + +QT += core gui + +CONFIG += c++14 debug + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = tp3 +TEMPLATE = app + + +SOURCES += main.cpp\ + princ.cpp \ + glarea.cpp \ + cylinder.cpp \ + scene.cpp \ + settingsdialog.cpp \ + propslider.cpp + +HEADERS += princ.h \ + glarea.h \ + scene.h \ + cylinder.h \ + settingsdialog.h \ + propslider.h + +FORMS += princ.ui \ + settingsdialog.ui + +RESOURCES += \ + tp3.qrc diff --git a/tp3.qrc b/tp3.qrc new file mode 100644 index 0000000..5b369b7 --- /dev/null +++ b/tp3.qrc @@ -0,0 +1,6 @@ + + + basic.fsh + basic.vsh + +