Skip to content

Commit

Permalink
[what] 实现 test_gl_transition
Browse files Browse the repository at this point in the history
  • Loading branch information
HR1025 committed Sep 8, 2024
1 parent 48bd590 commit c1f126f
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Core
Submodule Core updated 93 files
+2 −0 GPU/GL/D3D11/D3D11DrawContex.cpp
+1 −0 GPU/GL/OpenGL/OpenGLDrawContex.cpp
+90 −0 GPU/PG/CMakeLists.txt
+73 −0 GPU/PG/Transition/AngularTransition.cpp
+47 −0 GPU/PG/Transition/AngularTransition.h
+66 −0 GPU/PG/Transition/BurnTransition.cpp
+45 −0 GPU/PG/Transition/BurnTransition.h
+85 −0 GPU/PG/Transition/ButterflyWaveScrawlerTransition.cpp
+48 −0 GPU/PG/Transition/ButterflyWaveScrawlerTransition.h
+52 −0 GPU/PG/Transition/CannabisleafTransition.cpp
+40 −0 GPU/PG/Transition/CannabisleafTransition.h
+71 −0 GPU/PG/Transition/CircleCropTransition.cpp
+47 −0 GPU/PG/Transition/CircleCropTransition.h
+77 −0 GPU/PG/Transition/CircleTransition.cpp
+47 −0 GPU/PG/Transition/CircleTransition.h
+64 −0 GPU/PG/Transition/CircleopenTransition.cpp
+46 −0 GPU/PG/Transition/CircleopenTransition.h
+74 −0 GPU/PG/Transition/ColorphaseTransition.cpp
+47 −0 GPU/PG/Transition/ColorphaseTransition.h
+67 −0 GPU/PG/Transition/ColourDistanceTransition.cpp
+47 −0 GPU/PG/Transition/ColourDistanceTransition.h
+75 −0 GPU/PG/Transition/CrazyParametricFunTransition.cpp
+49 −0 GPU/PG/Transition/CrazyParametricFunTransition.h
+111 −0 GPU/PG/Transition/CrossZoomTransition.cpp
+50 −0 GPU/PG/Transition/CrossZoomTransition.h
+72 −0 GPU/PG/Transition/CrosshatchTransition.cpp
+48 −0 GPU/PG/Transition/CrosshatchTransition.h
+47 −0 GPU/PG/Transition/CrosswarpTransition.cpp
+38 −0 GPU/PG/Transition/CrosswarpTransition.h
+125 −0 GPU/PG/Transition/CubeTransition.cpp
+49 −0 GPU/PG/Transition/CubeTransition.h
+72 −0 GPU/PG/Transition/DirectionalwarpTransition.cpp
+48 −0 GPU/PG/Transition/DirectionalwarpTransition.h
+71 −0 GPU/PG/Transition/DirectionalwipeTransition.cpp
+47 −0 GPU/PG/Transition/DirectionalwipeTransition.h
+106 −0 GPU/PG/Transition/DoomScreenTransitionTransition.cpp
+50 −0 GPU/PG/Transition/DoomScreenTransitionTransition.h
+106 −0 GPU/PG/Transition/DoorwayTransition.cpp
+48 −0 GPU/PG/Transition/DoorwayTransition.h
+50 −0 GPU/PG/Transition/DreamyTransition.cpp
+38 −0 GPU/PG/Transition/DreamyTransition.h
+88 −0 GPU/PG/Transition/DreamyZoomTransition.cpp
+47 −0 GPU/PG/Transition/DreamyZoomTransition.h
+49 −0 GPU/PG/Transition/FadeTransition.cpp
+38 −0 GPU/PG/Transition/FadeTransition.h
+68 −0 GPU/PG/Transition/FadecolorTransition.cpp
+46 −0 GPU/PG/Transition/FadecolorTransition.h
+70 −0 GPU/PG/Transition/FadegrayscaleTransition.cpp
+46 −0 GPU/PG/Transition/FadegrayscaleTransition.h
+74 −0 GPU/PG/Transition/FlyeyeTransition.cpp
+47 −0 GPU/PG/Transition/FlyeyeTransition.h
+115 −0 GPU/PG/Transition/GlitchDisplaceTransition.cpp
+38 −0 GPU/PG/Transition/GlitchDisplaceTransition.h
+135 −0 GPU/PG/Transition/GridFlipTransition.cpp
+52 −0 GPU/PG/Transition/GridFlipTransition.h
+56 −0 GPU/PG/Transition/HeartTransition.cpp
+38 −0 GPU/PG/Transition/HeartTransition.h
+127 −0 GPU/PG/Transition/HexagonalizeTransition.cpp
+48 −0 GPU/PG/Transition/HexagonalizeTransition.h
+78 −0 GPU/PG/Transition/KaleidoscopeTransition.cpp
+48 −0 GPU/PG/Transition/KaleidoscopeTransition.h
+69 −0 GPU/PG/Transition/MorphTransition.cpp
+46 −0 GPU/PG/Transition/MorphTransition.h
+115 −0 GPU/PG/Transition/PerlinTransition.cpp
+48 −0 GPU/PG/Transition/PerlinTransition.h
+68 −0 GPU/PG/Transition/PinwheelTransition.cpp
+46 −0 GPU/PG/Transition/PinwheelTransition.h
+68 −0 GPU/PG/Transition/PixelizeTransition.cpp
+48 −0 GPU/PG/Transition/PixelizeTransition.h
+71 −0 GPU/PG/Transition/PolarFunctionTransition.cpp
+46 −0 GPU/PG/Transition/PolarFunctionTransition.h
+66 −0 GPU/PG/Transition/RadialTransition.cpp
+47 −0 GPU/PG/Transition/RadialTransition.h
+70 −0 GPU/PG/Transition/RandomsquaresTransition.cpp
+47 −0 GPU/PG/Transition/RandomsquaresTransition.h
+70 −0 GPU/PG/Transition/RippleTransition.cpp
+47 −0 GPU/PG/Transition/RippleTransition.h
+77 −0 GPU/PG/Transition/SquareswireTransition.cpp
+48 −0 GPU/PG/Transition/SquareswireTransition.h
+71 −0 GPU/PG/Transition/SqueezeTransition.cpp
+46 −0 GPU/PG/Transition/SqueezeTransition.h
+122 −0 GPU/PG/Transition/SwapTransition.cpp
+48 −0 GPU/PG/Transition/SwapTransition.h
+68 −0 GPU/PG/Transition/SwirlTransition.cpp
+40 −0 GPU/PG/Transition/SwirlTransition.h
+70 −0 GPU/PG/Transition/WindTransition.cpp
+46 −0 GPU/PG/Transition/WindTransition.h
+54 −0 GPU/PG/Transition/WindowblindsTransition.cpp
+38 −0 GPU/PG/Transition/WindowblindsTransition.h
+76 −0 GPU/PG/Transition/ZoomInCirclesTransition.cpp
+39 −0 GPU/PG/Transition/ZoomInCirclesTransition.h
+88 −0 GPU/PG/TransitionFactory.cpp
+2 −2 GPU/Windows/WindowFactory.cpp
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# README

