Kaynağa Gözat

- removed commented code from main.cpp that is not useful anymore
~ changed how g_Time is calculated so any shader that uses it should behave properly
~ changed how the uniforms are set to a reinterpret_cast instead of static_cast to perform a direct pointer conversion (safe as we know the types were actually those types)

Signed-off-by: Alexis Maiquez <almamu@almamu.com>

Alexis Maiquez 5 yıl önce
ebeveyn
işleme
9d7d344b80

+ 2 - 78
main.cpp

@@ -230,8 +230,6 @@ int main (int argc, char* argv[])
     auto sceneInformation = project->getWallpaper ()->as <WallpaperEngine::Core::CScene> ();
     FloatColor clearColor = sceneInformation->getClearColor ();
 
-    glClearColor (clearColor.r, clearColor.g, clearColor.b, clearColor.a);
-
     // enable depth text
     glEnable (GL_DEPTH_TEST);
     glDepthFunc (GL_LESS);
@@ -246,7 +244,7 @@ int main (int argc, char* argv[])
     while (glfwWindowShouldClose (window) == 0)
     {
         // calculate the current time value
-        g_Time += static_cast <float> (endTime - startTime) / CLOCKS_PER_SEC;
+        g_Time = (float) glfwGetTime ();
         // get the start time of the frame
         startTime = clock ();
 
@@ -255,6 +253,7 @@ int main (int argc, char* argv[])
         // ensure we render over the whole screen
         glViewport (0, 0, 1920, 1080);
 
+        glClearColor (clearColor.r, clearColor.g, clearColor.b, clearColor.a);
         // clear window
         glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -279,79 +278,4 @@ int main (int argc, char* argv[])
     SDL_Quit ();
 
     return 0;
-/*
-    try
-    {
-        IrrlichtContext = new WallpaperEngine::Irrlicht::CContext (screens, isRootWindow);
-        IrrlichtContext->initializeContext ();
-    }
-    catch (std::runtime_error& ex)
-    {
-        std::cerr << ex.what () << std::endl;
-
-        return 1;
-    }
-
-    path = stringPathFixes (path);
-
-    irr::io::path wallpaper_path = IrrlichtContext->getDevice ()->getFileSystem ()->getAbsolutePath (path.c_str ());
-    irr::io::path project_path = wallpaper_path + "project.json";
-
-    if (mode == RUN_MODE_PACKAGE)
-    {
-        irr::io::path scene_path = wallpaper_path + "scene.pkg";
-        // add the package file to the lookup list
-        IrrlichtContext->getDevice ()->getFileSystem ()->addFileArchive (scene_path, true, false);
-    }
-    else if (mode == RUN_MODE_DIRECTORY)
-    {
-        project_path = wallpaper_path + "project.json";
-        // set the working directory to the project folder
-        IrrlichtContext->getDevice ()->getFileSystem ()->changeWorkingDirectoryTo (wallpaper_path);
-    }
-
-    WallpaperEngine::Core::CProject* project = WallpaperEngine::Core::CProject::fromFile (project_path);
-    WallpaperEngine::Render::CWallpaper* wallpaper;
-
-    if (project->getType () == "scene")
-    {
-        WallpaperEngine::Core::CScene* scene = project->getWallpaper ()->as <WallpaperEngine::Core::CScene> ();
-        wallpaper = new WallpaperEngine::Render::CScene (scene, IrrlichtContext);
-        IrrlichtContext->getDevice ()->getSceneManager ()->setAmbientLight (
-                    scene->getAmbientColor ().toSColor ()
-        );
-    }
-    else if (project->getType () == "video")
-    {
-        wallpaper = new WallpaperEngine::Render::CVideo (
-                    project->getWallpaper ()->as <WallpaperEngine::Core::CVideo> (),
-                    IrrlichtContext
-        );
-    }
-    else
-    {
-        throw std::runtime_error ("Unsupported wallpaper type");
-    }
-    
-    uint32_t minimumTime = 1000 / maximumFPS;
-    uint32_t startTime = 0;
-    uint32_t endTime = 0;
-
-    while (IrrlichtContext && IrrlichtContext->getDevice () && IrrlichtContext->getDevice ()->run ())
-    {
-        if (IrrlichtContext->getDevice ()->getVideoDriver () == nullptr)
-            continue;
-
-        startTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();
-        g_Time = startTime / 1000.0f;
-
-        IrrlichtContext->renderFrame (wallpaper);
-
-        endTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();
-
-        IrrlichtContext->getDevice ()->sleep (minimumTime - (endTime - startTime), false);
-    }
-
-    SDL_Quit ();
-    return 0;*/
 }

