cursed code
parent
f996da35f4
commit
1b69fd3932
|
@ -287,7 +287,5 @@
|
|||
<option name="/Default/CodeStyle/CppIncludeDirective/SortIncludeDirectives/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CppIncludeDirective/UseAngleBracketsInsteadOfQuotes/@EntryValue" value="WhenPossible" type="string" />
|
||||
<option name="/Default/CodeStyle/CppIncludeDirective/UseRelativePaths/@EntryValue" value="Never" type="string" />
|
||||
<option name="/Default/CodeStyle/Generate/=CppDefinitions/@KeyIndexDefined" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Generate/=CppDefinitions/Options/=GenerateInlineDefinitions/@EntryIndexedValue" value="False" type="string" />
|
||||
</component>
|
||||
</project>
|
|
@ -2,26 +2,6 @@
|
|||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug-addrsan/_deps/freetype-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug-addrsan/_deps/freetype-src/subprojects/dlg" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug-addrsan/_deps/glfw3-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug-addrsan/_deps/imgui-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/freetype-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/freetype-src/subprojects/dlg" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/glfw3-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/imgui-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/freetype-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/freetype-src/subprojects/dlg" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/glfw3-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/imgui-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo-addrsan/_deps/freetype-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo-addrsan/_deps/freetype-src/subprojects/dlg" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo-addrsan/_deps/glfw3-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo-addrsan/_deps/imgui-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/freetype-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/freetype-src/subprojects/dlg" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/glfw3-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/imgui-src" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/lib/blt-with-graphics" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/lib/blt-with-graphics/libraries/BLT" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/lib/blt-with-graphics/libraries/BLT/libraries/parallel-hashmap" vcs="Git" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(gpu-particles VERSION 0.0.17)
|
||||
project(gpu-particles VERSION 0.0.18)
|
||||
|
||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||
|
@ -12,6 +12,53 @@ add_subdirectory(lib/blt-with-graphics)
|
|||
include_directories(include/)
|
||||
file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||
|
||||
function(embed_file_as_raw_string INPUT OUTPUT NAMESPACE VAR_NAME)
|
||||
file(READ "${INPUT}" CONTENTS)
|
||||
file(WRITE "${OUTPUT}" "// Generated from ${INPUT}\n")
|
||||
file(APPEND "${OUTPUT}" "#pragma once\n\n")
|
||||
file(APPEND "${OUTPUT}" "namespace ${NAMESPACE} {\n\n")
|
||||
file(APPEND "${OUTPUT}" "static constexpr char ${VAR_NAME}_str[] = R\"(\"${CONTENTS}\")\";\n\n}")
|
||||
endfunction()
|
||||
|
||||
function(embed_directory INPUT_DIR)
|
||||
# Get the name of the directory the user is trying to embed
|
||||
get_filename_component(parent_name "${INPUT_DIR}" NAME)
|
||||
# make sure directory uses forward slashes
|
||||
file(TO_CMAKE_PATH "${INPUT_DIR}" INPUT_DIR)
|
||||
set(OUTPUT_DIR "${CMAKE_BINARY_DIR}/embedded/${parent_name}")
|
||||
# find all directories within the user folder relative to the input directory
|
||||
file(GLOB_RECURSE INPUT_FILES RELATIVE "${INPUT_DIR}" "${INPUT_DIR}/*")
|
||||
|
||||
foreach(REL_PATH IN LISTS INPUT_FILES)
|
||||
set(ABS_INPUT_PATH "${INPUT_DIR}/${REL_PATH}")
|
||||
set(OUTPUT_HEADER "${OUTPUT_DIR}/${REL_PATH}.h")
|
||||
|
||||
get_filename_component(OUTPUT_HEADER_DIR "${OUTPUT_HEADER}" DIRECTORY)
|
||||
file(MAKE_DIRECTORY "${OUTPUT_HEADER_DIR}")
|
||||
|
||||
# Get the name, extension and relative directory of the input path + file
|
||||
get_filename_component(VAR_NAME "${REL_PATH}" NAME_WE)
|
||||
get_filename_component(VAR_EXT "${REL_PATH}" EXT)
|
||||
get_filename_component(VAR_DIR "${parent_name}/${REL_PATH}" DIRECTORY)
|
||||
set(FILE_PATH "${VAR_NAME}_${VAR_EXT}")
|
||||
# replace non-alphanum chars with "_" for the variable
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9]" "_" FILE_PATH "${FILE_PATH}")
|
||||
string(REGEX REPLACE "__+" "_" FILE_PATH "${FILE_PATH}")
|
||||
|
||||
# replace non-alphanum chars with : for the namespace
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9]" "::" VAR_DIR ${VAR_DIR})
|
||||
string(REGEX REPLACE ":::+" "::" VAR_DIR ${VAR_DIR})
|
||||
|
||||
message(STATUS "Converting file '${REL_PATH}' into variable '${VAR_NAME}' with namespace '${VAR_DIR}'")
|
||||
|
||||
embed_file_as_raw_string("${ABS_INPUT_PATH}" "${OUTPUT_HEADER}" "${VAR_DIR}" "${FILE_PATH}")
|
||||
endforeach()
|
||||
|
||||
include_directories("${CMAKE_BINARY_DIR}/embedded")
|
||||
endfunction()
|
||||
|
||||
embed_directory("${CMAKE_SOURCE_DIR}/shaders")
|
||||
|
||||
add_executable(gpu-particles ${PROJECT_BUILD_FILES})
|
||||
|
||||
target_compile_options(gpu-particles PRIVATE -Wall -Wextra -Wpedantic -Wno-comment)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1808af68b55e6bbcbc8ce82dcccbe12c21a7b38a
|
||||
Subproject commit dd3a242b4110552f9a9b9252d9abd28093e66d22
|
|
@ -1,6 +1,3 @@
|
|||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
const std::string shader_particle_2d_frag = R"("
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
|
@ -19,7 +16,4 @@ void main()
|
|||
FragColor = texture(tex1, vec2(x, y));
|
||||
else
|
||||
FragColor = texture(tex2, vec2(x, y));
|
||||
}
|
||||
|
||||
")";
|
||||
#endif
|
||||
}
|
|
@ -1,6 +1,3 @@
|
|||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
const std::string shader_particle_2d_vert = R"("
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
|
@ -24,7 +21,4 @@ void main()
|
|||
else
|
||||
silly = 0.0f;
|
||||
gl_Position = ovm * vec4(position.x, position.y, 0.0, 1.0);
|
||||
}
|
||||
|
||||
")";
|
||||
#endif
|
||||
}
|
|
@ -19,8 +19,8 @@
|
|||
#include <blt/gfx/vbo.h>
|
||||
#include <blt/gfx/window.h>
|
||||
#include <blt/std/random.h>
|
||||
#include <shaders/particle.frag>
|
||||
#include <shaders/particle.vert>
|
||||
#include <shaders/particle.frag.h>
|
||||
#include <shaders/particle.vert.h>
|
||||
#include "blt/gfx/renderer/batch_2d_renderer.h"
|
||||
#include "blt/gfx/renderer/camera.h"
|
||||
#include "blt/gfx/renderer/resource_manager.h"
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
alive_particles.push_back(i);
|
||||
}
|
||||
|
||||
particle_shader = std::unique_ptr<shader_t>(shader_t::make(shader_particle_2d_vert, shader_particle_2d_frag));
|
||||
particle_shader = std::unique_ptr<shader_t>(shader_t::make(shaders::particle_vert_str, shaders::particle_frag_str));
|
||||
|
||||
unique_vbo_t particle_vbo(GL_ARRAY_BUFFER);
|
||||
particle_vbo.bind().upload(sizeof(particle_t) * particles.size(), particles.data(), GL_DYNAMIC_DRAW);
|
||||
|
|
Loading…
Reference in New Issue