简体中文
简体中文 | [English](./README_en.md)

## 简介

Expand Down Expand Up @@ -53,7 +53,7 @@ cmake --build build --config Release -j 16
## 用例

>
> 详细的配置可以通过 `-h` 进行查看.
> 详细的配置可以通过 `-h` 进行查看. (`Windows` 上使用 `\h`)
>
### test_gl_compositor
Expand All @@ -76,6 +76,26 @@ cmake --build build --config Release -j 16

![test_gl_compositor](./images/test_gl_compositor.png)

### test_gl_transition

`test_gl_transition` 展现了如何实现转场的效果, 转场一般出现在画面切换的时候.

`MMP-Core` 的转场移植自 [gl-transitions](https://github.com/gl-transitions/gl-transitions), 对其进行部分修改以便于同时支持 `GLSL``HLSL`.

`test_gl_compositor` 支持一些配置项, 如下:

- backend : 处理节点, 可能可选 OPENGL, OPENGL_ES, D3D11 和 VULKAN
- transition : 转场类型, 详细见 `-h`
- duration : 持续时间, 单位为 s

以下是 `SwapTransition` 在不同阶段的效果 `progress``0.25`, `0.5``0.75` 的效果:

![transition_25](./images/transition_25.png)

![transition_50](./images/transition_50.png)

![transition_75](./images/transition_75.png)

## 其他

在不同的平台上, 或者不同的驱动上, 相同的测试用例可能出现不同的效果, 或者更严重点甚至无法运行或者崩溃.
Expand Down
103 changes: 103 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# README

English | [简体中文](./README.md)

## Introduction

`mmp_sample` provides usage examples for some interfaces of [MMP-Core](https://github.com/HR1025/MMP-Core), demonstrated in a standalone *main.cpp*.

In other words, you don't need to pay special attention to the code under `include` and `source`, as they are just simple auxiliary interfaces.

Furthermore, you only need to focus on the implementation of `int App::main(const ArgVec& args)` in `xxx.cpp`.

All examples are concentrated in the root directory of the project, named as `xxx.cpp`; the name of the `.cpp` file corresponds to the executable program name for each example.

## Compilation

### Linux (Debian System)

```shell
sudo apt install libgbm-dev libgl1-mesa-dev* nasm libx11-dev libdrm-dev libva-dev
rm -rf build
mkdir build
git submodule update --init --recursive
cd build && cmake .. -DUSE_OPENGL=ON -DUSE_GBM=ON -DUSE_SDL=ON -DUSE_SPRIV_CROSS=ON -DUSE_VULKAN=ON -DUSE_X11=ON -DUSE_VAAPI=ON -DUSE_OPENH264=ON && make -j4
```

## Windows (MSVC 2022 x64)

```shell
git submodule update --init --recursive
mkdir build
cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S. -B./build -G "Visual Studio 17 2022" -T host=x86 -A win32
cmake --build build --config Release -j 16
```

## Windows (MSVC 2022 x86)

```shell
git submodule update --init --recursive
mkdir build
cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S. -B./build -G "Visual Studio 17 2022" -T host=x64 -A x64
cmake --build build --config Release -j 16
```

>
> You can also use an `IDE` directly for building on `Windows`, just select the corresponding toolchain during the build process.
>
## How to Debug

Choose an `IDE` tool that integrates with `CMake`. The demo includes a `launch.json` for use with `vscode`.

## Examples

>
> Detailed configurations can be viewed using `-h`. (Use `\h` on `Windows`)
>
### test_gl_compositor

The example `test_gl_compositor` demonstrates how to achieve multi-screen composition effects. In MMP-Core, three terms are defined: `Item`, `Layer`, and `Compositor`.

Multiple items can be added to a single layer, ensuring they do not overlap.

Multiple layers can be added to a single compositor, thus achieving screen composition functionality.

The example supports several configuration options:

- backend: Processing node, options include OPENGL, OPENGL_ES, D3D11, and VULKAN.
- split_num: Number of splits; defaults to 4 for a four-way split effect.
- frame_per_second: Refresh rate; defaults to 60 frames per second.
- merry_go_around: Marquee effect; moves the screen at a speed of two frames per second.
- duration: Duration in seconds.

Example image:

![test_gl_compositor](./images/test_gl_compositor.png)

### test_gl_transition

The example `test_gl_transition` demonstrates how to achieve transition effects typically seen during screen changes.

MMP-Core's transitions are ported from [gl-transitions](https://github.com/gl-transitions/gl-transitions) with modifications to support both GLSL and HLSL.

The example supports several configuration options:

- backend: Processing node; options include OPENGL, OPENGL_ES, D3D11, and VULKAN.
- transition: Transition type; see details with `-h`.
- duration: Duration in seconds.

Below is an illustration of the SwapTransition at different stages (`progress` at 0.25, 0.5, and 0.75):

![transition_25](./images/transition_25.png)

![transition_50](./images/transition_50.png)

![transition_75](./images/transition_75.png)

## Others

On different platforms or drivers, identical test cases may yield different results or even fail or crash due to cross-platform compatibility issues that are hard to detect and address during development or due to logical errors within MMP-Core itself.

Generally speaking, simple compatibility issues can often be resolved through basic troubleshooting and modifications.
Binary file added images/transition_25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/transition_50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/transition_75.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion source/PngA.c

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion source/PngB.c

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions test_gl_transition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,23 @@ void App::displayHelp()
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("Simple program to test nxn Compositor using MMP-Core.");
helpFormatter.format(ss);
ss << "Available transition:" << std::endl;
ss << "\t" << "BowTieHorizontalTransition, BowTieVerticalTransition, DirectionalTransition, GlitchMemoriesTransition" << std::endl;
ss << "\t" << "InvertedPageCurlTransition, LinearBlurTransition, PolkaDotsCurtainTransition, SimpleZoomTransition" << std::endl;
ss << "\t" << "StereoViewerTransition, WaterDropTransition, WindowsliceTransition, CircleCropTransition" << std::endl;
ss << "\t" << "ColourDistanceTransition, DirectionalwarpTransition, MorphTransition, PerlinTransition" << std::endl;
ss << "\t" << "SwirlTransition, CannabisleafTransition, ButterflyWaveScrawlerTransition, CrazyParametricFunTransition" << std::endl;
ss << "\t" << "CrosshatchTransition, CrossZoomTransition, DreamyTransition, KaleidoscopeTransition" << std::endl;
ss << "\t" << "GridFlipTransition, RadialTransition, ZoomInCirclesTransition, AngularTransition" << std::endl;
ss << "\t" << "BurnTransition, CircleopenTransition, CircleTransition, ColorphaseTransition" << std::endl;
ss << "\t" << "DoomScreenTransitionTransition, DreamyZoomTransition, GlitchDisplaceTransition, HexagonalizeTransition" << std::endl;
ss << "\t" << "PinwheelTransition, RippleTransition, WindowblindsTransition, CrosswarpTransition" << std::endl;
ss << "\t" << "CubeTransition, DirectionalwipeTransition, DoorwayTransition, FadecolorTransition" << std::endl;
ss << "\t" << "FadegrayscaleTransition, FadeTransition, FlyeyeTransition, HeartTransition" << std::endl;
ss << "\t" << "PixelizeTransition, PolarFunctionTransition, RandomsquaresTransition, SquareswireTransition" << std::endl;
ss << "\t" << "SqueezeTransition, SwapTransition, WindTransition" << std::endl;
ss << "(see `https://gl-transitions.com/gallery` for more information)" << std::endl;
MMP_LOG_INFO << ss.str();
MMP_LOG_INFO << "Available transition:";
MMP_LOG_INFO << "\t" << "BowTieHorizontalTransition, BowTieVerticalTransition, DirectionalTransition, GlitchMemoriesTransition";
MMP_LOG_INFO << "\t" << "InvertedPageCurlTransition, LinearBlurTransition, PolkaDotsCurtainTransition, SimpleZoomTransition";
MMP_LOG_INFO << "\t" << "StereoViewerTransition, WaterDropTransition, WindowsliceTransition";
MMP_LOG_INFO << "(see `https://gl-transitions.com/gallery` for more information)";
exit(0);
}

Expand Down Expand Up @@ -193,7 +204,7 @@ void App::defineOptions(OptionSet& options)
.argument("[type]")
.callback(OptionCallback<App>(this, &App::HandleBackend))
);
options.addOption(Option("duration", "d", "default(30) second")
options.addOption(Option("duration", "d", "default(1) second")
.required(false)
.repeatable(false)
.argument("[num]")
Expand Down

0 comments on commit c1f126f

Please sign in to comment.