diff --git a/.github/workflows/build-tests.yml b/.github/workflows/build-tests.yml deleted file mode 100644 index 6e17c69..0000000 --- a/.github/workflows/build-tests.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: jGL build tests - -on: - push: - branches-ignore: - - 'main' - - 'docs' - paths-ignore: - - 'doc/**' - workflow_dispatch: - -jobs: - linuxXlinux: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y build-essential xorg-dev mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev libxinerama-dev libxcursor-dev xvfb x11-apps vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools - - - name: linux-linux - run: | - ./build.sh -t -r -e - cp -r build/Examples linux-x86_64-examples - cp LICENSE linux-x86_64-examples/ - - - name: build examples artifact - uses: actions/upload-artifact@v4 - with: - name: linux-x86_64-examples - path: linux-x86_64-examples - - linuxXwindows: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y xorg-dev build-essential mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix libxinerama-dev libxcursor-dev vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools - - - name: linux-X-windows - run: | - ./build.sh -t -w -r -e - cp -r build/Examples windows-examples - cp LICENSE windows-examples/ - - - name: build examples artifact - uses: actions/upload-artifact@v4 - with: - name: windows-examples - path: windows-examples - - macOS: - runs-on: macos-13 - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Install dependencies - run: | - wget https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.zip -O vulkan-sdk.zip - unzip vulkan-sdk.zip - sudo ./InstallVulkan.app/Contents/macOS/InstallVulkan --root ~/vulkan --accept-licenses --default-answer --confirm-command install - ls ~/vulkan - cd ~/vulkan/ - python install_vulkan.py - - - name: macos-macos - run: | - ./build.sh -o -e -r - cp -r build/Examples macos-examples - cp LICENSE macos-examples/ - - - name: build examples artifact - uses: actions/upload-artifact@v4 - with: - name: macos-examples - path: macos-examples \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8725d6d..a2ee5c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: jGL release +name: jGL CI on: push: @@ -8,6 +8,7 @@ on: - 'doc/**' - '.github/**' workflow_dispatch: + pull_request: jobs: @@ -60,7 +61,7 @@ jobs: name: headers-mingw path: headers-mingw - linuxNative: + linux: runs-on: ubuntu-20.04 steps: @@ -68,7 +69,7 @@ jobs: with: submodules: 'true' - - name: Install dependencies + - name: install dependencies run: sudo apt-get update && sudo apt-get install -y build-essential xorg-dev mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev libxinerama-dev libxcursor-dev xvfb x11-apps vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools - name: linux-linux @@ -80,7 +81,7 @@ jobs: cp LICENSE linux-x86_64-examples/ cp LICENSE linux-x86_64/ - - name: Tests + - name: unit tests working-directory: ${{github.workspace}}/build # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail @@ -102,7 +103,7 @@ jobs: name: linux-x86_64-examples path: linux-x86_64-examples - linuxXwindows: + windows: runs-on: ubuntu-22.04 steps: @@ -110,7 +111,7 @@ jobs: with: submodules: 'true' - - name: Install dependencies + - name: install dependencies run: sudo apt-get update && sudo apt-get install -y xorg-dev build-essential mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix libxinerama-dev libxcursor-dev vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools - name: linux-X-windows @@ -119,6 +120,8 @@ jobs: mkdir windows cp -r build/Examples windows-examples cp build/libjGL.a windows/libjGL-windows.a + cp build/*.dll windows/ + cp build/*.dll windows-examples/ cp LICENSE windows-examples/ cp LICENSE windows/ @@ -134,7 +137,7 @@ jobs: name: windows-examples path: windows-examples - macosNative: + macos: runs-on: macos-13 steps: @@ -142,7 +145,7 @@ jobs: with: submodules: 'true' - - name: Install dependencies + - name: install dependencies run: | wget https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.zip -O vulkan-sdk.zip unzip vulkan-sdk.zip @@ -173,11 +176,15 @@ jobs: path: macos-examples linuxRun: - needs: linuxNative + needs: linux runs-on: ubuntu-22.04 + strategy: + matrix: + example: [Particles, Sprite, Shape] + steps: - - name: Install dependencies + - name: install dependencies run: sudo apt-get update && sudo apt-get install -y xvfb x11-apps imagemagick - name: get linux build @@ -188,12 +195,49 @@ jobs: - name: launch and screenshot run: | ls - cd Particles - chmod +x Particles + cd ${{ matrix.example }} + chmod +x ${{ matrix.example }} + export DISPLAY=:99 + sudo Xvfb :99 -screen 0 800x600x24 & + sleep 5 + MESA_GL_VERSION_OVERRIDE=3.3 ./${{ matrix.example }} & + export PID=$! + sleep 10 + xwd -root -silent | convert xwd:- png:screenshot.png + sleep 5 && kill $PID + + - name: upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.example }}.png + path: ${{ matrix.example }}/screenshot.png + + wineRun: + needs: windows + runs-on: ubuntu-22.04 + + strategy: + matrix: + example: [Particles, Sprite, Shape] + + steps: + - name: install dependencies + run: sudo apt-get update && sudo apt-get install -y xvfb x11-apps imagemagick wine64 + + - name: get linux build + uses: actions/download-artifact@v4 + with: + name: windows-examples + + - name: launch and screenshot + run: | + cd ${{ matrix.example }} + cp ../*.dll . + chmod +x ${{ matrix.example }}.exe export DISPLAY=:99 sudo Xvfb :99 -screen 0 800x600x24 & sleep 5 - MESA_GL_VERSION_OVERRIDE=3.3 ./Particles & + MESA_GL_VERSION_OVERRIDE=3.3 wine64 ${{ matrix.example }}.exe & export PID=$! sleep 10 xwd -root -silent | convert xwd:- png:screenshot.png @@ -202,44 +246,11 @@ jobs: - name: upload artifact uses: actions/upload-artifact@v4 with: - name: screenshot - path: Particles/screenshot.png - - # wineRun: - # needs: linuxXwindows - # runs-on: ubuntu-22.04 - - # steps: - # - name: Install dependencies - # run: sudo apt-get update && sudo apt-get install -y xvfb x11-apps imagemagick wine32 wine64 - - # - name: get linux build - # uses: actions/download-artifact@v4 - # with: - # name: windows-examples - - # - name: launch and screenshot - # run: | - # ls - # cd Particles - # chmod +x Particles.exe - # export DISPLAY=:99 - # sudo Xvfb :99 -screen 0 800x600x24 & - # sleep 5 - # MESA_GL_VERSION_OVERRIDE=3.3 wine64 Particles.exe & - # export PID=$! - # sleep 10 - # xwd -root -silent | convert xwd:- png:screenshot.png - # sleep 5 && kill $PID - - # - name: upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: screenshot-wine - # path: Particles/screenshot.png + name: ${{ matrix.example }}-wine.png + path: ${{ matrix.example }}/screenshot.png test-release: - needs: [linuxNative, headers] + needs: [linux, headers] runs-on: ubuntu-22.04 steps: @@ -259,7 +270,7 @@ jobs: with: name: linux-x86_64 - - name: Install dependencies + - name: install dependencies run: sudo apt-get update && sudo apt-get install -y xorg-dev build-essential mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix libxinerama-dev libxcursor-dev vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools xvfb x11-apps imagemagick - name: linux lib test @@ -274,7 +285,7 @@ jobs: cmake .. && make test-release-mingw: - needs: [linuxXwindows, headers] + needs: [windows, headers] runs-on: ubuntu-22.04 steps: @@ -294,7 +305,7 @@ jobs: with: name: windows - - name: Install dependencies + - name: install dependencies run: sudo apt-get update && sudo apt-get install -y xorg-dev build-essential mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix libxinerama-dev libxcursor-dev vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools xvfb x11-apps imagemagick - name: mingw lib test @@ -307,7 +318,7 @@ jobs: ./build.sh test-release-macos: - needs: [macosNative, headers] + needs: [macos, headers] runs-on: macos-13 steps: @@ -327,7 +338,7 @@ jobs: with: name: macos - - name: Install dependencies + - name: install dependencies run: | wget https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.zip -O vulkan-sdk.zip unzip vulkan-sdk.zip @@ -347,7 +358,7 @@ jobs: cmake .. -DCMAKE_TOOLCHAIN_FILE=../osx.cmake && make release: - needs: [linuxNative, linuxXwindows, macosNative] + needs: [linux, windows, macos] if: github.ref_type == 'tag' runs-on: ubuntu-22.04 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 05215bf..0000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: jGL run tests - -on: - pull_request: - workflow_dispatch: - -jobs: - linuxRunTest: - runs-on: ubuntu-22.04 - - strategy: - matrix: - example: [Particles, Sprite, Shape] - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y build-essential xorg-dev mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev libxinerama-dev libxcursor-dev xvfb x11-apps vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools - - - name: linux-linux - run: | - ./build.sh -t -r -e - - - name: run ${{ matrix.example }} - run: | - cd build/Examples/${{ matrix.example }} - chmod +x ${{ matrix.example }} - export DISPLAY=:99 - sudo Xvfb :99 -screen 0 800x600x24 & - sleep 5 - MESA_GL_VERSION_OVERRIDE=3.3 ./${{ matrix.example }} & - export PID=$! - sleep 10 - xwd -root -silent | convert xwd:- png:screenshot.png - sleep 5 && kill $PID - - - name: upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.example }}.png - path: build/Examples/${{ matrix.example }}/screenshot.png - - wineRunTest: - if: ${{ github.event_name == 'workflow_dispatch' }} - runs-on: ubuntu-22.04 - - strategy: - matrix: - example: [Particles, Sprite, Shape] - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y xorg-dev build-essential mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix libxinerama-dev libxcursor-dev xvfb x11-apps vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools wine64 - - name: linux-windows - run: | - ./build.sh -t -r -w -e - - - name: run ${{ matrix.example }} - run: | - cd build/Examples/${{ matrix.example }} - chmod +x ${{ matrix.example }}.exe - export DISPLAY=:99 - sudo Xvfb :99 -screen 0 800x600x24 & - sleep 5 - MESA_GL_VERSION_OVERRIDE=3.3 wine64 ${{ matrix.example }}.exe & - export PID=$! - sleep 10 - xwd -root -silent | convert xwd:- png:screenshot.png - sleep 5 && kill $PID - - - name: upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.example }}-wine.png - path: build/Examples/${{ matrix.example }}/screenshot.png \ No newline at end of file diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 5c95df8..0000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: jGL unit tests - -on: - push: - branches-ignore: 'docs' - paths-ignore: - - 'doc/**' - - '.github/**' - workflow_dispatch: - -jobs: - linuxUnitTest: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y build-essential xorg-dev mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev libxinerama-dev libxcursor-dev xvfb x11-apps vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools - - - name: linux-linux - run: | - ./build.sh -t -r - - - name: Tests - working-directory: ${{github.workspace}}/build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: | - export DISPLAY=:99 - sudo Xvfb :99 -screen 0 800x600x24 & - sleep 5 - MESA_GL_VERSION_OVERRIDE=3.3 ctest --exclude-regex Vulkan --extra-verbose --output-on-failure - - linuxWineUnitTest: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y xorg-dev build-essential mesa-common-dev libx11-dev libxrandr-dev libgl1-mesa-dev libglu1-mesa-dev libfreetype6-dev libopenal-dev libsndfile1-dev libudev-dev g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix libxinerama-dev libxcursor-dev vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools wine64 - - name: linux-windos - run: | - ./build.sh -t -r -w - - - name: Tests - working-directory: ${{github.workspace}}/build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: | - export DISPLAY=:99 - sudo Xvfb :99 -screen 0 800x600x24 & - sleep 5 - MESA_GL_VERSION_OVERRIDE=3.3 ctest --exclude-regex Vulkan --extra-verbose --output-on-failure diff --git a/build.sh b/build.sh index c6d4920..5adb4fb 100755 --- a/build.sh +++ b/build.sh @@ -177,8 +177,10 @@ then done echo -e "###############\n" - dll=() - + dll=("libgcc_s_seh-1.dll" + "libstdc++-6.dll" + "libwinpthread-1.dll" + ) for j in "${dll[@]}" do findAndCopyDLL $j || echo "Could not find $j" diff --git a/tests/regression/user/main.cpp b/tests/regression/main.cpp similarity index 100% rename from tests/regression/user/main.cpp rename to tests/regression/main.cpp diff --git a/tests/regression/user-macos/main.h b/tests/regression/main.h similarity index 100% rename from tests/regression/user-macos/main.h rename to tests/regression/main.h diff --git a/tests/regression/user-macos/rand.cpp b/tests/regression/rand.cpp similarity index 100% rename from tests/regression/user-macos/rand.cpp rename to tests/regression/rand.cpp diff --git a/tests/regression/user-macos/rand.h b/tests/regression/rand.h similarity index 100% rename from tests/regression/user-macos/rand.h rename to tests/regression/rand.h diff --git a/tests/regression/user-macos/CMakeLists.txt b/tests/regression/user-macos/CMakeLists.txt index 77b70c6..3229d5a 100644 --- a/tests/regression/user-macos/CMakeLists.txt +++ b/tests/regression/user-macos/CMakeLists.txt @@ -9,12 +9,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math -fno-rounding-math -f set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O3 -Wall") set(SRC - "main.cpp" - "rand.cpp" + "../main.cpp" + "../rand.cpp" ) include_directories(include) -include_directories(.) +include_directories(../) find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) diff --git a/tests/regression/user-macos/main.cpp b/tests/regression/user-macos/main.cpp deleted file mode 100644 index f42db6f..0000000 --- a/tests/regression/user-macos/main.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "main.h" - -int main(int argv, char ** argc) -{ - - jGL::DesktopDisplay::Config conf; - - conf.VULKAN = false; - conf.COCOA_RETINA = false; - - jGL::DesktopDisplay display(glm::ivec2(resX, resY), "Shape", conf); - - glewInit(); - - jGLInstance = std::move(std::make_unique(display.getRes())); - - jGL::OrthoCam camera(resX, resY, glm::vec2(0.0,0.0)); - - camera.setPosition(0.0f, 0.0f); - - jLog::Log log; - - high_resolution_clock::time_point tic, tock; - double rdt = 0.0; - - jGLInstance->setTextProjection(glm::ortho(0.0,double(resX),0.0,double(resY))); - jGLInstance->setMSAA(1); - - std::shared_ptr circles = jGLInstance->createShapeRenderer - ( - 32 - ); - - std::vector shapes; - - RNG rng; - - std::vector trans; - std::vector cols; - - trans.reserve(64); - shapes.reserve(64); - cols.reserve(64); - - for (unsigned i = 0; i < 64; i++) - { - trans.push_back(jGL::Transform(rng.nextFloat(), rng.nextFloat(), 0.0, 0.1f)); - cols.push_back(glm::vec4(rng.nextFloat(), rng.nextFloat(), rng.nextFloat(), 1.0)); - - shapes.push_back - ( - { - &trans[i], - &cols[i] - } - ); - - circles->add(shapes[i], std::to_string(i)); - } - - circles->setProjection(camera.getVP()); - - std::shared_ptr shader = std::make_shared(vertexShader, fragmentShader); - - shader->use(); - - double delta = 0.0; - double dt = 1.0/600.0; - - while (display.isOpen()) - { - tic = high_resolution_clock::now(); - - jGLInstance->beginFrame(); - - jGLInstance->clear(); - - for (unsigned i = 0; i getTransform(std::to_string(i)); - trans[i] = jGL::Transform - ( - tr->x+dt*(rng.nextFloat()-0.5), - tr->y+dt*(rng.nextFloat()-0.5), - tr->theta, - tr->scaleX - ); - } - - circles->draw(shader); - - delta = 0.0; - for (int n = 0; n < 60; n++) - { - delta += deltas[n]; - } - delta /= 60.0; - - std::stringstream debugText; - - double mouseX, mouseY; - display.mousePosition(mouseX,mouseY); - - debugText << "Delta: " << fixedLengthNumber(delta,6) - << " ( FPS: " << fixedLengthNumber(1.0/delta,4) - << ")\n" - << "Render draw time: \n" - << " " << fixedLengthNumber(rdt, 6) << "\n" - << "Mouse (" << fixedLengthNumber(mouseX,4) - << "," - << fixedLengthNumber(mouseY,4) - << ")\n"; - - jGLInstance->text( - debugText.str(), - glm::vec2(64.0f, resY-64.0f), - 0.5f, - glm::vec4(0.0f,0.0f,0.0f,1.0f) - ); - - if (frameId == 30) - { - if (log.size() > 0) - { - std::cout << log << "\n"; - } - } - - jGLInstance->endFrame(); - - display.loop(); - - tock = high_resolution_clock::now(); - - deltas[frameId] = duration_cast>(tock-tic).count(); - frameId = (frameId+1) % 60; - - } - - jGLInstance->finish(); - - return 0; -} \ No newline at end of file diff --git a/tests/regression/user-mingw/CMakeLists.txt b/tests/regression/user-mingw/CMakeLists.txt index d4051f9..cfc229a 100644 --- a/tests/regression/user-mingw/CMakeLists.txt +++ b/tests/regression/user-mingw/CMakeLists.txt @@ -9,15 +9,15 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math -fno-rounding-math -f set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O3 -Wall") set(SRC - "main.cpp" - "rand.cpp" + "../main.cpp" + "../rand.cpp" ) # launch as windows, not console app - so cmd does not open as well add_link_options(-mwindows) include_directories(include) -include_directories(.) +include_directories(../) find_package(Vulkan REQUIRED) find_package(OpenGL REQUIRED) diff --git a/tests/regression/user-mingw/main.cpp b/tests/regression/user-mingw/main.cpp deleted file mode 100644 index f42db6f..0000000 --- a/tests/regression/user-mingw/main.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "main.h" - -int main(int argv, char ** argc) -{ - - jGL::DesktopDisplay::Config conf; - - conf.VULKAN = false; - conf.COCOA_RETINA = false; - - jGL::DesktopDisplay display(glm::ivec2(resX, resY), "Shape", conf); - - glewInit(); - - jGLInstance = std::move(std::make_unique(display.getRes())); - - jGL::OrthoCam camera(resX, resY, glm::vec2(0.0,0.0)); - - camera.setPosition(0.0f, 0.0f); - - jLog::Log log; - - high_resolution_clock::time_point tic, tock; - double rdt = 0.0; - - jGLInstance->setTextProjection(glm::ortho(0.0,double(resX),0.0,double(resY))); - jGLInstance->setMSAA(1); - - std::shared_ptr circles = jGLInstance->createShapeRenderer - ( - 32 - ); - - std::vector shapes; - - RNG rng; - - std::vector trans; - std::vector cols; - - trans.reserve(64); - shapes.reserve(64); - cols.reserve(64); - - for (unsigned i = 0; i < 64; i++) - { - trans.push_back(jGL::Transform(rng.nextFloat(), rng.nextFloat(), 0.0, 0.1f)); - cols.push_back(glm::vec4(rng.nextFloat(), rng.nextFloat(), rng.nextFloat(), 1.0)); - - shapes.push_back - ( - { - &trans[i], - &cols[i] - } - ); - - circles->add(shapes[i], std::to_string(i)); - } - - circles->setProjection(camera.getVP()); - - std::shared_ptr shader = std::make_shared(vertexShader, fragmentShader); - - shader->use(); - - double delta = 0.0; - double dt = 1.0/600.0; - - while (display.isOpen()) - { - tic = high_resolution_clock::now(); - - jGLInstance->beginFrame(); - - jGLInstance->clear(); - - for (unsigned i = 0; i getTransform(std::to_string(i)); - trans[i] = jGL::Transform - ( - tr->x+dt*(rng.nextFloat()-0.5), - tr->y+dt*(rng.nextFloat()-0.5), - tr->theta, - tr->scaleX - ); - } - - circles->draw(shader); - - delta = 0.0; - for (int n = 0; n < 60; n++) - { - delta += deltas[n]; - } - delta /= 60.0; - - std::stringstream debugText; - - double mouseX, mouseY; - display.mousePosition(mouseX,mouseY); - - debugText << "Delta: " << fixedLengthNumber(delta,6) - << " ( FPS: " << fixedLengthNumber(1.0/delta,4) - << ")\n" - << "Render draw time: \n" - << " " << fixedLengthNumber(rdt, 6) << "\n" - << "Mouse (" << fixedLengthNumber(mouseX,4) - << "," - << fixedLengthNumber(mouseY,4) - << ")\n"; - - jGLInstance->text( - debugText.str(), - glm::vec2(64.0f, resY-64.0f), - 0.5f, - glm::vec4(0.0f,0.0f,0.0f,1.0f) - ); - - if (frameId == 30) - { - if (log.size() > 0) - { - std::cout << log << "\n"; - } - } - - jGLInstance->endFrame(); - - display.loop(); - - tock = high_resolution_clock::now(); - - deltas[frameId] = duration_cast>(tock-tic).count(); - frameId = (frameId+1) % 60; - - } - - jGLInstance->finish(); - - return 0; -} \ No newline at end of file diff --git a/tests/regression/user-mingw/main.h b/tests/regression/user-mingw/main.h deleted file mode 100644 index 7fd73b0..0000000 --- a/tests/regression/user-mingw/main.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef MAIN_H -#define MAIN_H - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -using namespace std::chrono; - -const int resX = 800; -const int resY = 1000; - -uint8_t frameId = 0; -double deltas[60]; - -std::unique_ptr jGLInstance; - -std::string fixedLengthNumber(double x, unsigned length) -{ - std::string d = std::to_string(x); - std::string dtrunc(length,' '); - for (unsigned c = 0; c < dtrunc.length(); c++/*ayy lmao*/) - { - - if (c >= d.length()) - { - dtrunc[c] = '0'; - } - else - { - dtrunc[c] = d[c]; - } - } - return dtrunc; -} - -const char * vertexShader = - "#version 330\n" - "precision lowp float;\n" - "in vec4 a_position;\n" - "in vec4 a_offset;\n" - "in vec4 a_colour;\n" - "uniform mat4 proj;\n" - "out vec2 texCoord;\n" - "out vec4 colour;\n" - "void main(void){" - "vec2 pos = a_position.xy*a_offset.w;\n" - "float ct = cos(a_offset.z); float st = sin(a_offset.z);\n" - "mat2 rot = mat2(ct, -st, st, ct);\n" - "pos = rot*pos + a_offset.xy;\n" - "gl_Position = proj*vec4(pos,0.0,1.0);\n" - "texCoord = a_position.zw;\n" - "colour = a_colour;\n" - "}"; - -const char * fragmentShader = - "#version 330\n" - "precision lowp float;\n" - "in vec2 texCoord;\n" - "in vec4 colour;\n" - "out vec4 fragment;\n" - "void main(void){\n" - "vec2 c = texCoord-vec2(0.5,0.5);\n" - "if (dot(c,c) > 0.5*0.5) {discard;}\n" - "fragment = colour;\n" - "}"; - -#endif /* MAIN_H */ diff --git a/tests/regression/user-mingw/rand.cpp b/tests/regression/user-mingw/rand.cpp deleted file mode 100644 index 8bd4a7e..0000000 --- a/tests/regression/user-mingw/rand.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -std::uniform_real_distribution RNG::floatU; -std::random_device RNG::device; -std::mt19937 RNG::engine(device()); diff --git a/tests/regression/user-mingw/rand.h b/tests/regression/user-mingw/rand.h deleted file mode 100644 index d703110..0000000 --- a/tests/regression/user-mingw/rand.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RAND_H -#define RAND_H - -#include - -class RNG -{ - -public: - - float nextFloat(){ return floatU(engine); } - -private: - - static std::uniform_real_distribution floatU; - static std::random_device device; - static std::mt19937 engine; - -}; - -#endif /* RAND_H */ - diff --git a/tests/regression/user/CMakeLists.txt b/tests/regression/user/CMakeLists.txt index 973ecce..e162cdd 100644 --- a/tests/regression/user/CMakeLists.txt +++ b/tests/regression/user/CMakeLists.txt @@ -8,8 +8,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math -fno-rounding-math -f set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O3 -Wall") set(SRC - "main.cpp" - "rand.cpp" + "../main.cpp" + "../rand.cpp" ) @@ -17,7 +17,7 @@ set(SRC add_link_options(-no-pie) include_directories(include) -include_directories(.) +include_directories(../) find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) diff --git a/tests/regression/user/main.h b/tests/regression/user/main.h deleted file mode 100644 index 7fd73b0..0000000 --- a/tests/regression/user/main.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef MAIN_H -#define MAIN_H - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -using namespace std::chrono; - -const int resX = 800; -const int resY = 1000; - -uint8_t frameId = 0; -double deltas[60]; - -std::unique_ptr jGLInstance; - -std::string fixedLengthNumber(double x, unsigned length) -{ - std::string d = std::to_string(x); - std::string dtrunc(length,' '); - for (unsigned c = 0; c < dtrunc.length(); c++/*ayy lmao*/) - { - - if (c >= d.length()) - { - dtrunc[c] = '0'; - } - else - { - dtrunc[c] = d[c]; - } - } - return dtrunc; -} - -const char * vertexShader = - "#version 330\n" - "precision lowp float;\n" - "in vec4 a_position;\n" - "in vec4 a_offset;\n" - "in vec4 a_colour;\n" - "uniform mat4 proj;\n" - "out vec2 texCoord;\n" - "out vec4 colour;\n" - "void main(void){" - "vec2 pos = a_position.xy*a_offset.w;\n" - "float ct = cos(a_offset.z); float st = sin(a_offset.z);\n" - "mat2 rot = mat2(ct, -st, st, ct);\n" - "pos = rot*pos + a_offset.xy;\n" - "gl_Position = proj*vec4(pos,0.0,1.0);\n" - "texCoord = a_position.zw;\n" - "colour = a_colour;\n" - "}"; - -const char * fragmentShader = - "#version 330\n" - "precision lowp float;\n" - "in vec2 texCoord;\n" - "in vec4 colour;\n" - "out vec4 fragment;\n" - "void main(void){\n" - "vec2 c = texCoord-vec2(0.5,0.5);\n" - "if (dot(c,c) > 0.5*0.5) {discard;}\n" - "fragment = colour;\n" - "}"; - -#endif /* MAIN_H */ diff --git a/tests/regression/user/rand.cpp b/tests/regression/user/rand.cpp deleted file mode 100644 index 8bd4a7e..0000000 --- a/tests/regression/user/rand.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -std::uniform_real_distribution RNG::floatU; -std::random_device RNG::device; -std::mt19937 RNG::engine(device()); diff --git a/tests/regression/user/rand.h b/tests/regression/user/rand.h deleted file mode 100644 index d703110..0000000 --- a/tests/regression/user/rand.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RAND_H -#define RAND_H - -#include - -class RNG -{ - -public: - - float nextFloat(){ return floatU(engine); } - -private: - - static std::uniform_real_distribution floatU; - static std::random_device device; - static std::mt19937 engine; - -}; - -#endif /* RAND_H */ -