Skip to content

Commit

Permalink
Simple installation script and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
CHrlS98 committed Jul 28, 2021
1 parent 61b8803 commit ae4455e
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
[bB]uild
third/vcpkg
*.jpg
*.ini
*.ini
.cache-install
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
set(CMAKE_GENERATOR "Unix Makefiles")
set(CMAKE_TOOLCHAIN_FILE ./third/vcpkg-export-20210512-131839/scripts/buildsystems/vcpkg.cmake)

#========== Global Configurations =============#
#----------------------------------------------#
cmake_minimum_required(VERSION 3.11)
project(stunningsuccotash)
project(rtfodfslicer)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)

Expand Down
2 changes: 2 additions & 0 deletions Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ target_link_libraries(rtfodfslicer PRIVATE IMGUI)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

add_compile_definitions(RTFODFSLICER_SHADERS_DIR="${CMAKE_CURRENT_BINARY_DIR}/shaders")

add_custom_command(TARGET rtfodfslicer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:rtfodfslicer>/shaders
Expand Down
23 changes: 17 additions & 6 deletions Engine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <timer.h>
#include <gui.h>

#ifndef RTFODFSLICER_SHADERS_DIR
#error "RTFODFSLICER_SHADERS_DIR PREPROCESSOR DEFINITION NOT FOUND."
#endif

namespace
{
const int DEFAULT_SPHERE_RESOLUTION = 25;
Expand All @@ -31,6 +35,7 @@ struct CLArgs
std::string absWorkingDir = "";
std::string imagePath = "";
int sphereRes = DEFAULT_SPHERE_RESOLUTION;
bool success = true;
};

State::Mouse mouseState;
Expand Down Expand Up @@ -122,7 +127,7 @@ int main(const CLArgs& args)
const int height = 600;
const float aspectRatio = static_cast<float>(width) / static_cast<float>(height);

GLFWwindow* window = glfwCreateWindow(width, height, "stunning-succotash", NULL, NULL);
GLFWwindow* window = glfwCreateWindow(width, height, "RTfODF Slicer", NULL, NULL);
glfwMakeContextCurrent(window);
glfwSetWindowUserPointer(window, NULL);

Expand All @@ -141,16 +146,16 @@ int main(const CLArgs& args)
}

// vertex+fragment shaders
const std::string absPathVS = args.absWorkingDir + "shaders/triangle.vert";
const std::string absPathFS = args.absWorkingDir + "shaders/triangle.frag";
const std::string absPathVS = std::string(RTFODFSLICER_SHADERS_DIR) + "/triangle.vert";
const std::string absPathFS = std::string(RTFODFSLICER_SHADERS_DIR) + "/triangle.frag";

std::vector<Scene::ShaderProgram> shaders;
shaders.push_back(Scene::ShaderProgram(absPathVS, GL_VERTEX_SHADER));
shaders.push_back(Scene::ShaderProgram(absPathFS, GL_FRAGMENT_SHADER));
Scene::ProgramPipeline programPipeline(shaders);

// compute shader
std::string absPathCS = args.absWorkingDir + "shaders/compute.glsl";
std::string absPathCS = std::string(RTFODFSLICER_SHADERS_DIR) + "/compute.glsl";
Scene::ShaderProgram computeShader(absPathCS, GL_COMPUTE_SHADER);

// load our image
Expand Down Expand Up @@ -224,11 +229,13 @@ int main(const CLArgs& args)

Engine::CLArgs parseArguments(int argc, char** argv)
{
Engine::CLArgs args;
if(argc < 2)
{
throw std::runtime_error("Missing required argument: imagePath.");
std::cout << "Missing mandatory argument: [imagePath]" << std::endl;
args.success = false;
return args;
}
Engine::CLArgs args;
args.absWorkingDir = extractPath(argv[0]);
args.imagePath = argv[1];
if(argc > 2)
Expand All @@ -241,5 +248,9 @@ Engine::CLArgs parseArguments(int argc, char** argv)
int main(int argc, char** argv)
{
Engine::CLArgs args = parseArguments(argc, argv);
if(!args.success)
{
return -1;
}
return Engine::main(args);
}
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
# RTfODFSlicer
# RTfODF Slicer
A real-time fiber ODF slicing application for Linux using `OpenGL 4.6`.

## Installation

`Cmake` minimum version 3.11 is required for installing the application.
`Cmake` minimum version 3.11 is required for installing the application. The generator used by default is `GNU Make`. Make sure you have `git` installed; it is used for fetching the [`nifticlib` library](https://github.com/NIFTI-Imaging/nifti_clib).

To build the project using `GNU Make`:

### Quick installation
The program can be installed by running:
```
./install.sh
```
The above script creates the build directory, runs `Cmake` and `make` and add the executable path the system `PATH`.

### Step-by-step installation
Alternatively, the program can be built by running:
```
mkdir build
cd build
cmake ..
make
```

To run the executable:
The executable file will be in the folder `${project_root}/build/Engine`.

Then you can add the path to the directory containing the executable to your `.bashrc` configuration to make it available system-wide.

```
./build/Engine/rtfodfslicer path/to/image.nii.gz
export PATH='${absolute_path_to_project}/build/Engine':$PATH
```

If you experience problems with the installation, make sure you have `git` installed; it is used for fetching the [`nifticlib`](https://github.com/NIFTI-Imaging/nifti_clib) library.
## Running the application
To run the executable:
```
rtfodfslicer path/to/image.nii.gz
```
27 changes: 27 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

script="$(readlink -f "${BASH_SOURCE[0]}")"
project_dir="$(dirname "$script")"

if [ -d "$project_dir/build" ]
then
echo "Build directory $project_dir/build already exists."
else
echo "Creating build directory $project_dir/build."
mkdir "$project_dir/build"
fi

cd "$project_dir/build" || exit
cmake ..
make

if [ -e "$project_dir/.cache-install" ]
then
echo "Skipping path update. Delete .cache-install file and rerun to update."
else
echo "Updating path..."
echo "export PATH='$project_dir/build/Engine':\$PATH" >> ~/.bashrc
source ~/.bashrc
touch "$project_dir/.cache-install"
fi
echo "Done!"

0 comments on commit ae4455e

Please sign in to comment.