From 961cf3e0072db27300b20c0455fc7529cfaa35ca Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 9 Oct 2018 23:03:07 +0200 Subject: [PATCH] [DEV] update shader IO --- gale/resource/Manager.hpp | 2 +- gale/resource/Program.cpp | 8 ++++++++ gale/resource/Shader.cpp | 7 ++++--- sample/basic.cpp | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gale/resource/Manager.hpp b/gale/resource/Manager.hpp index b6ddd36..9955c18 100644 --- a/gale/resource/Manager.hpp +++ b/gale/resource/Manager.hpp @@ -40,7 +40,7 @@ namespace gale { void display(); /** * @brief Reload all resources from files, and send there in openGL card if needed. - * @note If file is reference at THEME:XXX:filename if the Theme change the file will reload the newOne + * @note If file is reference at THEME_XXX:///filename if the Theme change the file will reload the newOne */ void reLoadResources(); /** diff --git a/gale/resource/Program.cpp b/gale/resource/Program.cpp index 431d23e..242f620 100644 --- a/gale/resource/Program.cpp +++ b/gale/resource/Program.cpp @@ -66,7 +66,9 @@ void gale::resource::Program::init(const etk::Uri& _uri) { return; } etk::String tmpData; + GALE_DEBUG("==========================================================="); while (fileIO->gets(tmpData) != false) { + GALE_DEBUG("data: " << tmpData); int32_t len = tmpData.size(); if( tmpData[len-1] == '\n' || tmpData[len-1] == '\r') { @@ -83,6 +85,11 @@ void gale::resource::Program::init(const etk::Uri& _uri) { // get it with relative position: etk::Uri tmpUri = _uri; tmpUri.setPath(_uri.getPath().getParent() / tmpData); + GALE_VERBOSE("base path: " << _uri); + GALE_VERBOSE("base path: " << _uri.getPath()); + GALE_VERBOSE("base path: " << _uri.getPath().getParent()); + GALE_VERBOSE("new path: " << _uri.getPath().getParent() / tmpData); + GALE_VERBOSE("create shader: " << tmpUri); ememory::SharedPtr tmpShader = gale::resource::Shader::create(tmpUri.get()); if (tmpShader == null) { GALE_ERROR("Error while getting a specific shader filename : " << tmpUri); @@ -91,6 +98,7 @@ void gale::resource::Program::init(const etk::Uri& _uri) { m_shaderList.pushBack(tmpShader); } } + GALE_DEBUG("==========================================================="); // close the file: fileIO->close(); } diff --git a/gale/resource/Shader.cpp b/gale/resource/Shader.cpp index 7db748b..9e02722 100644 --- a/gale/resource/Shader.cpp +++ b/gale/resource/Shader.cpp @@ -102,11 +102,12 @@ void gale::resource::Shader::removeContextToLate() { void gale::resource::Shader::reload() { ethread::RecursiveLock lock(m_mutex); etk::Uri uri = m_name; - if (etk::uri::exist(uri)) { + if (etk::uri::exist(uri) == false) { GALE_CRITICAL("File does not Exist : '" << uri << "' : path='" << uri.getPath() << "'"); return; } etk::uri::readAll(uri, m_fileData); + GALE_VERBOSE("load shader:\n-----------------------------------------------------------------\n" << m_fileData << "\n-----------------------------------------------------------------"); // now change the OGL context ... if (gale::openGL::hasContext() == true) { GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> call update context (direct)"); @@ -115,8 +116,8 @@ void gale::resource::Shader::reload() { } else { GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> tagged has update context needed"); // TODO : Check this, this is a leek ==> in the GPU ... really bad ... - m_exist = false; - m_shader = 0; + m_exist = false; + m_shader = 0; getManager().update(ememory::dynamicPointerCast(sharedFromThis())); } } diff --git a/sample/basic.cpp b/sample/basic.cpp index 17faba8..dd4f1b8 100644 --- a/sample/basic.cpp +++ b/sample/basic.cpp @@ -31,7 +31,7 @@ namespace appl { void onCreate(gale::Context& _context) override { setSize(vec2(800, 600)); m_angle = 0.0f; - m_GLprogram = gale::resource::Program::create("DATA:basic.prog"); + m_GLprogram = gale::resource::Program::create("DATA:///basic.prog"); if (m_GLprogram != null) { m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); m_GLColor = m_GLprogram->getAttribute("EW_color");