From b8e833e0f327491bb58067989067553e4376164c Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Thu, 4 Nov 2021 16:00:23 +0000 Subject: [PATCH] Add macOS/Linux files to release & make background color tunable (#115) --- .github/workflows/workflow.yml | 40 +++++++++++++++++++++++++++ README.md | 49 ++++++++++++++++------------------ resolved.bzl | 10 +++---- snap/snapcraft.yaml | 2 +- voidstar/arguments.cc | 1 + voidstar/managers/glfw3.cc | 17 +++++++++--- 6 files changed, 84 insertions(+), 35 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index cebc936..55fd122 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -29,11 +29,27 @@ jobs: - uses: actions/checkout@v2 - run: DOCKER_BUILDKIT=1 docker build -o=./bin/ --target=voidstar . --progress=plain - run: ./bin/voidstar --help + - uses: actions/upload-artifact@v2 + with: + name: voidstar_gcc_ubuntu + path: ./bin/voidstar - uses: Wandalen/wretry.action@v1.0.11 with: command: DOCKER_BUILDKIT=1 docker build -o=. --target=video-gcc . --progress=plain attempt_limit: 20 attempt_delay: 1000 + - run: mv ./bin/voidstar voidstar_gcc_ubuntu + - run: mv ./video.webm voidstar_gcc_ubuntu.webm + - uses: actions/upload-artifact@v2 + with: + name: video-gcc_ubuntu + path: ./voidstar_gcc_ubuntu.webm + - uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + voidstar_gcc_ubuntu + voidstar_gcc_ubuntu.webm build_on_ubuntu_with_clang: name: Build on ubuntu with Clang @@ -46,11 +62,27 @@ jobs: - uses: actions/checkout@v2 - run: DOCKER_BUILDKIT=1 docker build -o=./bin/ --target=voidstar-clang . --progress=plain - run: ./bin/voidstar --help + - uses: actions/upload-artifact@v2 + with: + name: voidstar_clang_ubuntu + path: ./bin/voidstar - uses: Wandalen/wretry.action@v1.0.11 with: command: DOCKER_BUILDKIT=1 docker build -o=. --target=video-clang . --progress=plain attempt_limit: 20 attempt_delay: 1000 + - run: mv ./bin/voidstar voidstar_clang_ubuntu + - run: mv ./video.webm voidstar_clang_ubuntu.webm + - uses: actions/upload-artifact@v2 + with: + name: video-clang_ubuntu + path: ./voidstar_clang_ubuntu.webm + - uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + voidstar_clang_ubuntu + voidstar_clang_ubuntu.webm build_on_macos: name: Build on macos @@ -62,6 +94,14 @@ jobs: - uses: actions/checkout@v2 - run: bazelisk build voidstar - run: ./bazel-bin/voidstar/voidstar --help + - uses: actions/upload-artifact@v2 + with: + name: voidstar_macos-latest + path: ./bazel-bin/voidstar/voidstar + - uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ./bazel-bin/voidstar/voidstar # build_on_windows: FIXME # name: Build on windows diff --git a/README.md b/README.md index 0ef0f77..db934e4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# VoidStar [![Snap Status](https://build.snapcraft.io/badge/fenollp/voidstar.svg)](https://build.snapcraft.io/user/fenollp/voidstar) [Coverity](https://scan.coverity.com/projects/fenollp-voidstar?tab=overview) +# void* Browse data using Corti's 2D projector as well as 3D variants. @@ -27,8 +27,7 @@ The actual file being represented below [is data/BigPictureBG.tga](http://www.do ## Usage ```shell -bazel build voidstar -./bazel-bin/voidstar/voidstar --move bazel-bin/voidstar/voidstar data/* +voidstar --move bazel-bin/voidstar/voidstar data/* ``` ``` @@ -63,49 +62,47 @@ Usage: # Use > to slide faster, < to slow down # SPACE to toggle spinning the shape # Press O to reset the camera position + # Use B to change background color # ESC to quit ``` ## Installing -### docker - -Known to work with -* ubuntu 18.10 + docker 18.09.0 - -``` -docker build -f Dockerfile.dev -t voiddev . -mv your/interesting/files/* data/ -./docker-dev.sh -``` - ### on MacOS -1. Download one of the `osx` files of [the latest release](https://github.com/fenollp/voidstar/releases/latest) -1. Open Terminal.app (you can search for it in Spotlight) +1. Download one of the `macos` files of [the latest release](https://github.com/fenollp/voidstar/releases/latest) +1. Open `Terminal.app` (you can search for it in Spotlight) 1. Type `chmod u+x ` then drag and drop the file you downloaded then press ENTER (now this file can be executed) 1. Now drag and drop your executable then drag a file you want to look at (e.g. `data/dragon.vox`) then press ENTER + * your Terminal command should look like `/Users/you/Downloads/voidstar some_file.xyz` 1. A window should appear. Move your mouse and play with your keyboard's arrows. You should see some colored dots in 3D. -### on any Linux distribution +### Windows -`snap install voidstar` +https://github.com/fenollp/voidstar/issues/2 -This relies on [snaps](https://snapcraft.io/docs/core/install). +### with Docker +```shell +DOCKER_BUILDKIT=1 docker build -o=/usr/local/bin https://github.com/voidstarHQ/voidstar.git +``` -## Requirements +### on any Linux distribution -* A C++ compiler -* `bazel` that you can use through [bazelisk](https://github.com/bazelbuild/bazelisk) +```shell +snap install voidstar +``` -### Windows +This relies on [snaps](https://snapcraft.io/docs/core/install). -https://github.com/fenollp/voidstar/issues/2 -### Debian +## Hacking ```shell -sudo apt-get install mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev xorg-dev +bazel build voidstar +./bazel-bin/voidstar/voidstar --move bazel-bin/voidstar/voidstar data/* ``` + +* A C++ compiler +* `bazel` that you can use through [bazelisk](https://github.com/bazelbuild/bazelisk) diff --git a/resolved.bzl b/resolved.bzl index 269396e..ff5c2bc 100644 --- a/resolved.bzl +++ b/resolved.bzl @@ -385,14 +385,14 @@ resolved = [ "rule_class": "@bazel_upgradable//:rule.bzl%upgradable_repository", "attributes": { "urls": [ - "https://github.com/bazelbuild/rules_cc/archive/f84656686987ce254481cc33efa3b6645d4254c3.tar.gz", - "https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/f84656686987ce254481cc33efa3b6645d4254c3.tar.gz", + "https://github.com/bazelbuild/rules_cc/archive/426f72132372dfbd3a904d283662faba71bdf393.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/426f72132372dfbd3a904d283662faba71bdf393.tar.gz", ], - "sha256": "a30681f34021a77638b07abcea132d0057aa16d81e76444b4c454c29ae59fac0", + "sha256": "e7df2dc809915dda2b5a6d79ed0b9e673af94b7920399ef40ae183623bbff49d", "netrc": "", "auth_patterns": {}, "canonical_id": "", - "strip_prefix": "rules_cc-f84656686987ce254481cc33efa3b6645d4254c3", + "strip_prefix": "rules_cc-426f72132372dfbd3a904d283662faba71bdf393", "type": "tar.gz", "patches": [], "patch_tool": "", @@ -409,7 +409,7 @@ resolved = [ "tag": "", "name": "rules_cc", }, - "output_tree_hash": "400ca6f1331142b6c9922db519cf33d899f9f0c2acd262ac4585d444bf1d0adb", + "output_tree_hash": "bdb911a032f66a3a03b5095825cbb14c6ae41346dc684c910b723556fa8db695", }, ], }, diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 9532dd7..18bf294 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: voidstar -version: v1.35.0 # FIXME: 'git' +version: v1.36.0 # FIXME: 'git' summary: void* casts files onto 2D/3D colored spaces for your mind blowing needs # 79 char long summary description: | Usage: diff --git a/voidstar/arguments.cc b/voidstar/arguments.cc index db8a048..cff52d9 100644 --- a/voidstar/arguments.cc +++ b/voidstar/arguments.cc @@ -39,6 +39,7 @@ static void usage(const char* prgname __unused) { # Use > to slide faster, < to slow down # SPACE to toggle spinning the shape # Press O to reset the camera position + # Use B to change background color # ESC to quit )"; diff --git a/voidstar/managers/glfw3.cc b/voidstar/managers/glfw3.cc index 03dd528..3b70861 100644 --- a/voidstar/managers/glfw3.cc +++ b/voidstar/managers/glfw3.cc @@ -251,14 +251,23 @@ void GLFW3Manager::run() { glfwSetCursorPos(window_, viewport_width_ / 2, viewport_height_ / 2); } + static constexpr float bgColors[][3] = { + {0, 0, 0}, // black + {1, 0, 0}, // R + {0, 1, 0}, // G + {0, 0, 1}, // B + {0.2f, 0.3f, 0.3f}, // gray + {1, 1, 1}, // white + }; + size_t bgi = 0; + double lastTime = glfwGetTime(); while (!glfwWindowShouldClose(window_)) { // process pending events events_->update(); // Clear the colorbuffer - glClearColor(0, 0, 0, 1); - // glClearColor(0.2f, 0.3f, 0.3f, 1.0f); + glClearColor(bgColors[bgi][0], bgColors[bgi][1], bgColors[bgi][2], 1); if (is3D) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } else { @@ -290,10 +299,12 @@ void GLFW3Manager::run() { if (is3D) glfwSetCursorPos(window_, viewport_width_ / 2, viewport_height_ / 2); if (events_->keyPressed(GLFW_KEY_ESCAPE)) - glfwSetWindowShouldClose(window_, GL_TRUE); + glfwSetWindowShouldClose(window_, GLFW_TRUE); if (events_->keyPressed('F')) ToggleFullscreen(); if (events_->keyPressed('H')) loadPrevFile(); if (events_->keyPressed('L')) loadNextFile(); + if (events_->keyPressed('B')) + bgi = (bgi + 1) % (sizeof(bgColors) / sizeof(bgColors[0])); if (!args_->move_window && args_->exit_at_fin) glfwSetWindowShouldClose(window_, GLFW_TRUE); }