reorganize to use .bat files instead of .sh. Move demo to an example project
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,5 +12,6 @@ x64**
|
||||
**.exe
|
||||
.cache**
|
||||
tags
|
||||
bin/*
|
||||
**/bin/**
|
||||
**/obj/**
|
||||
compile_commands.json
|
||||
|
||||
@@ -1 +1 @@
|
||||
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" && bash
|
||||
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
Binary file not shown.
BIN
bin/LivePlotter.lib
(Stored with Git LFS)
BIN
bin/LivePlotter.lib
(Stored with Git LFS)
Binary file not shown.
10
build.bat
Normal file
10
build.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
@ECHO off
|
||||
SET flags=-Od -ZI -MDd
|
||||
IF "%1" == "release" (
|
||||
SET flags=-O2 -MTd
|
||||
)
|
||||
SET srcs=src\*
|
||||
mkdir bin obj
|
||||
cl %srcs% ext\glfw\build\src\Debug\glfw3.lib kernel32.lib user32.lib Gdi32.lib Shell32.lib -I inc -I ext\glm -I ext\glfw\include %flags% -std:c++20 -MP -LD -Fo:obj\\ -Fe:bin\\LivePlotter.dll
|
||||
COPY /Y assets\* bin
|
||||
COPY /Y assets\shaders\* bin
|
||||
22
build.sh
22
build.sh
@@ -1,22 +0,0 @@
|
||||
(
|
||||
cd bin
|
||||
rm *
|
||||
demo_srcs=../src/demo/*.cpp
|
||||
demo_srcs+=" ../src/util.cpp"
|
||||
plotter_srcs=../src/*.cpp
|
||||
glad_src=../src/glad.c
|
||||
glfw_lib=../ext/glfw/build/src/Debug/glfw3.lib
|
||||
if [ $# -eq 1 ] && [ "$1" == "release" ]
|
||||
then
|
||||
dll_flags="-O2 -MTd"
|
||||
exe_flags="-O2 -MT"
|
||||
else
|
||||
dll_flags="-Od -ZI -MDd"
|
||||
exe_flags="-Od -ZI -MD"
|
||||
fi
|
||||
echo $flags
|
||||
cl $plotter_srcs $glad_src $glfw_lib kernel32.lib user32.lib Gdi32.lib Shell32.lib -I ../inc -I ../ext/glm -I ../ext/glfw/include $dll_flags -MP -std:c++20 -LD -FeLivePlotter.dll
|
||||
cp ../src/shaders/* .
|
||||
cp ../assets/* .
|
||||
cl $demo_srcs -I ../inc -I ../ext/glm $exe_flags -MP -std:c++20 -Fedemo.exe
|
||||
)
|
||||
0
examples/demo/activate.bat
Normal file
0
examples/demo/activate.bat
Normal file
12
examples/demo/build.bat
Normal file
12
examples/demo/build.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
SET flags=-Od -ZI -MD
|
||||
IF "%1" == "release" (
|
||||
SET flags=-O2 -MT
|
||||
)
|
||||
SET srcs=src\*
|
||||
mkdir bin obj
|
||||
(
|
||||
PUSHD ..\..
|
||||
CALL build.bat %1
|
||||
POPD
|
||||
COPY /Y ..\..\bin\* bin && cl %srcs% bin\LivePlotter.lib -I ..\..\inc -I ..\..\ext\glm %flags% -std:c++20 -MP -Fo:obj\\ -Fe:bin\\
|
||||
)
|
||||
22
examples/demo/export.bat
Normal file
22
examples/demo/export.bat
Normal file
@@ -0,0 +1,22 @@
|
||||
@ECHO off
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
ECHO [ > compile_commands.json
|
||||
|
||||
FOR /r "src\" %%F IN (*.cpp) DO (
|
||||
|
||||
SET "file=%%F"
|
||||
SET "file=!file:\=/!"
|
||||
SET "directory=%~dp0"
|
||||
SET "directory=!directory:\=/!"
|
||||
|
||||
ECHO { >> compile_commands.json
|
||||
ECHO "directory": "!directory!", >> compile_commands.json
|
||||
ECHO "command": "cl !file! -I inc -I ../../ext/glm -I ../../ext/glfw/include %flags% -std:c++20 -MD -MP -Fo:obj\\ ", >> compile_commands.json
|
||||
|
||||
ECHO "file": "!file!" >> compile_commands.json
|
||||
ECHO }, >> compile_commands.json
|
||||
|
||||
)
|
||||
|
||||
ECHO ] >> compile_commands.json
|
||||
40
examples/demo/src/util.cpp
Normal file
40
examples/demo/src/util.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "util.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool read_file(string* s, const char* filepath) {
|
||||
ifstream file(filepath);
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
}
|
||||
*s = { istreambuf_iterator<char>(file), istreambuf_iterator<char>() };
|
||||
return true;
|
||||
}
|
||||
|
||||
vector<string> split_str(string s, char delim) {
|
||||
vector<string> res;
|
||||
string cur_word;
|
||||
istringstream ss(s);
|
||||
while (getline(ss, cur_word, delim)) {
|
||||
res.push_back(cur_word);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// https://songho.ca/opengl/gl_quaternion.html
|
||||
glm::mat4 quat_to_mat4(glm::quat q) {
|
||||
glm::vec4 col0 = glm::vec4(
|
||||
1 - 2 * q.y * q.y - 2 * q.z * q.z, 2 * q.x * q.y + 2 * q.w * q.z, 2 * q.x * q.z - 2 * q.w * q.y, 0);
|
||||
|
||||
glm::vec4 col1 = glm::vec4(
|
||||
2 * q.x * q.y - 2 * q.w * q.z, 1 - 2 * q.x * q.x - 2 * q.z * q.z, 2 * q.y * q.z + 2 * q.w * q.x, 0);
|
||||
|
||||
glm::vec4 col2 = glm::vec4(
|
||||
2 * q.x * q.z + 2 * q.w * q.y, 2 * q.y * q.z - 2 * q.w * q.x, 1 - 2 * q.x * q.x - 2 * q.y * q.y, 0);
|
||||
|
||||
glm::vec4 col3 = glm::vec4(0, 0, 0, 1);
|
||||
|
||||
return glm::mat4(col0, col1, col2, col3);
|
||||
}
|
||||
|
||||
float randf() { return (float)abs(rand()) / (float)RAND_MAX; }
|
||||
22
export.bat
Normal file
22
export.bat
Normal file
@@ -0,0 +1,22 @@
|
||||
@ECHO off
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
ECHO [ > compile_commands.json
|
||||
|
||||
FOR /r "src\" %%F IN (*.cpp) DO (
|
||||
|
||||
SET "file=%%F"
|
||||
SET "file=!file:\=/!"
|
||||
SET "directory=%~dp0"
|
||||
SET "directory=!directory:\=/!"
|
||||
|
||||
ECHO { >> compile_commands.json
|
||||
ECHO "directory": "!directory!", >> compile_commands.json
|
||||
ECHO "command": "cl !file! -I inc -I ext/glm -I ext/glfw/include %flags% -std:c++20 -MP -LD -Fo:obj\\ ", >> compile_commands.json
|
||||
|
||||
ECHO "file": "!file!" >> compile_commands.json
|
||||
ECHO }, >> compile_commands.json
|
||||
|
||||
)
|
||||
|
||||
ECHO ] >> compile_commands.json
|
||||
@@ -1,5 +0,0 @@
|
||||
srcs=src/*
|
||||
|
||||
echo [ > compile_commands.json
|
||||
find src -iname "*.cpp" -exec sh -c 'echo { \"directory\": \"$(cygpath -m $(pwd))\", \"command\": \"cl "$(cygpath -m {})" -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo\", \"file\": \"$(cygpath -m {})\" }, >> compile_commands.json' \;
|
||||
echo ] >> compile_commands.json
|
||||
@@ -11,9 +11,12 @@
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
bool read_file(std::string* s, const char* filepath);
|
||||
std::vector<std::string> split_str(std::string s, char delim);
|
||||
using namespace std;
|
||||
|
||||
bool read_file(string* s, const char* filepath);
|
||||
vector<string> split_str(string s, char delim);
|
||||
glm::mat4 quat_to_mat4(glm::quat q);
|
||||
float randf();
|
||||
template<class T> T lerp(T start, T end, float t) { return t * end + (1 - t) * start; }
|
||||
template<class T> float ilerp(T start, T end, T pos) { return (pos - start) / (end - start); }
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "util.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Reference in New Issue
Block a user