Compare commits

..

No commits in common. "bf44e7d7f09f51a125daf394b464c37b3e90367a" and "b66610cc26c1584041059f6b5ae75b99280f1d65" have entirely different histories.

15 changed files with 63 additions and 167 deletions

View File

@ -33,7 +33,7 @@ class DynamicValue {
explicit DynamicValue(float value); explicit DynamicValue(float value);
explicit DynamicValue(int value); explicit DynamicValue(int value);
explicit DynamicValue(bool value); explicit DynamicValue(bool value);
virtual ~DynamicValue (); ~DynamicValue ();
[[nodiscard]] const glm::ivec4& getIVec4 () const; [[nodiscard]] const glm::ivec4& getIVec4 () const;
[[nodiscard]] const glm::ivec3& getIVec3 () const; [[nodiscard]] const glm::ivec3& getIVec3 () const;

View File

@ -29,7 +29,6 @@ struct EffectPass {
/** The target this material renders to (if specified) */ /** The target this material renders to (if specified) */
std::optional <std::string> target; std::optional <std::string> target;
}; };
struct Effect { struct Effect {
/** Effect's name for the UI */ /** Effect's name for the UI */
std::string name; std::string name;

View File

@ -8,42 +8,16 @@
#include "Types.h" #include "Types.h"
namespace WallpaperEngine::Data::Model { namespace WallpaperEngine::Data::Model {
enum BlendingMode {
BlendingMode_Unknown = 0,
BlendingMode_Normal = 1,
BlendingMode_Translucent = 2,
BlendingMode_Additive = 3,
};
enum CullingMode {
CullingMode_Unknown = 0,
CullingMode_Normal = 1,
CullingMode_Disable = 2
};
enum DepthtestMode {
DepthtestMode_Unknown = 0,
DepthtestMode_Disabled = 1,
DepthtestMode_Enabled = 2,
};
enum DepthwriteMode {
DepthwriteMode_Unknown = 0,
DepthwriteMode_Disabled = 1,
DepthwriteMode_Enabled = 2,
};
struct MaterialPass { struct MaterialPass {
// TODO: WRITE ENUMS FOR THESE // TODO: WRITE ENUMS FOR THESE
/** Blending mode */ /** Blending mode */
BlendingMode blending; std::string blending;
/** Culling mode */ /** Culling mode */
CullingMode cullmode; std::string cullmode;
/** Depth test mode */ /** Depth test mode */
DepthtestMode depthtest; std::string depthtest;
/** Depth write mode */ /** Depth write mode */
DepthwriteMode depthwrite; std::string depthwrite;
/** Shader file to use for this pass */ /** Shader file to use for this pass */
std::string shader; std::string shader;
/** List of textures defined for this pass */ /** List of textures defined for this pass */

View File

@ -7,14 +7,13 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include "Types.h" #include "Types.h"
#include "UserSetting.h" #include "Effect.h"
#include "Material.h" #include "Material.h"
#include "Model.h" #include "Model.h"
#include "Effect.h"
#include "WallpaperEngine/Data/Utils/TypeCaster.h" #include "WallpaperEngine/Data/Utils/TypeCaster.h"
namespace WallpaperEngine::Data::Model { namespace WallpaperEngine::Data::Model {
using namespace WallpaperEngine::Data::Utils; using TypeCaster = WallpaperEngine::Data::Utils::TypeCaster;
struct ObjectData { struct ObjectData {
int id; int id;
@ -49,7 +48,7 @@ struct ImageEffectPassOverride {
int id; int id;
ComboMap combos; ComboMap combos;
ShaderConstantMap constants; ShaderConstantMap constants;
TextureMap textures; std::map <int, std::string> textures;
}; };
/** /**

View File

@ -10,6 +10,7 @@ namespace WallpaperEngine::Data::Model {
* Represents a wallpaper engine project * Represents a wallpaper engine project
*/ */
struct Project { struct Project {
public:
enum Type { enum Type {
Type_Scene = 0, Type_Scene = 0,
Type_Web = 1, Type_Web = 1,

View File

@ -60,7 +60,7 @@ class PropertyBoolean : public Property {
class PropertyColor : public Property { class PropertyColor : public Property {
public: public:
explicit PropertyColor (PropertyData data, std::string value) : Property (std::move(data)) { explicit PropertyColor (PropertyData data, std::string value) : Property (std::move(data)) {
this->PropertyColor::update (value); this->update (value);
} }
using Property::update; using Property::update;
@ -113,7 +113,7 @@ class PropertyColor : public Property {
class PropertyCombo : public Property, ComboData { class PropertyCombo : public Property, ComboData {
public: public:
PropertyCombo (PropertyData data, ComboData comboData, std::string value) : Property (std::move(data)), ComboData (std::move(comboData)) { PropertyCombo (PropertyData data, ComboData comboData, std::string value) : Property (std::move(data)), ComboData (std::move(comboData)) {
this->PropertyCombo::update (value); this->update (value);
} }
using Property::update; using Property::update;
@ -139,7 +139,7 @@ class PropertyText : public Property {
class PropertySceneTexture : public Property { class PropertySceneTexture : public Property {
public: public:
explicit PropertySceneTexture (PropertyData data, std::string value) : Property (std::move(data)) { explicit PropertySceneTexture (PropertyData data, std::string value) : Property (std::move(data)) {
this->PropertySceneTexture::update (value); this->update (value);
} }
void update(const std::string& value) override { void update(const std::string& value) override {

View File

@ -14,7 +14,7 @@ class Wallpaper;
class Scene; class Scene;
class Web; class Web;
class Video; class Video;
struct UserSetting; class UserSetting;
class Object; class Object;
class Sound; class Sound;
class Image; class Image;

View File

@ -8,11 +8,12 @@
namespace WallpaperEngine::Data::Model { namespace WallpaperEngine::Data::Model {
struct ConditionInfo { struct ConditionInfo {
public:
std::string name; std::string name;
std::string condition; std::string condition;
}; };
struct UserSetting { struct UserSetting {
public:
/** /**
* The value of this setting, can be a few different things: * The value of this setting, can be a few different things:
* - a value connected to the property * - a value connected to the property

View File

@ -8,9 +8,11 @@
#include "Types.h" #include "Types.h"
#include "Object.h" #include "Object.h"
#include "WallpaperEngine/Data/Utils/TypeCaster.h" #include "WallpaperEngine/Data/Utils/TypeCaster.h"
#include "WallpaperEngine/Data/JSON.h"
namespace WallpaperEngine::Data::Model { namespace WallpaperEngine::Data::Model {
using namespace WallpaperEngine::Data::Utils; using json = WallpaperEngine::Data::JSON::JSON;
using TypeCaster = WallpaperEngine::Data::Utils::TypeCaster;
struct WallpaperData { struct WallpaperData {
std::string filename; std::string filename;
@ -108,8 +110,10 @@ struct SceneData {
class Scene : public Wallpaper, public SceneData { class Scene : public Wallpaper, public SceneData {
public: public:
explicit Scene (WallpaperData data, SceneData sceneData) noexcept : Wallpaper (std::move (data)), SceneData (std::move (sceneData)) {} explicit Scene (WallpaperData data, SceneData sceneData) noexcept : SceneData (std::move(sceneData)), Wallpaper (data) {}
~Scene () override = default; ~Scene () override = default;
// TODO: ADD OBJECTS HERE
}; };
} // namespace WallpaperEngine::Data::Model } // namespace WallpaperEngine::Data::Model

View File

@ -41,10 +41,10 @@ MaterialPassUniquePtr MaterialParser::parsePass (const JSON& it, Project& projec
return std::make_unique <MaterialPass>(MaterialPass { return std::make_unique <MaterialPass>(MaterialPass {
//TODO: REMOVE THIS UGLY STD::STRING CREATION //TODO: REMOVE THIS UGLY STD::STRING CREATION
.blending = parseBlendMode (it.optional ("blending", std::string ("normal"))), .blending = it.optional ("blending", std::string ("normal")),
.cullmode = parseCullMode (it.optional ("cullmode", std::string ("nocull"))), .cullmode = it.optional ("cullmode", std::string ("disabled")),
.depthtest = parseDepthtestMode (it.optional ("depthtest", std::string ("disabled"))), .depthtest = it.optional ("depthtest", std::string ("disabled")),
.depthwrite = parseDepthwriteMode (it.optional ("depthwrite", std::string ("disabled"))), .depthwrite = it.optional ("depthwrite", std::string ("disabled")),
.shader = it.require <std::string> ("shader", "Material pass must have a shader"), .shader = it.require <std::string> ("shader", "Material pass must have a shader"),
.textures = textures.has_value () ? parseTextures (*textures) : TextureMap {}, .textures = textures.has_value () ? parseTextures (*textures) : TextureMap {},
.usertextures = usertextures.has_value () ? parseTextures (*usertextures) : TextureMap {}, .usertextures = usertextures.has_value () ? parseTextures (*usertextures) : TextureMap {},
@ -90,59 +90,3 @@ std::map <std::string, int> MaterialParser::parseCombos (const JSON& it) {
return result; return result;
} }
BlendingMode MaterialParser::parseBlendMode (const std::string& mode) {
if (mode == "normal") {
return BlendingMode_Normal;
}
if (mode == "additive") {
return BlendingMode_Additive;
}
if (mode == "translucent") {
return BlendingMode_Translucent;
}
sLog.error ("Unknown blending mode: ", mode, " defaulting to normal");
return BlendingMode_Normal;
}
CullingMode MaterialParser::parseCullMode (const std::string& mode) {
if (mode == "nocull") {
return CullingMode_Disable;
}
if (mode == "normal") {
return CullingMode_Normal;
}
sLog.error ("Unknown culling mode: ", mode, " defaulting to nocull");
return CullingMode_Disable;
}
DepthtestMode MaterialParser::parseDepthtestMode (const std::string& mode) {
if (mode == "disabled") {
return DepthtestMode_Disabled;
}
if (mode == "enabled") {
return DepthtestMode_Enabled;
}
sLog.error ("Unknown depthtest mode: ", mode, " defaulting to disabled");
return DepthtestMode_Disabled;
}
DepthwriteMode MaterialParser::parseDepthwriteMode (const std::string& mode) {
if (mode == "disabled") {
return DepthwriteMode_Disabled;
}
if (mode == "enabled") {
return DepthwriteMode_Enabled;
}
sLog.error ("Unknown depthwrite mode: ", mode, " defaulting to disabled");
return DepthwriteMode_Disabled;
}

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "WallpaperEngine/Data/JSON.h" #include "WallpaperEngine/Data/JSON.h"
#include "WallpaperEngine/Data/Model/Material.h"
#include "WallpaperEngine/Data/Model/Types.h" #include "WallpaperEngine/Data/Model/Types.h"
namespace WallpaperEngine::Data::Parsers { namespace WallpaperEngine::Data::Parsers {
@ -16,9 +15,5 @@ class MaterialParser {
static MaterialPassUniquePtr parsePass (const JSON& it, Project& project); static MaterialPassUniquePtr parsePass (const JSON& it, Project& project);
static std::map <int, std::string> parseTextures (const JSON& it); static std::map <int, std::string> parseTextures (const JSON& it);
static std::map <std::string, int> parseCombos (const JSON& it); static std::map <std::string, int> parseCombos (const JSON& it);
static BlendingMode parseBlendMode (const std::string& mode);
static CullingMode parseCullMode (const std::string& mode);
static DepthtestMode parseDepthtestMode (const std::string& mode);
static DepthwriteMode parseDepthwriteMode (const std::string& mode);
}; };
} // namespace WallpaperEngine::Data::Parsers } // namespace WallpaperEngine::Data::Parsers

View File

@ -294,10 +294,10 @@ void CImage::setup () {
} }
const auto virtualPass = MaterialPass { const auto virtualPass = MaterialPass {
.blending = BlendingMode_Normal, .blending = "normal",
.cullmode = CullingMode_Disable, .cullmode = "nocull",
.depthtest = DepthtestMode_Disabled, .depthtest = "disabled",
.depthwrite = DepthwriteMode_Disabled, .depthwrite = "disabled",
.shader = "commands/copy", .shader = "commands/copy",
.textures = { .textures = {
{0, *(*curEffect)->source} {0, *(*curEffect)->source}
@ -363,7 +363,7 @@ void CImage::setup () {
const auto last = this->m_passes.rbegin (); const auto last = this->m_passes.rbegin ();
(*last)->setBlendingMode ((*first)->getBlendingMode ()); (*last)->setBlendingMode ((*first)->getBlendingMode ());
(*first)->setBlendingMode (BlendingMode_Normal); (*first)->setBlendingMode ("normal");
} }
// calculate full animation time (if any) // calculate full animation time (if any)

View File

@ -89,55 +89,36 @@ void CPass::setupRenderFramebuffer () {
glViewport (0, 0, this->m_drawTo->getRealWidth (), this->m_drawTo->getRealHeight ()); glViewport (0, 0, this->m_drawTo->getRealWidth (), this->m_drawTo->getRealHeight ());
// set texture blending // set texture blending
switch (this->getBlendingMode ()) { if (this->getBlendingMode () == "translucent") {
case BlendingMode_Translucent:
glEnable (GL_BLEND); 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);
break; } else if (this->getBlendingMode () == "additive") {
case BlendingMode_Additive:
glEnable (GL_BLEND); 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);
break; } else if (this->getBlendingMode () == "normal") {
case BlendingMode_Normal:
glEnable (GL_BLEND); glEnable (GL_BLEND);
glBlendFuncSeparate (GL_ONE, GL_ZERO, GL_ONE, GL_ZERO); glBlendFuncSeparate (GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
break; } else {
default:
glDisable (GL_BLEND); glDisable (GL_BLEND);
break;
} }
switch (this->m_pass.depthtest) { // set depth testing
case DepthtestMode_Enabled: if (this->m_pass.depthtest == "disabled") {
glEnable (GL_DEPTH_TEST);
break;
case DepthtestMode_Disabled:
default:
glDisable (GL_DEPTH_TEST); glDisable (GL_DEPTH_TEST);
break; } else {
glEnable (GL_DEPTH_TEST);
} }
switch (this->m_pass.cullmode) { if (this->m_pass.cullmode == "nocull") {
case CullingMode_Normal:
glEnable (GL_CULL_FACE);
break;
case CullingMode_Disable:
default:
glDisable (GL_CULL_FACE); glDisable (GL_CULL_FACE);
break; } else {
glEnable (GL_CULL_FACE);
} }
switch (this->m_pass.depthwrite) { if (this->m_pass.depthwrite == "disabled") {
case DepthwriteMode_Enabled:
glDepthMask (true);
break;
case DepthwriteMode_Disabled:
default:
glDepthMask (false); glDepthMask (false);
break; } else {
glDepthMask (true);
} }
} }
@ -341,11 +322,11 @@ void CPass::setViewProjectionMatrix (const glm::mat4* viewProjection) {
this->m_viewProjectionMatrix = viewProjection; this->m_viewProjectionMatrix = viewProjection;
} }
void CPass::setBlendingMode (BlendingMode blendingmode) { void CPass::setBlendingMode (std::string blendingmode) {
this->m_blendingmode = blendingmode; this->m_blendingmode = std::move(blendingmode);
} }
BlendingMode CPass::getBlendingMode () const { const std::string& CPass::getBlendingMode () const {
return this->m_blendingmode; return this->m_blendingmode;
} }

View File

@ -3,7 +3,6 @@
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include <utility> #include <utility>
#include "WallpaperEngine/Data/Model/Material.h"
#include "WallpaperEngine/Assets/ITexture.h" #include "WallpaperEngine/Assets/ITexture.h"
#include "WallpaperEngine/Render/CFBO.h" #include "WallpaperEngine/Render/CFBO.h"
#include "WallpaperEngine/Render/CFBOProvider.h" #include "WallpaperEngine/Render/CFBOProvider.h"
@ -38,8 +37,8 @@ class CPass final : public Helpers::CContextAware {
void setModelViewProjectionMatrixInverse (const glm::mat4* projection); void setModelViewProjectionMatrixInverse (const glm::mat4* projection);
void setModelMatrix (const glm::mat4* model); void setModelMatrix (const glm::mat4* model);
void setViewProjectionMatrix (const glm::mat4* viewProjection); void setViewProjectionMatrix (const glm::mat4* viewProjection);
void setBlendingMode (BlendingMode blendingmode); void setBlendingMode (std::string blendingmode);
[[nodiscard]] BlendingMode getBlendingMode () const; [[nodiscard]] const std::string& getBlendingMode () const;
[[nodiscard]] std::shared_ptr<const CFBO> resolveFBO (const std::string& name) const; [[nodiscard]] std::shared_ptr<const CFBO> resolveFBO (const std::string& name) const;
[[nodiscard]] std::shared_ptr<const CFBOProvider> getFBOProvider () const; [[nodiscard]] std::shared_ptr<const CFBOProvider> getFBOProvider () const;
@ -164,7 +163,7 @@ class CPass final : public Helpers::CContextAware {
std::vector<AttribEntry*> m_attribs = {}; std::vector<AttribEntry*> m_attribs = {};
std::map<std::string, UniformEntry*> m_uniforms = {}; std::map<std::string, UniformEntry*> m_uniforms = {};
std::map<std::string, ReferenceUniformEntry*> m_referenceUniforms = {}; std::map<std::string, ReferenceUniformEntry*> m_referenceUniforms = {};
BlendingMode m_blendingmode = BlendingMode_Normal; std::string m_blendingmode = "";
const glm::mat4* m_modelViewProjectionMatrix; const glm::mat4* m_modelViewProjectionMatrix;
const glm::mat4* m_modelViewProjectionMatrixInverse; const glm::mat4* m_modelViewProjectionMatrixInverse;
const glm::mat4* m_modelMatrix; const glm::mat4* m_modelMatrix;

View File

@ -17,7 +17,6 @@ using namespace WallpaperEngine::Render;
using namespace WallpaperEngine::Data::Model; using namespace WallpaperEngine::Data::Model;
using namespace WallpaperEngine::Data::Parsers; using namespace WallpaperEngine::Data::Parsers;
using namespace WallpaperEngine::Render::Wallpapers; using namespace WallpaperEngine::Render::Wallpapers;
using JSON = WallpaperEngine::Data::JSON::JSON;
CScene::CScene ( CScene::CScene (
const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext, const Wallpaper& wallpaper, CRenderContext& context, CAudioContext& audioContext,
@ -89,7 +88,7 @@ CScene::CScene (
const auto bloomOrigin = glm::vec3 { sceneWidth / 2, sceneHeight / 2, 0.0f }; const auto bloomOrigin = glm::vec3 { sceneWidth / 2, sceneHeight / 2, 0.0f };
const auto bloomSize = glm::vec2 { sceneWidth, sceneHeight }; const auto bloomSize = glm::vec2 { sceneWidth, sceneHeight };
const JSON bloom = { const nlohmann::json bloom = {
{"image", "models/wpenginelinux.json"}, {"image", "models/wpenginelinux.json"},
{"name", "bloomimagewpenginelinux"}, {"name", "bloomimagewpenginelinux"},
{"visible", true}, {"visible", true},
@ -99,14 +98,14 @@ CScene::CScene (
{"size", std::to_string (bloomSize.x) + " " + std::to_string (bloomSize.y)}, {"size", std::to_string (bloomSize.x) + " " + std::to_string (bloomSize.y)},
{"id", -1}, {"id", -1},
{"effects", {"effects",
JSON::array ( json::array (
{ {
{ {
{"file", "effects/wpenginelinux/bloomeffect.json"}, {"file", "effects/wpenginelinux/bloomeffect.json"},
{"id", 15242000}, {"id", 15242000},
{"name", ""}, {"name", ""},
{"passes", {"passes",
JSON::array ( json::array (
{ {
{ {
{"constantshadervalues", {"constantshadervalues",