+ 0 - 3
src/WallpaperEngine/Render/Objects/CImage.cpp

@@ -177,9 +177,6 @@ void CImage::render ()
     // now render the last pass (to screen)
     glBindBuffer (GL_ARRAY_BUFFER, *this->m_material->getImage ()->getVertexBuffer ());
     glDrawArrays (GL_TRIANGLES, 0, 6);*/
-
-    // flush stdout
-    std::cout << std::flush;
 }
 
 /*

+ 10 - 10
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -58,17 +58,17 @@ void CPass::render (GLuint drawTo, GLuint input)
     if (this->m_pass->getBlendingMode () == "translucent")
     {
         glEnable (GL_BLEND);
-        glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+        glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     }
     else if (this->m_pass->getBlendingMode () == "additive")
     {
         glEnable (GL_BLEND);
-        glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
+        glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
     }
     else if (this->m_pass->getBlendingMode () == "normal")
     {
         glEnable (GL_BLEND);
-        glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
+        glBlendFuncSeparate (GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
     }
     else
     {
@@ -128,25 +128,25 @@ void CPass::render (GLuint drawTo, GLuint input)
             switch ((*cur)->type)
             {
                 case Double:
-                    glUniform1d ((*cur)->id, *static_cast <const double*> ((*cur)->value));
+                    glUniform1d ((*cur)->id, *reinterpret_cast <const double*> ((*cur)->value));
                     break;
                 case Float:
-                    glUniform1f ((*cur)->id, *static_cast <const float*> ((*cur)->value));
+                    glUniform1f ((*cur)->id, *reinterpret_cast <const float*> ((*cur)->value));
                     break;
                 case Integer:
-                    glUniform1i ((*cur)->id, *static_cast <const int*> ((*cur)->value));
+                    glUniform1i ((*cur)->id, *reinterpret_cast <const int*> ((*cur)->value));
                     break;
                 case Vector4:
-                    glUniform4fv ((*cur)->id, 1, glm::value_ptr (*static_cast <const glm::vec4*> ((*cur)->value)));
+                    glUniform4fv ((*cur)->id, 1, glm::value_ptr (*reinterpret_cast <const glm::vec4*> ((*cur)->value)));
                     break;
                 case Vector3:
-                    glUniform3fv ((*cur)->id, 1, glm::value_ptr (*static_cast <const glm::vec3*> ((*cur)->value)));
+                    glUniform3fv ((*cur)->id, 1, glm::value_ptr (*reinterpret_cast <const glm::vec3*> ((*cur)->value)));
                     break;
                 case Vector2:
-                    glUniform2fv ((*cur)->id, 1, glm::value_ptr (*static_cast <const glm::vec2*> ((*cur)->value)));
+                    glUniform2fv ((*cur)->id, 1, glm::value_ptr (*reinterpret_cast <const glm::vec2*> ((*cur)->value)));
                     break;
                 case Matrix4:
-                    glUniformMatrix4fv ((*cur)->id, 1, GL_FALSE, glm::value_ptr (*static_cast <const glm::mat4*> ((*cur)->value)));
+                    glUniformMatrix4fv ((*cur)->id, 1, GL_FALSE, glm::value_ptr (*reinterpret_cast <const glm::mat4*> ((*cur)->value)));
                     break;
             }
         }