[DEV] update shader IO

This commit is contained in:
Edouard DUPIN 2018-10-09 23:03:07 +02:00
parent 9fc1003fbb
commit 961cf3e007
4 changed files with 14 additions and 5 deletions

View File

@ -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();
/**

View File

@ -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<gale::resource::Shader> 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();
}

View File

@ -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<gale::Resource>(sharedFromThis()));
}
}

View File

@ -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");