fix issue with shader compiler

main
Brett 2024-04-11 00:12:02 -04:00
parent 5ad77763dc
commit 20a8974f9b
4 changed files with 16 additions and 5 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
set(BLT_GRAPHICS_VERSION 0.9.3) set(BLT_GRAPHICS_VERSION 0.9.4)
set(BLT_GRAPHICS_TEST_VERSION 0.0.1) set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})

View File

@ -152,6 +152,7 @@ namespace blt::gfx
static unsigned int createShader(const std::string& source, int type); static unsigned int createShader(const std::string& source, int type);
static std::string loadShader(std::string_view file);
public: public:
/** /**
* Creates a shader * Creates a shader

@ -1 +1 @@
Subproject commit 0ec0548661bbacbe7849b37c4019693dbfb47279 Subproject commit 9db3f120489ff27aa560e488d82b5ae0d64019df

View File

@ -93,6 +93,7 @@ namespace blt::gfx
// loads the shader code for later complication and uploading into the graphics card // loads the shader code for later complication and uploading into the graphics card
// TODO: defines can be added here by sending them as additional strings. No need to edit the source string // TODO: defines can be added here by sending them as additional strings. No need to edit the source string
glShaderSource(shaderID, 1, &shader_code, nullptr); glShaderSource(shaderID, 1, &shader_code, nullptr);
// Compile it // Compile it
glCompileShader(shaderID); glCompileShader(shaderID);
@ -129,8 +130,8 @@ namespace blt::gfx
if (!load_as_string) if (!load_as_string)
{ {
// BLT provides a recursive file loader for glsl shaders. It's pretty much just a recursive function looking for include statements. // BLT provides a recursive file loader for glsl shaders. It's pretty much just a recursive function looking for include statements.
vertex_source = blt::fs::loadShaderFile(vertex); vertex_source = loadShader(vertex);
fragment_source = blt::fs::loadShaderFile(fragment); fragment_source = loadShader(fragment);
} else } else
{ {
vertex_source = removeEmptyFirstLines(vertex_source); vertex_source = removeEmptyFirstLines(vertex_source);
@ -221,6 +222,15 @@ namespace blt::gfx
move.programID = -1; move.programID = -1;
} }
std::string shader_t::loadShader(std::string_view file)
{
auto lines = blt::fs::recursiveInclude(file);
std::string str;
for (const auto& v : lines)
str += v;
return str;
}
shader_base_t& shader_base_t::setBool(const std::string& name, bool value) shader_base_t& shader_base_t::setBool(const std::string& name, bool value)
{ {
if (auto i = getUniformLocation(name)) if (auto i = getUniformLocation(name))