[DEV] update shader IO
This commit is contained in:
parent
9fc1003fbb
commit
961cf3e007
@ -40,7 +40,7 @@ namespace gale {
|
|||||||
void display();
|
void display();
|
||||||
/**
|
/**
|
||||||
* @brief Reload all resources from files, and send there in openGL card if needed.
|
* @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();
|
void reLoadResources();
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,9 @@ void gale::resource::Program::init(const etk::Uri& _uri) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
etk::String tmpData;
|
etk::String tmpData;
|
||||||
|
GALE_DEBUG("===========================================================");
|
||||||
while (fileIO->gets(tmpData) != false) {
|
while (fileIO->gets(tmpData) != false) {
|
||||||
|
GALE_DEBUG("data: " << tmpData);
|
||||||
int32_t len = tmpData.size();
|
int32_t len = tmpData.size();
|
||||||
if( tmpData[len-1] == '\n'
|
if( tmpData[len-1] == '\n'
|
||||||
|| tmpData[len-1] == '\r') {
|
|| tmpData[len-1] == '\r') {
|
||||||
@ -83,6 +85,11 @@ void gale::resource::Program::init(const etk::Uri& _uri) {
|
|||||||
// get it with relative position:
|
// get it with relative position:
|
||||||
etk::Uri tmpUri = _uri;
|
etk::Uri tmpUri = _uri;
|
||||||
tmpUri.setPath(_uri.getPath().getParent() / tmpData);
|
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());
|
ememory::SharedPtr<gale::resource::Shader> tmpShader = gale::resource::Shader::create(tmpUri.get());
|
||||||
if (tmpShader == null) {
|
if (tmpShader == null) {
|
||||||
GALE_ERROR("Error while getting a specific shader filename : " << tmpUri);
|
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);
|
m_shaderList.pushBack(tmpShader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GALE_DEBUG("===========================================================");
|
||||||
// close the file:
|
// close the file:
|
||||||
fileIO->close();
|
fileIO->close();
|
||||||
}
|
}
|
||||||
|
@ -102,11 +102,12 @@ void gale::resource::Shader::removeContextToLate() {
|
|||||||
void gale::resource::Shader::reload() {
|
void gale::resource::Shader::reload() {
|
||||||
ethread::RecursiveLock lock(m_mutex);
|
ethread::RecursiveLock lock(m_mutex);
|
||||||
etk::Uri uri = m_name;
|
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() << "'");
|
GALE_CRITICAL("File does not Exist : '" << uri << "' : path='" << uri.getPath() << "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
etk::uri::readAll(uri, m_fileData);
|
etk::uri::readAll(uri, m_fileData);
|
||||||
|
GALE_VERBOSE("load shader:\n-----------------------------------------------------------------\n" << m_fileData << "\n-----------------------------------------------------------------");
|
||||||
// now change the OGL context ...
|
// now change the OGL context ...
|
||||||
if (gale::openGL::hasContext() == true) {
|
if (gale::openGL::hasContext() == true) {
|
||||||
GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> call update context (direct)");
|
GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> call update context (direct)");
|
||||||
@ -115,8 +116,8 @@ void gale::resource::Shader::reload() {
|
|||||||
} else {
|
} else {
|
||||||
GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> tagged has update context needed");
|
GALE_DEBUG("OGL : load SHADER '" << m_name << "' ==> tagged has update context needed");
|
||||||
// TODO : Check this, this is a leek ==> in the GPU ... really bad ...
|
// TODO : Check this, this is a leek ==> in the GPU ... really bad ...
|
||||||
m_exist = false;
|
m_exist = false;
|
||||||
m_shader = 0;
|
m_shader = 0;
|
||||||
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace appl {
|
|||||||
void onCreate(gale::Context& _context) override {
|
void onCreate(gale::Context& _context) override {
|
||||||
setSize(vec2(800, 600));
|
setSize(vec2(800, 600));
|
||||||
m_angle = 0.0f;
|
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) {
|
if (m_GLprogram != null) {
|
||||||
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
|
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
|
||||||
m_GLColor = m_GLprogram->getAttribute("EW_color");
|
m_GLColor = m_GLprogram->getAttribute("EW_color");
|
||||||
|
Loading…
Reference in New Issue
Block a user