mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 10:42:29 +01:00
Fix shader compilation and demo project
This commit is contained in:
parent
f47f299e9e
commit
d75893dcd1
@ -1,9 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ScreenPlayShader LANGUAGES CXX)
|
||||
project(
|
||||
ScreenPlayShader
|
||||
VERSION 0.1
|
||||
LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
find_package(
|
||||
Qt6
|
||||
@ -12,44 +14,45 @@ find_package(
|
||||
|
||||
set(QML src/ShadertoyShader.qml src/TestMain.qml)
|
||||
|
||||
set(QML_PLUGIN_SOURCES src/shaderlibrary.cpp)
|
||||
|
||||
set(QML_PLUGIN_HEADER src/shaderlibrary.h)
|
||||
|
||||
|
||||
qt_add_library(${PROJECT_NAME} STATIC)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC src/ )
|
||||
|
||||
qt_add_qml_module(
|
||||
${PROJECT_NAME}
|
||||
OUTPUT_DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}
|
||||
URI
|
||||
${PROJECT_NAME}
|
||||
VERSION
|
||||
1.0
|
||||
SOURCES
|
||||
${QML_PLUGIN_SOURCES}
|
||||
${QML_PLUGIN_HEADER}
|
||||
QML_FILES
|
||||
${QML})
|
||||
|
||||
# https://doc.qt.io/qt-6/qtshadertools-build.html
|
||||
qt6_add_shaders(
|
||||
${PROJECT_NAME}
|
||||
"shaders"
|
||||
BATCHABLE
|
||||
PRECOMPILE
|
||||
PREFIX
|
||||
"/ScreenPlayShader"
|
||||
"/"
|
||||
FILES
|
||||
# shader/lightning.frag shader/lightning.vert
|
||||
shaders/wobble.frag
|
||||
shaders/water.frag
|
||||
shaders/water.vert)
|
||||
|
||||
# https://doc.qt.io/qt-6/qtshadertools-build.html
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick)
|
||||
|
||||
if(${SCREENPLAY_TESTS})
|
||||
qt_add_executable(tst_ScreenPlayShader src/TestMain.cpp)
|
||||
|
||||
qt_add_qml_module(
|
||||
tst_ScreenPlayShader
|
||||
URI
|
||||
ScreenPlayShader
|
||||
VERSION
|
||||
1.0
|
||||
QML_FILES
|
||||
${QML})
|
||||
|
||||
target_link_libraries(
|
||||
tst_ScreenPlayShader
|
||||
PRIVATE Qt6::Quick
|
||||
Qt::Core
|
||||
Qt::Gui
|
||||
Qt::Qml
|
||||
Qt::Quick
|
||||
${PROJECT_NAME})
|
||||
|
||||
qt_add_executable(tst_ScreenPlayShader src/TestMain.cpp Resources.qrc)
|
||||
target_link_libraries(tst_ScreenPlayShader PRIVATE Qt::Quick ${PROJECT_NAME}plugin )
|
||||
target_compile_definitions(tst_ScreenPlayShader PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
|
||||
endif()
|
||||
|
8
ScreenPlayShader/Resources.qrc
Normal file
8
ScreenPlayShader/Resources.qrc
Normal file
@ -0,0 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>assets/Shadertoy_Bayer.png</file>
|
||||
<file>assets/Shadertoy_Gray_Noise_Medium.png</file>
|
||||
<file>assets/Shadertoy_Lichen.jpg</file>
|
||||
<file>assets/test_image_andras-vas-Bd7gNnWJBkU-unsplash.jpg</file>
|
||||
</qresource>
|
||||
</RCC>
|
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
@ -1,8 +1,9 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QVersionNumber>
|
||||
#include <QtQml/qqmlextensionplugin.h>
|
||||
|
||||
Q_IMPORT_QML_PLUGIN(ScreenPlayShaderPlugin)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
@ -12,19 +12,23 @@ Window {
|
||||
|
||||
Image {
|
||||
id: img
|
||||
anchors.centerIn: parent
|
||||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
|
||||
layer.enabled: true
|
||||
layer.effect: ShaderEffect {
|
||||
//property variant source: theSource
|
||||
property real amplitude: 0.04 * 1
|
||||
property real frequency: 20
|
||||
property real frequency: 200
|
||||
property real time: 0
|
||||
NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
|
||||
NumberAnimation on time {
|
||||
loops: Animation.Infinite
|
||||
from: 0
|
||||
to: Math.PI * 2
|
||||
duration: 600
|
||||
}
|
||||
|
||||
fragmentShader: " :/ScreenPlayShader/shaders/wobble.frag.qsb"
|
||||
fragmentShader: "/shaders/wobble.frag.qsb"
|
||||
}
|
||||
source: Qt.resolvedUrl(
|
||||
"file:///C:/Users/Eli/Desktop/jasmin-ne-Z4zOxNBri5I-unsplash.jpg")
|
||||
source: "qrc:/assets/test_image_andras-vas-Bd7gNnWJBkU-unsplash.jpg"
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
class Shader : public QObject {
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
Q_PROPERTY(QString vertex READ vertex WRITE setVertex NOTIFY vertexChanged)
|
||||
Q_PROPERTY(QString fragment READ fragment WRITE setFragment NOTIFY fragmentChanged)
|
||||
|
Loading…
Reference in New Issue
Block a user