~ changed priority of assets loading, so background's assets should be loaded before looking into the assets folder

~ hopefully fixed effects that use shader targets so they now display properly

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2021-09-29 01:21:35 +02:00
parent f5e943b0fc
commit f86eba347c
5 changed files with 18 additions and 15 deletions

View File

@ -148,8 +148,6 @@ int main (int argc, char* argv[])
std::string project_path = path + "project.json"; std::string project_path = path + "project.json";
auto containers = new WallpaperEngine::Assets::CCombinedContainer (); auto containers = new WallpaperEngine::Assets::CCombinedContainer ();
// add containers to the list
containers->add (new WallpaperEngine::Assets::CDirectory ("./assets/"));
// the background's path is required to load project.json regardless of the type of background we're using // the background's path is required to load project.json regardless of the type of background we're using
containers->add (new WallpaperEngine::Assets::CDirectory (path)); containers->add (new WallpaperEngine::Assets::CDirectory (path));
// check if scene.pkg exists and add it to the list // check if scene.pkg exists and add it to the list
@ -164,6 +162,8 @@ int main (int argc, char* argv[])
{ {
// ignore the exception, this is to be expected of normal backgrounds // ignore the exception, this is to be expected of normal backgrounds
} }
// add containers to the list
containers->add (new WallpaperEngine::Assets::CDirectory ("./assets/"));
// parse the project.json file // parse the project.json file
auto project = WallpaperEngine::Core::CProject::fromFile ("project.json", containers); auto project = WallpaperEngine::Core::CProject::fromFile ("project.json", containers);

View File

@ -115,12 +115,12 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
memcpy (this->m_texCoordList, data2, sizeof (data2)); memcpy (this->m_texCoordList, data2, sizeof (data2));
GLfloat data3 [] = { GLfloat data3 [] = {
0.0f, 0.0f, -1.0f, -1.0f, 0.0f,
1.0f, 0.0f, 1.0f, -1.0f, 0.0f,
0.0f, 1.0f, -1.0f, 1.0f, 0.0f,
0.0f, 1.0f, -1.0f, 1.0f, 0.0f,
1.0f, 0.0f, 1.0f, -1.0f, 0.0f,
1.0f, 1.0f 1.0f, 1.0f, 0.0f,
}; };
memcpy (this->m_passTexCoordList, data3, sizeof (data3)); memcpy (this->m_passTexCoordList, data3, sizeof (data3));
@ -183,7 +183,7 @@ void CImage::simpleRender ()
auto end = this->m_material->getPasses ().end (); auto end = this->m_material->getPasses ().end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
(*cur)->render (this->getScene ()->getFBO (), this->getTexture ()); (*cur)->render (this->getScene ()->getFBO (), this->getTexture (), false);
} }
void CImage::complexRender () void CImage::complexRender ()
@ -197,7 +197,7 @@ void CImage::complexRender ()
auto end = this->m_material->getPasses ().end (); auto end = this->m_material->getPasses ().end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
(*cur)->render (drawTo, asInput); (*cur)->render (drawTo, asInput, false);
// render all the other materials // render all the other materials
auto effectCur = this->getEffects ().begin (); auto effectCur = this->getEffects ().begin ();
@ -232,7 +232,7 @@ void CImage::complexRender ()
if ((*materialCur)->getMaterial ()->hasTarget () == false) if ((*materialCur)->getMaterial ()->hasTarget () == false)
this->pinpongFramebuffer (&drawTo, &asInput); this->pinpongFramebuffer (&drawTo, &asInput);
(*passCur)->render (drawTo, asInput); (*passCur)->render (drawTo, asInput, (*materialCur)->getMaterial ()->hasTarget ());
} }
} }
} }
@ -251,7 +251,7 @@ void CImage::complexRender ()
glColorMask (true, true, true, false); glColorMask (true, true, true, false);
for (; cur != end; cur ++) for (; cur != end; cur ++)
(*cur)->render (this->getScene ()->getFBO (), asInput); (*cur)->render (this->getScene ()->getFBO (), asInput, false);
} }
void CImage::render () void CImage::render ()

View File

@ -62,7 +62,7 @@ namespace WallpaperEngine::Render::Objects
GLfloat m_vertexList [6 * 3]; GLfloat m_vertexList [6 * 3];
GLfloat m_passesVertexList [6 * 3]; GLfloat m_passesVertexList [6 * 3];
GLfloat m_texCoordList [6 * 2]; GLfloat m_texCoordList [6 * 2];
GLfloat m_passTexCoordList [6 * 2]; GLfloat m_passTexCoordList [6 * 3];
GLuint m_vertexBuffer; GLuint m_vertexBuffer;
GLuint m_passesVertexBuffer; GLuint m_passesVertexBuffer;
GLuint m_texCoordBuffer; GLuint m_texCoordBuffer;

View File

@ -64,7 +64,7 @@ ITexture* CPass::resolveTexture (ITexture* expected, int index, ITexture* previo
return fbo; return fbo;
} }
void CPass::render (CFBO* drawTo, ITexture* input) void CPass::render (CFBO* drawTo, ITexture* input, bool hasTarget)
{ {
// set the framebuffer we're drawing to // set the framebuffer we're drawing to
glBindFramebuffer (GL_FRAMEBUFFER, drawTo->getFramebuffer ()); glBindFramebuffer (GL_FRAMEBUFFER, drawTo->getFramebuffer ());
@ -133,6 +133,9 @@ void CPass::render (CFBO* drawTo, ITexture* input)
this->a_TexCoord = *this->m_material->getImage ()->getTexCoordBuffer (); this->a_TexCoord = *this->m_material->getImage ()->getTexCoordBuffer ();
this->a_Position = *this->m_material->getImage ()->getVertexBuffer (); this->a_Position = *this->m_material->getImage ()->getVertexBuffer ();
if (hasTarget)
this->a_Position = *this->m_material->getImage ()->getPassTexCoordBuffer ();
// use the shader we have registered // use the shader we have registered
glUseProgram (this->m_programID); glUseProgram (this->m_programID);

View File

@ -21,7 +21,7 @@ namespace WallpaperEngine::Render::Objects::Effects
public: public:
CPass (CMaterial* material, Core::Objects::Images::Materials::CPass* pass); CPass (CMaterial* material, Core::Objects::Images::Materials::CPass* pass);
void render (CFBO* drawTo, ITexture* input); void render (CFBO* drawTo, ITexture* input, bool hasTarget);
private: private:
enum UniformType enum UniformType