mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
More code cleanups
Update .clang-format Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
48a91ff297
commit
732c60da46
161
.clang-format
161
.clang-format
@ -1,34 +1,21 @@
|
|||||||
---
|
# Generated from CLion C/C++ Code Style settings
|
||||||
Language: Cpp
|
BasedOnStyle: LLVM
|
||||||
# BasedOnStyle: Microsoft
|
|
||||||
AccessModifierOffset: -4
|
AccessModifierOffset: -4
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
AlignArrayOfStructures: None
|
|
||||||
AlignConsecutiveMacros: None
|
|
||||||
AlignConsecutiveAssignments: None
|
AlignConsecutiveAssignments: None
|
||||||
AlignConsecutiveBitFields: None
|
|
||||||
AlignConsecutiveDeclarations: None
|
|
||||||
AlignEscapedNewlines: Right
|
|
||||||
AlignOperands: Align
|
AlignOperands: Align
|
||||||
AlignTrailingComments: true
|
AllowAllArgumentsOnNextLine: false
|
||||||
AllowAllArgumentsOnNextLine: true
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
AllowAllConstructorInitializersOnNextLine: true
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
AllowShortBlocksOnASingleLine: Always
|
||||||
AllowShortEnumsOnASingleLine: false
|
|
||||||
AllowShortBlocksOnASingleLine: Empty
|
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
AllowShortLambdasOnASingleLine: All
|
AllowShortLambdasOnASingleLine: All
|
||||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
AllowShortLoopsOnASingleLine: false
|
||||||
AllowShortLoopsOnASingleLine: true
|
|
||||||
AlwaysBreakAfterDefinitionReturnType: None
|
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
AlwaysBreakTemplateDeclarations: MultiLine
|
BreakBeforeBraces: Custom
|
||||||
AttributeMacros:
|
|
||||||
- __capability
|
|
||||||
BinPackArguments: false
|
|
||||||
BinPackParameters: false
|
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
AfterCaseLabel: false
|
AfterCaseLabel: false
|
||||||
AfterClass: true
|
AfterClass: true
|
||||||
@ -36,144 +23,44 @@ BraceWrapping:
|
|||||||
AfterEnum: true
|
AfterEnum: true
|
||||||
AfterFunction: true
|
AfterFunction: true
|
||||||
AfterNamespace: true
|
AfterNamespace: true
|
||||||
AfterObjCDeclaration: true
|
AfterUnion: true
|
||||||
AfterStruct: true
|
|
||||||
AfterUnion: false
|
|
||||||
AfterExternBlock: true
|
|
||||||
BeforeCatch: true
|
BeforeCatch: true
|
||||||
BeforeElse: true
|
BeforeElse: true
|
||||||
BeforeLambdaBody: false
|
|
||||||
BeforeWhile: false
|
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
SplitEmptyFunction: true
|
SplitEmptyFunction: false
|
||||||
SplitEmptyRecord: true
|
SplitEmptyRecord: true
|
||||||
SplitEmptyNamespace: true
|
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeConceptDeclarations: true
|
|
||||||
BreakBeforeBraces: Allman
|
|
||||||
BreakBeforeInheritanceComma: false
|
|
||||||
BreakInheritanceList: BeforeColon
|
|
||||||
BreakBeforeTernaryOperators: true
|
BreakBeforeTernaryOperators: true
|
||||||
BreakConstructorInitializersBeforeComma: false
|
BreakConstructorInitializers: BeforeColon
|
||||||
BreakConstructorInitializers: AfterColon
|
BreakInheritanceList: BeforeColon
|
||||||
PackConstructorInitializers: Never
|
ColumnLimit: 0
|
||||||
BreakAfterJavaFieldAnnotations: false
|
|
||||||
BreakStringLiterals: true
|
|
||||||
ColumnLimit: 120
|
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
|
||||||
CompactNamespaces: false
|
CompactNamespaces: false
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
ContinuationIndentWidth: 8
|
||||||
ConstructorInitializerIndentWidth: 4
|
|
||||||
ContinuationIndentWidth: 4
|
|
||||||
Cpp11BracedListStyle: true
|
|
||||||
DeriveLineEnding: true
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
DisableFormat: false
|
|
||||||
EmptyLineAfterAccessModifier: Never
|
|
||||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
|
||||||
ExperimentalAutoDetectBinPacking: false
|
|
||||||
FixNamespaceComments: true
|
|
||||||
ForEachMacros:
|
|
||||||
- foreach
|
|
||||||
- Q_FOREACH
|
|
||||||
- BOOST_FOREACH
|
|
||||||
IfMacros:
|
|
||||||
- KJ_IF_MAYBE
|
|
||||||
IncludeBlocks: Preserve
|
|
||||||
IncludeCategories:
|
|
||||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
|
||||||
Priority: 2
|
|
||||||
SortPriority: 0
|
|
||||||
CaseSensitive: false
|
|
||||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
|
||||||
Priority: 3
|
|
||||||
SortPriority: 0
|
|
||||||
CaseSensitive: false
|
|
||||||
- Regex: '.*'
|
|
||||||
Priority: 1
|
|
||||||
SortPriority: 0
|
|
||||||
CaseSensitive: false
|
|
||||||
IncludeIsMainRegex: '(Test)?$'
|
|
||||||
IncludeIsMainSourceRegex: ''
|
|
||||||
IndentAccessModifiers: false
|
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentCaseBlocks: true
|
|
||||||
IndentGotoLabels: true
|
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentExternBlock: AfterExternBlock
|
|
||||||
IndentRequires: false
|
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
IndentWrappedFunctionNames: false
|
|
||||||
InsertTrailingCommas: None
|
|
||||||
JavaScriptQuotes: Leave
|
|
||||||
JavaScriptWrapImports: true
|
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
LambdaBodyIndentation: Signature
|
MaxEmptyLinesToKeep: 2
|
||||||
MacroBlockBegin: ''
|
|
||||||
MacroBlockEnd: ''
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
NamespaceIndentation: All
|
NamespaceIndentation: All
|
||||||
ObjCBinPackProtocolList: Auto
|
|
||||||
ObjCBlockIndentWidth: 2
|
|
||||||
ObjCBreakBeforeNestedBlockParam: true
|
|
||||||
ObjCSpaceAfterProperty: false
|
ObjCSpaceAfterProperty: false
|
||||||
ObjCSpaceBeforeProtocolList: true
|
ObjCSpaceBeforeProtocolList: true
|
||||||
PenaltyBreakAssignment: 2
|
|
||||||
PenaltyBreakBeforeFirstCallParameter: 19
|
|
||||||
PenaltyBreakComment: 300
|
|
||||||
PenaltyBreakFirstLessLess: 120
|
|
||||||
PenaltyBreakString: 1000
|
|
||||||
PenaltyBreakTemplateDeclaration: 10
|
|
||||||
PenaltyExcessCharacter: 1000000
|
|
||||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
|
||||||
PenaltyIndentedWhitespace: 0
|
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
PPIndentWidth: -1
|
ReflowComments: false
|
||||||
ReferenceAlignment: Pointer
|
|
||||||
ReflowComments: true
|
|
||||||
ShortNamespaceLines: 1
|
|
||||||
SortIncludes: CaseSensitive
|
|
||||||
SortJavaStaticImport: Before
|
|
||||||
SortUsingDeclarations: true
|
|
||||||
SpaceAfterCStyleCast: true
|
SpaceAfterCStyleCast: true
|
||||||
SpaceAfterLogicalNot: false
|
SpaceAfterLogicalNot: false
|
||||||
SpaceAfterTemplateKeyword: true
|
SpaceAfterTemplateKeyword: true
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
SpaceBeforeCaseColon: false
|
SpaceBeforeCpp11BracedList: true
|
||||||
SpaceBeforeCpp11BracedList: false
|
|
||||||
SpaceBeforeCtorInitializerColon: true
|
SpaceBeforeCtorInitializerColon: true
|
||||||
SpaceBeforeInheritanceColon: true
|
SpaceBeforeInheritanceColon: true
|
||||||
SpaceBeforeParens: Always
|
SpaceBeforeParens: Always
|
||||||
SpaceAroundPointerQualifiers: Default
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
SpaceInEmptyBlock: false
|
|
||||||
SpaceInEmptyParentheses: false
|
SpaceInEmptyParentheses: false
|
||||||
SpacesBeforeTrailingComments: 1
|
SpacesBeforeTrailingComments: 0
|
||||||
SpacesInAngles: Never
|
SpacesInAngles: false
|
||||||
SpacesInConditionalStatement: false
|
|
||||||
SpacesInContainerLiterals: true
|
|
||||||
SpacesInCStyleCastParentheses: false
|
SpacesInCStyleCastParentheses: false
|
||||||
SpacesInLineCommentPrefix:
|
SpacesInContainerLiterals: false
|
||||||
Minimum: 1
|
|
||||||
Maximum: -1
|
|
||||||
SpacesInParentheses: false
|
SpacesInParentheses: false
|
||||||
SpacesInSquareBrackets: false
|
SpacesInSquareBrackets: false
|
||||||
SpaceBeforeSquareBrackets: true
|
|
||||||
BitFieldColonSpacing: Both
|
|
||||||
Standard: Latest
|
|
||||||
StatementAttributeLikeMacros:
|
|
||||||
- Q_EMIT
|
|
||||||
StatementMacros:
|
|
||||||
- Q_UNUSED
|
|
||||||
- QT_REQUIRE_VERSION
|
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
UseCRLF: false
|
UseTab: ForContinuationAndIndentation
|
||||||
UseTab: Never
|
|
||||||
WhitespaceSensitiveMacros:
|
|
||||||
- STRINGIZE
|
|
||||||
- PP_STRINGIZE
|
|
||||||
- BOOST_PP_STRINGIZE
|
|
||||||
- NS_SWIFT_NAME
|
|
||||||
- CF_SWIFT_NAME
|
|
||||||
...
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ std::filesystem::path detectHomepath ()
|
|||||||
|
|
||||||
std::filesystem::path path = home;
|
std::filesystem::path path = home;
|
||||||
|
|
||||||
if (std::filesystem::is_directory (path) == false)
|
if (!std::filesystem::is_directory (path))
|
||||||
sLog.exception ("Cannot find home directory for current user, ", home, " is not a directory");
|
sLog.exception ("Cannot find home directory for current user, ", home, " is not a directory");
|
||||||
|
|
||||||
return home;
|
return home;
|
||||||
@ -41,7 +41,7 @@ std::filesystem::path Steam::FileSystem::workshopDirectory (int appID, const std
|
|||||||
{
|
{
|
||||||
auto currentpath = std::filesystem::path (homepath) / *current / std::to_string (appID) / contentID;
|
auto currentpath = std::filesystem::path (homepath) / *current / std::to_string (appID) / contentID;
|
||||||
|
|
||||||
if (std::filesystem::exists (currentpath) == false || std::filesystem::is_directory (currentpath) == false)
|
if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return currentpath;
|
return currentpath;
|
||||||
@ -58,7 +58,7 @@ std::filesystem::path Steam::FileSystem::appDirectory (const std::string& appDir
|
|||||||
{
|
{
|
||||||
auto currentpath = std::filesystem::path (homepath) / *current / appDirectory / path;
|
auto currentpath = std::filesystem::path (homepath) / *current / appDirectory / path;
|
||||||
|
|
||||||
if (std::filesystem::exists (currentpath) == false || std::filesystem::is_directory (currentpath) == false)
|
if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return currentpath;
|
return currentpath;
|
||||||
|
@ -14,23 +14,23 @@
|
|||||||
using namespace WallpaperEngine::Application;
|
using namespace WallpaperEngine::Application;
|
||||||
|
|
||||||
struct option long_options [] = {
|
struct option long_options [] = {
|
||||||
{"screen-root", required_argument, 0, 'r'},
|
{"screen-root", required_argument, nullptr, 'r'},
|
||||||
{"pkg", required_argument, 0, 'p'},
|
{"pkg", required_argument, nullptr, 'p'},
|
||||||
{"dir", required_argument, 0, 'd'},
|
{"dir", required_argument, nullptr, 'd'},
|
||||||
{"silent", no_argument, 0, 's'},
|
{"silent", no_argument, nullptr, 's'},
|
||||||
{"volume", required_argument, 0, 'v'},
|
{"volume", required_argument, nullptr, 'v'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"fps", required_argument, 0, 'f'},
|
{"fps", required_argument, nullptr, 'f'},
|
||||||
{"assets-dir", required_argument, 0, 'a'},
|
{"assets-dir", required_argument, nullptr, 'a'},
|
||||||
{"screenshot", required_argument, 0, 'c'},
|
{"screenshot", required_argument, nullptr, 'c'},
|
||||||
{"list-properties", no_argument, 0, 'l'},
|
{"list-properties", no_argument, nullptr, 'l'},
|
||||||
{"set-property", required_argument, 0, 'o'},
|
{"set-property", required_argument, nullptr, 'o'},
|
||||||
{nullptr, 0, 0, 0}
|
{nullptr, 0, nullptr, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string stringPathFixes(const std::string& s)
|
std::string stringPathFixes(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s.empty () == true)
|
if (s.empty ())
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
std::string str (s);
|
std::string str (s);
|
||||||
@ -49,7 +49,8 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
maximumFPS (30),
|
maximumFPS (30),
|
||||||
audioVolume (128),
|
audioVolume (128),
|
||||||
audioEnabled (true),
|
audioEnabled (true),
|
||||||
onlyListProperties (false)
|
onlyListProperties (false),
|
||||||
|
screenshotFormat (FIF_UNKNOWN)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
maximumFPS = atoi (optarg);
|
maximumFPS = strtol (optarg, nullptr, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -104,17 +105,20 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
this->audioVolume = glm::clamp (atoi (optarg), 0, 128);
|
this->audioVolume = glm::clamp ((int) strtol (optarg, nullptr, 0), 0, 128);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
this->takeScreenshot = true;
|
this->takeScreenshot = true;
|
||||||
this->screenshot = stringPathFixes (optarg);
|
this->screenshot = stringPathFixes (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->background.empty () == true)
|
if (this->background.empty ())
|
||||||
{
|
{
|
||||||
if (optind < argc && strlen (argv [optind]) > 0)
|
if (optind < argc && strlen (argv [optind]) > 0)
|
||||||
{
|
{
|
||||||
@ -122,7 +126,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->printHelp (argv [0]);
|
CApplicationContext::printHelp (argv [0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +146,7 @@ void CApplicationContext::validatePath ()
|
|||||||
|
|
||||||
void CApplicationContext::validateAssets ()
|
void CApplicationContext::validateAssets ()
|
||||||
{
|
{
|
||||||
if (this->assets.empty () == false)
|
if (!this->assets.empty ())
|
||||||
{
|
{
|
||||||
sLog.out ("Using wallpaper engine's assets at ", this->assets, " based on --assets-dir parameter");
|
sLog.out ("Using wallpaper engine's assets at ", this->assets, " based on --assets-dir parameter");
|
||||||
return;
|
return;
|
||||||
@ -162,10 +166,10 @@ void CApplicationContext::validateAssets ()
|
|||||||
|
|
||||||
void CApplicationContext::validateScreenshot ()
|
void CApplicationContext::validateScreenshot ()
|
||||||
{
|
{
|
||||||
if (this->takeScreenshot == false)
|
if (!this->takeScreenshot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this->screenshot.has_extension () == false)
|
if (!this->screenshot.has_extension ())
|
||||||
sLog.exception ("Cannot determine screenshot format");
|
sLog.exception ("Cannot determine screenshot format");
|
||||||
|
|
||||||
std::string extension = this->screenshot.extension ();
|
std::string extension = this->screenshot.extension ();
|
||||||
|
@ -29,6 +29,6 @@ namespace WallpaperEngine::Application
|
|||||||
void validatePath ();
|
void validatePath ();
|
||||||
void validateAssets ();
|
void validateAssets ();
|
||||||
void validateScreenshot ();
|
void validateScreenshot ();
|
||||||
void printHelp (const char* route);
|
static void printHelp (const char* route);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -139,7 +139,7 @@ void CWallpaperApplication::loadProject ()
|
|||||||
this->m_project = CProject::fromFile ("project.json", this->m_vfs);
|
this->m_project = CProject::fromFile ("project.json", this->m_vfs);
|
||||||
// go to the right folder so the videos will play
|
// go to the right folder so the videos will play
|
||||||
// TODO: stop doing chdir and use full path
|
// TODO: stop doing chdir and use full path
|
||||||
if (this->m_project->getWallpaper ()->is <WallpaperEngine::Core::CVideo> () == true)
|
if (this->m_project->getWallpaper ()->is <WallpaperEngine::Core::CVideo> ())
|
||||||
chdir (this->m_context.background.c_str ());
|
chdir (this->m_context.background.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ void CWallpaperApplication::show ()
|
|||||||
|
|
||||||
float startTime, endTime, minimumTime = 1.0f / this->m_context.maximumFPS;
|
float startTime, endTime, minimumTime = 1.0f / this->m_context.maximumFPS;
|
||||||
|
|
||||||
while (videoDriver.closeRequested () == false && g_KeepRunning == true)
|
while (!videoDriver.closeRequested () && g_KeepRunning)
|
||||||
{
|
{
|
||||||
// update input information
|
// update input information
|
||||||
inputContext.update ();
|
inputContext.update ();
|
||||||
@ -248,7 +248,7 @@ void CWallpaperApplication::show ()
|
|||||||
if ((endTime - startTime) < minimumTime)
|
if ((endTime - startTime) < minimumTime)
|
||||||
usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC);
|
usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC);
|
||||||
|
|
||||||
if (this->m_context.takeScreenshot == true && videoDriver.getFrameCounter () == 5)
|
if (this->m_context.takeScreenshot && videoDriver.getFrameCounter () == 5)
|
||||||
{
|
{
|
||||||
this->takeScreenshot (context.getWallpaper (), this->m_context.screenshot, this->m_context.screenshotFormat);
|
this->takeScreenshot (context.getWallpaper (), this->m_context.screenshot, this->m_context.screenshotFormat);
|
||||||
// disable screenshot just in case the counter overflows
|
// disable screenshot just in case the counter overflows
|
||||||
|
@ -14,4 +14,4 @@ namespace WallpaperEngine::Assets
|
|||||||
private:
|
private:
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
};
|
};
|
||||||
};
|
}
|
@ -6,6 +6,12 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Assets;
|
using namespace WallpaperEngine::Assets;
|
||||||
|
|
||||||
|
CCombinedContainer::CCombinedContainer () :
|
||||||
|
CContainer (),
|
||||||
|
m_containers ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void CCombinedContainer::add (CContainer* container)
|
void CCombinedContainer::add (CContainer* container)
|
||||||
{
|
{
|
||||||
this->m_containers.emplace_back (container);
|
this->m_containers.emplace_back (container);
|
||||||
|
@ -11,6 +11,8 @@ namespace WallpaperEngine::Assets
|
|||||||
class CCombinedContainer : public CContainer
|
class CCombinedContainer : public CContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CCombinedContainer ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a container to the list
|
* Adds a container to the list
|
||||||
*
|
*
|
||||||
@ -19,7 +21,7 @@ namespace WallpaperEngine::Assets
|
|||||||
void add (CContainer* container);
|
void add (CContainer* container);
|
||||||
void addPkg (const std::filesystem::path& path);
|
void addPkg (const std::filesystem::path& path);
|
||||||
|
|
||||||
const void* readFile (std::string filename, uint32_t* length) const override;
|
const void* readFile (std::string filename, uint32_t* length = nullptr) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<CContainer*> m_containers;
|
std::vector<CContainer*> m_containers;
|
||||||
|
@ -15,8 +15,9 @@ const ITexture* CContainer::readTexture (std::string filename) const
|
|||||||
|
|
||||||
ITexture* result = new CTexture (textureContents);
|
ITexture* result = new CTexture (textureContents);
|
||||||
|
|
||||||
if (DEBUG)
|
#if DEBUG
|
||||||
glObjectLabel (GL_TEXTURE, result->getTextureID (), -1, filename.c_str ());
|
glObjectLabel (GL_TEXTURE, result->getTextureID (), -1, filename.c_str ());
|
||||||
|
#endif /* DEBUG */
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace WallpaperEngine::Assets
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
const virtual void* readFile (std::string filename, uint32_t* length = nullptr) const = 0;
|
virtual const void* readFile (std::string filename, uint32_t* length = nullptr) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for readFile, appends the texture extension at the end of the filename
|
* Wrapper for readFile, appends the texture extension at the end of the filename
|
||||||
|
@ -12,7 +12,7 @@ CDirectory::CDirectory (std::filesystem::path basepath) :
|
|||||||
m_basepath (std::move(basepath))
|
m_basepath (std::move(basepath))
|
||||||
{
|
{
|
||||||
// ensure the specified path exists
|
// ensure the specified path exists
|
||||||
struct stat buffer;
|
struct stat buffer {};
|
||||||
|
|
||||||
if (stat (this->m_basepath.c_str (), &buffer) != 0)
|
if (stat (this->m_basepath.c_str (), &buffer) != 0)
|
||||||
sLog.exception ("Cannot find ", this->m_basepath, ". This folder is required for wallpaper engine to work");
|
sLog.exception ("Cannot find ", this->m_basepath, ". This folder is required for wallpaper engine to work");
|
||||||
@ -22,9 +22,7 @@ CDirectory::CDirectory (std::filesystem::path basepath) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CDirectory::~CDirectory ()
|
CDirectory::~CDirectory ()
|
||||||
{
|
= default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const void* CDirectory::readFile (std::string filename, uint32_t* length) const
|
const void* CDirectory::readFile (std::string filename, uint32_t* length) const
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace WallpaperEngine::Assets
|
|||||||
class CDirectory : public CContainer
|
class CDirectory : public CContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CDirectory (std::filesystem::path basepath);
|
explicit CDirectory (std::filesystem::path basepath);
|
||||||
~CDirectory ();
|
~CDirectory ();
|
||||||
|
|
||||||
const void* readFile (std::string filename, uint32_t* length) const override;
|
const void* readFile (std::string filename, uint32_t* length) const override;
|
||||||
@ -21,4 +21,4 @@ namespace WallpaperEngine::Assets
|
|||||||
std::filesystem::path m_basepath;
|
std::filesystem::path m_basepath;
|
||||||
std::map <std::string, CFileEntry> m_cache;
|
std::map <std::string, CFileEntry> m_cache;
|
||||||
};
|
};
|
||||||
};
|
}
|
@ -29,9 +29,7 @@ CPackage::CPackage (std::filesystem::path path) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CPackage::~CPackage()
|
CPackage::~CPackage()
|
||||||
{
|
= default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const void* CPackage::readFile (std::string filename, uint32_t* length) const
|
const void* CPackage::readFile (std::string filename, uint32_t* length) const
|
||||||
|
@ -16,7 +16,7 @@ namespace WallpaperEngine::Assets
|
|||||||
class CPackage : public CContainer
|
class CPackage : public CContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPackage (std::filesystem::path path);
|
explicit CPackage (std::filesystem::path path);
|
||||||
~CPackage ();
|
~CPackage ();
|
||||||
|
|
||||||
const void* readFile (std::string filename, uint32_t* length) const override;
|
const void* readFile (std::string filename, uint32_t* length) const override;
|
||||||
|
@ -8,7 +8,7 @@ namespace WallpaperEngine::Assets
|
|||||||
class CPackageLoadException : public std::exception
|
class CPackageLoadException : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPackageLoadException(const std::string& message, const std::string& extrainfo = "");
|
explicit CPackageLoadException(const std::string& message, const std::string& extrainfo = "");
|
||||||
const char* what() const noexcept override;
|
const char* what() const noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -7,14 +7,15 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Assets;
|
using namespace WallpaperEngine::Assets;
|
||||||
|
|
||||||
CTexture::CTexture (const void* fileData)
|
CTexture::CTexture (const void* fileData) :
|
||||||
|
m_resolution ()
|
||||||
{
|
{
|
||||||
// ensure the header is parsed
|
// ensure the header is parsed
|
||||||
this->m_header = this->parseHeader (static_cast <const char*> (fileData));
|
this->m_header = parseHeader (static_cast <const char*> (fileData));
|
||||||
|
|
||||||
GLint internalFormat;
|
GLint internalFormat;
|
||||||
|
|
||||||
if (this->isAnimated () == true)
|
if (this->isAnimated ())
|
||||||
{
|
{
|
||||||
this->m_resolution = {
|
this->m_resolution = {
|
||||||
this->m_header->textureWidth, this->m_header->textureHeight,
|
this->m_header->textureWidth, this->m_header->textureHeight,
|
||||||
@ -27,7 +28,7 @@ CTexture::CTexture (const void* fileData)
|
|||||||
{
|
{
|
||||||
// wpengine-texture format always has one mipmap
|
// wpengine-texture format always has one mipmap
|
||||||
// get first image size
|
// get first image size
|
||||||
std::vector<TextureMipmap*>::const_iterator element = this->m_header->images.find (0)->second.begin ();
|
auto element = this->m_header->images.find (0)->second.begin ();
|
||||||
|
|
||||||
// set the texture resolution
|
// set the texture resolution
|
||||||
this->m_resolution = {
|
this->m_resolution = {
|
||||||
@ -160,14 +161,14 @@ CTexture::CTexture (const void* fileData)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (this->m_header->format == TextureFormat::RG88)
|
if (this->m_header->format == TextureFormat::R8)
|
||||||
textureFormat = GL_RG;
|
|
||||||
else if (this->m_header->format == TextureFormat::R8)
|
|
||||||
{
|
{
|
||||||
// red textures are 1-byte-per-pixel, so it's alignment has to be set manually
|
// red textures are 1-byte-per-pixel, so it's alignment has to be set manually
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
textureFormat = GL_RED;
|
textureFormat = GL_RED;
|
||||||
}
|
}
|
||||||
|
else if (this->m_header->format == TextureFormat::RG88)
|
||||||
|
textureFormat = GL_RG;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (internalFormat)
|
switch (internalFormat)
|
||||||
@ -242,12 +243,12 @@ const uint32_t CTexture::getTextureHeight (uint32_t imageIndex) const
|
|||||||
|
|
||||||
const uint32_t CTexture::getRealWidth () const
|
const uint32_t CTexture::getRealWidth () const
|
||||||
{
|
{
|
||||||
return this->isAnimated () == true ? this->getHeader ()->gifWidth : this->getHeader ()->width;
|
return this->isAnimated () ? this->getHeader ()->gifWidth : this->getHeader ()->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CTexture::getRealHeight () const
|
const uint32_t CTexture::getRealHeight () const
|
||||||
{
|
{
|
||||||
return this->isAnimated () == true ? this->getHeader ()->gifHeight : this->getHeader ()->height;
|
return this->isAnimated () ? this->getHeader ()->gifHeight : this->getHeader ()->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ITexture::TextureFormat CTexture::getFormat () const
|
const ITexture::TextureFormat CTexture::getFormat () const
|
||||||
@ -281,8 +282,7 @@ const bool CTexture::isAnimated () const
|
|||||||
}
|
}
|
||||||
|
|
||||||
CTexture::TextureMipmap::TextureMipmap ()
|
CTexture::TextureMipmap::TextureMipmap ()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
CTexture::TextureMipmap::~TextureMipmap ()
|
CTexture::TextureMipmap::~TextureMipmap ()
|
||||||
{
|
{
|
||||||
@ -308,26 +308,41 @@ void CTexture::TextureMipmap::decompressData ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::TextureFrame::TextureFrame ()
|
CTexture::TextureFrame::TextureFrame () :
|
||||||
|
frameNumber (0),
|
||||||
|
frametime (0.0f),
|
||||||
|
x (0),
|
||||||
|
y (0),
|
||||||
|
width1 (0),
|
||||||
|
width2 (0),
|
||||||
|
height1 (0),
|
||||||
|
height2 (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::TextureFrame::~TextureFrame ()
|
CTexture::TextureFrame::~TextureFrame ()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
CTexture::TextureHeader::TextureHeader ()
|
CTexture::TextureHeader::TextureHeader () :
|
||||||
|
flags (NoFlags),
|
||||||
|
width (0),
|
||||||
|
height (0),
|
||||||
|
textureWidth (0),
|
||||||
|
textureHeight (0),
|
||||||
|
gifWidth (0),
|
||||||
|
gifHeight (0),
|
||||||
|
format (TextureFormat::UNKNOWN),
|
||||||
|
imageCount (0),
|
||||||
|
mipmapCount (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::TextureHeader::~TextureHeader ()
|
CTexture::TextureHeader::~TextureHeader ()
|
||||||
{
|
{
|
||||||
for (const auto& imgCur : this->images)
|
for (const auto& imgCur : this->images)
|
||||||
{
|
|
||||||
for (auto cur : imgCur.second)
|
for (auto cur : imgCur.second)
|
||||||
delete cur;
|
delete cur;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CTexture::TextureHeader* CTexture::parseHeader (const char* fileData)
|
CTexture::TextureHeader* CTexture::parseHeader (const char* fileData)
|
||||||
{
|
{
|
||||||
@ -342,9 +357,9 @@ CTexture::TextureHeader* CTexture::parseHeader (const char* fileData)
|
|||||||
// jump through the string again
|
// jump through the string again
|
||||||
fileData += 9;
|
fileData += 9;
|
||||||
|
|
||||||
TextureHeader* header = new TextureHeader;
|
auto* header = new TextureHeader;
|
||||||
|
|
||||||
const uint32_t* pointer = reinterpret_cast <const uint32_t*> (fileData);
|
const auto* pointer = reinterpret_cast <const uint32_t*> (fileData);
|
||||||
|
|
||||||
header->format = static_cast <TextureFormat>(*pointer ++);
|
header->format = static_cast <TextureFormat>(*pointer ++);
|
||||||
header->flags = static_cast <TextureFlags> (*pointer ++);
|
header->flags = static_cast <TextureFlags> (*pointer ++);
|
||||||
@ -433,7 +448,7 @@ CTexture::TextureHeader* CTexture::parseHeader (const char* fileData)
|
|||||||
while (framecount > 0)
|
while (framecount > 0)
|
||||||
{
|
{
|
||||||
// add the frame to the list
|
// add the frame to the list
|
||||||
header->frames.push_back (parseAnimation (header, &fileData));
|
header->frames.push_back (parseAnimation (&fileData));
|
||||||
|
|
||||||
framecount --;
|
framecount --;
|
||||||
}
|
}
|
||||||
@ -451,19 +466,19 @@ CTexture::TextureHeader* CTexture::parseHeader (const char* fileData)
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::TextureFrame* CTexture::parseAnimation (TextureHeader* header, const char** originalFileData)
|
CTexture::TextureFrame* CTexture::parseAnimation (const char** originalFileData)
|
||||||
{
|
{
|
||||||
const char* fileData = *originalFileData;
|
const char* fileData = *originalFileData;
|
||||||
// get back the pointer into integer
|
// get back the pointer into integer
|
||||||
const uint32_t* pointer = reinterpret_cast <const uint32_t*> (fileData);
|
const auto* pointer = reinterpret_cast <const uint32_t*> (fileData);
|
||||||
|
|
||||||
// start reading frame information
|
// start reading frame information
|
||||||
TextureFrame* frame = new TextureFrame();
|
auto* frame = new TextureFrame();
|
||||||
|
|
||||||
frame->frameNumber = *pointer++;
|
frame->frameNumber = *pointer++;
|
||||||
|
|
||||||
// reinterpret the pointer into float
|
// reinterpret the pointer into float
|
||||||
const float* fPointer = reinterpret_cast <const float*> (pointer);
|
const auto* fPointer = reinterpret_cast <const float*> (pointer);
|
||||||
|
|
||||||
frame->frametime = *fPointer ++;
|
frame->frametime = *fPointer ++;
|
||||||
frame->x = *fPointer ++;
|
frame->x = *fPointer ++;
|
||||||
@ -481,13 +496,13 @@ CTexture::TextureFrame* CTexture::parseAnimation (TextureHeader* header, const c
|
|||||||
|
|
||||||
CTexture::TextureMipmap* CTexture::parseMipmap (TextureHeader* header, const char** originalFileData)
|
CTexture::TextureMipmap* CTexture::parseMipmap (TextureHeader* header, const char** originalFileData)
|
||||||
{
|
{
|
||||||
TextureMipmap* mipmap = new TextureMipmap ();
|
auto* mipmap = new TextureMipmap ();
|
||||||
|
|
||||||
// get the current position
|
// get the current position
|
||||||
const char* fileData = *originalFileData;
|
const char* fileData = *originalFileData;
|
||||||
|
|
||||||
// get an integer pointer
|
// get an integer pointer
|
||||||
const uint32_t* pointer = reinterpret_cast <const uint32_t*> (fileData);
|
const auto* pointer = reinterpret_cast <const uint32_t*> (fileData);
|
||||||
|
|
||||||
mipmap->width = *pointer++;
|
mipmap->width = *pointer++;
|
||||||
mipmap->height = *pointer++;
|
mipmap->height = *pointer++;
|
||||||
@ -536,7 +551,7 @@ CTexture::TextureMipmap* CTexture::parseMipmap (TextureHeader* header, const cha
|
|||||||
return mipmap;
|
return mipmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CTexture::TextureHeader::isAnimated () const
|
bool CTexture::TextureHeader::isAnimated () const
|
||||||
{
|
{
|
||||||
return this->flags & TextureFlags::IsGif;
|
return this->flags & TextureFlags::IsGif;
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ namespace WallpaperEngine::Assets
|
|||||||
struct TextureHeader;
|
struct TextureHeader;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTexture (const void* fileData);
|
explicit CTexture (const void* fileData);
|
||||||
~CTexture ();
|
~CTexture ();
|
||||||
|
|
||||||
const GLuint getTextureID (uint32_t imageIndex = 0) const override;
|
const GLuint getTextureID (uint32_t imageIndex = 0) const override;
|
||||||
@ -82,7 +82,7 @@ namespace WallpaperEngine::Assets
|
|||||||
TextureHeader ();
|
TextureHeader ();
|
||||||
~TextureHeader ();
|
~TextureHeader ();
|
||||||
|
|
||||||
const bool isAnimated () const;
|
bool isAnimated () const;
|
||||||
|
|
||||||
/** The version of the texture container */
|
/** The version of the texture container */
|
||||||
ContainerVersion containerVersion = ContainerVersion::UNKNOWN;
|
ContainerVersion containerVersion = ContainerVersion::UNKNOWN;
|
||||||
@ -117,7 +117,7 @@ namespace WallpaperEngine::Assets
|
|||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
static TextureHeader* parseHeader (const char* fileData);
|
static TextureHeader* parseHeader (const char* fileData);
|
||||||
static TextureFrame* parseAnimation (TextureHeader* header, const char** originalFileData);
|
static TextureFrame* parseAnimation (const char** originalFileData);
|
||||||
static TextureMipmap* parseMipmap (TextureHeader* header, const char** fileData);
|
static TextureMipmap* parseMipmap (TextureHeader* header, const char** fileData);
|
||||||
|
|
||||||
TextureHeader* m_header;
|
TextureHeader* m_header;
|
||||||
|
@ -11,8 +11,8 @@ namespace WallpaperEngine::Assets
|
|||||||
class CVirtualContainer : public CContainer
|
class CVirtualContainer : public CContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CVirtualContainer () {}
|
CVirtualContainer () = default;
|
||||||
~CVirtualContainer () {}
|
~CVirtualContainer () = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new file to the virtual container
|
* Adds a new file to the virtual container
|
||||||
|
@ -36,6 +36,7 @@ namespace WallpaperEngine::Assets
|
|||||||
*/
|
*/
|
||||||
enum TextureFormat : uint32_t
|
enum TextureFormat : uint32_t
|
||||||
{
|
{
|
||||||
|
UNKNOWN = 0xFFFFFFFF,
|
||||||
ARGB8888 = 0,
|
ARGB8888 = 0,
|
||||||
RGB888 = 1,
|
RGB888 = 1,
|
||||||
RGB565 = 2,
|
RGB565 = 2,
|
||||||
@ -74,4 +75,4 @@ namespace WallpaperEngine::Assets
|
|||||||
virtual const glm::vec4* getResolution () const = 0;
|
virtual const glm::vec4* getResolution () const = 0;
|
||||||
virtual const bool isAnimated () const = 0;
|
virtual const bool isAnimated () const = 0;
|
||||||
};
|
};
|
||||||
};
|
}
|
@ -15,7 +15,7 @@ namespace WallpaperEngine::Audio
|
|||||||
class CAudioContext
|
class CAudioContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAudioContext (Drivers::CAudioDriver& driver);
|
explicit CAudioContext (Drivers::CAudioDriver& driver);
|
||||||
|
|
||||||
void addStream (CAudioStream* stream);
|
void addStream (CAudioStream* stream);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ int audio_read_thread (void* arg)
|
|||||||
if (waitMutex == nullptr)
|
if (waitMutex == nullptr)
|
||||||
sLog.exception ("Cannot create mutex for audio playback waiting");
|
sLog.exception ("Cannot create mutex for audio playback waiting");
|
||||||
|
|
||||||
while (ret >= 0 && g_KeepRunning == true)
|
while (ret >= 0 && g_KeepRunning)
|
||||||
{
|
{
|
||||||
// give the cpu some time to play the queued frames if there's enough info there
|
// give the cpu some time to play the queued frames if there's enough info there
|
||||||
if (
|
if (
|
||||||
@ -47,7 +47,7 @@ int audio_read_thread (void* arg)
|
|||||||
avcodec_flush_buffers (stream->getContext ());
|
avcodec_flush_buffers (stream->getContext ());
|
||||||
|
|
||||||
// ensure the thread is not killed if audio has to be looped
|
// ensure the thread is not killed if audio has to be looped
|
||||||
if (stream->isRepeat() == true)
|
if (stream->isRepeat())
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -59,7 +59,7 @@ int audio_read_thread (void* arg)
|
|||||||
else
|
else
|
||||||
av_packet_unref (packet);
|
av_packet_unref (packet);
|
||||||
|
|
||||||
if (stream->isInitialized () == false)
|
if (!stream->isInitialized ())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,8 +165,8 @@ CAudioStream::~CAudioStream()
|
|||||||
|
|
||||||
void CAudioStream::loadCustomContent (const char* filename)
|
void CAudioStream::loadCustomContent (const char* filename)
|
||||||
{
|
{
|
||||||
const AVCodec* aCodec = nullptr;
|
const AVCodec* aCodec;
|
||||||
AVCodecContext* avCodecContext = nullptr;
|
AVCodecContext* avCodecContext;
|
||||||
|
|
||||||
if (avformat_open_input (&this->m_formatContext, filename, nullptr, nullptr) != 0)
|
if (avformat_open_input (&this->m_formatContext, filename, nullptr, nullptr) != 0)
|
||||||
sLog.exception ("Cannot open audio file: ", filename);
|
sLog.exception ("Cannot open audio file: ", filename);
|
||||||
@ -287,7 +287,7 @@ void CAudioStream::queuePacket(AVPacket *pkt)
|
|||||||
bool gotQueued = this->doQueue (clone);
|
bool gotQueued = this->doQueue (clone);
|
||||||
SDL_UnlockMutex (this->m_queue->mutex);
|
SDL_UnlockMutex (this->m_queue->mutex);
|
||||||
|
|
||||||
if (gotQueued == false)
|
if (!gotQueued)
|
||||||
av_packet_free (&pkt);
|
av_packet_free (&pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,11 +324,12 @@ void CAudioStream::dequeuePacket (AVPacket* output)
|
|||||||
|
|
||||||
while (g_KeepRunning)
|
while (g_KeepRunning)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
#if FF_API_FIFO_OLD_API
|
#if FF_API_FIFO_OLD_API
|
||||||
ret = av_fifo_read (this->m_queue->packetList, &entry, 1);
|
int ret = av_fifo_read (this->m_queue->packetList, &entry, 1);
|
||||||
#else
|
#else
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
if (av_fifo_size (this->m_queue->packetList) >= sizeof (entry))
|
if (av_fifo_size (this->m_queue->packetList) >= sizeof (entry))
|
||||||
ret = av_fifo_generic_read (this->m_queue->packetList, &entry, sizeof (entry), nullptr);
|
ret = av_fifo_generic_read (this->m_queue->packetList, &entry, sizeof (entry), nullptr);
|
||||||
#endif
|
#endif
|
||||||
@ -440,29 +441,23 @@ SDL_mutex* CAudioStream::getMutex ()
|
|||||||
|
|
||||||
void CAudioStream::stop ()
|
void CAudioStream::stop ()
|
||||||
{
|
{
|
||||||
if (this->isInitialized () == false)
|
if (!this->isInitialized ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// stop the threads running
|
// stop the threads running
|
||||||
this->m_initialized = false;
|
this->m_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAudioStream::resampleAudio (
|
int CAudioStream::resampleAudio (AVFrame * decoded_audio_frame, uint8_t * out_buf)
|
||||||
AVFrame * decoded_audio_frame,
|
|
||||||
enum AVSampleFormat out_sample_fmt,
|
|
||||||
int out_channels,
|
|
||||||
int out_sample_rate,
|
|
||||||
uint8_t * out_buf
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
int out_nb_channels = 0;
|
|
||||||
int out_linesize = 0;
|
int out_linesize = 0;
|
||||||
int in_nb_samples = 0;
|
int ret;
|
||||||
int out_nb_samples = 0;
|
int out_nb_channels;
|
||||||
int max_out_nb_samples = 0;
|
int in_nb_samples;
|
||||||
uint8_t ** resampled_data = NULL;
|
int out_nb_samples;
|
||||||
int resampled_data_size = 0;
|
int max_out_nb_samples;
|
||||||
|
uint8_t** resampled_data = nullptr;
|
||||||
|
int resampled_data_size;
|
||||||
|
|
||||||
// retrieve number of audio samples (per channel)
|
// retrieve number of audio samples (per channel)
|
||||||
in_nb_samples = decoded_audio_frame->nb_samples;
|
in_nb_samples = decoded_audio_frame->nb_samples;
|
||||||
@ -474,7 +469,7 @@ int CAudioStream::resampleAudio (
|
|||||||
|
|
||||||
max_out_nb_samples = out_nb_samples = av_rescale_rnd(
|
max_out_nb_samples = out_nb_samples = av_rescale_rnd(
|
||||||
in_nb_samples,
|
in_nb_samples,
|
||||||
out_sample_rate,
|
this->m_audioContext.getSampleRate (),
|
||||||
this->getContext ()->sample_rate,
|
this->getContext ()->sample_rate,
|
||||||
AV_ROUND_UP
|
AV_ROUND_UP
|
||||||
);
|
);
|
||||||
@ -507,7 +502,7 @@ int CAudioStream::resampleAudio (
|
|||||||
&out_linesize,
|
&out_linesize,
|
||||||
out_nb_channels,
|
out_nb_channels,
|
||||||
out_nb_samples,
|
out_nb_samples,
|
||||||
out_sample_fmt,
|
this->m_audioContext.getFormat (),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -520,7 +515,7 @@ int CAudioStream::resampleAudio (
|
|||||||
// retrieve output samples number taking into account the progressive delay
|
// retrieve output samples number taking into account the progressive delay
|
||||||
out_nb_samples = av_rescale_rnd(
|
out_nb_samples = av_rescale_rnd(
|
||||||
swr_get_delay(this->m_swrctx, this->getContext ()->sample_rate) + in_nb_samples,
|
swr_get_delay(this->m_swrctx, this->getContext ()->sample_rate) + in_nb_samples,
|
||||||
out_sample_rate,
|
this->m_audioContext.getSampleRate (),
|
||||||
this->getContext ()->sample_rate,
|
this->getContext ()->sample_rate,
|
||||||
AV_ROUND_UP
|
AV_ROUND_UP
|
||||||
);
|
);
|
||||||
@ -543,7 +538,7 @@ int CAudioStream::resampleAudio (
|
|||||||
&out_linesize,
|
&out_linesize,
|
||||||
out_nb_channels,
|
out_nb_channels,
|
||||||
out_nb_samples,
|
out_nb_samples,
|
||||||
out_sample_fmt,
|
this->m_audioContext.getFormat (),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -561,7 +556,7 @@ int CAudioStream::resampleAudio (
|
|||||||
ret = swr_convert(
|
ret = swr_convert(
|
||||||
this->m_swrctx,
|
this->m_swrctx,
|
||||||
resampled_data,
|
resampled_data,
|
||||||
out_nb_samples,
|
max_out_nb_samples,
|
||||||
(const uint8_t **) decoded_audio_frame->data,
|
(const uint8_t **) decoded_audio_frame->data,
|
||||||
decoded_audio_frame->nb_samples
|
decoded_audio_frame->nb_samples
|
||||||
);
|
);
|
||||||
@ -578,7 +573,7 @@ int CAudioStream::resampleAudio (
|
|||||||
&out_linesize,
|
&out_linesize,
|
||||||
out_nb_channels,
|
out_nb_channels,
|
||||||
ret,
|
ret,
|
||||||
out_sample_fmt,
|
this->m_audioContext.getFormat (),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -613,7 +608,7 @@ int CAudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize)
|
|||||||
static uint8_t *audio_pkt_data = NULL;
|
static uint8_t *audio_pkt_data = NULL;
|
||||||
static int audio_pkt_size = 0;
|
static int audio_pkt_size = 0;
|
||||||
|
|
||||||
int len1, data_size = 0;
|
int len1, data_size;
|
||||||
|
|
||||||
// allocate a new frame, used to decode audio packets
|
// allocate a new frame, used to decode audio packets
|
||||||
static AVFrame * avFrame = NULL;
|
static AVFrame * avFrame = NULL;
|
||||||
@ -636,11 +631,9 @@ int CAudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = avcodec_send_packet(this->getContext (), pkt);
|
ret = avcodec_send_packet(this->getContext (), pkt);
|
||||||
if (ret == AVERROR(EAGAIN))
|
if (ret < 0 && ret != AVERROR (EAGAIN))
|
||||||
ret = 0;
|
|
||||||
else if (ret < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
else
|
|
||||||
len1 = pkt->size;
|
len1 = pkt->size;
|
||||||
|
|
||||||
if (len1 < 0)
|
if (len1 < 0)
|
||||||
@ -656,13 +649,7 @@ int CAudioStream::decodeFrame (uint8_t* audioBuffer, int bufferSize)
|
|||||||
|
|
||||||
if (got_frame) {
|
if (got_frame) {
|
||||||
// audio resampling
|
// audio resampling
|
||||||
data_size = this->resampleAudio (
|
data_size = this->resampleAudio (avFrame, audioBuffer);
|
||||||
avFrame,
|
|
||||||
this->m_audioContext.getFormat (),
|
|
||||||
this->m_audioContext.getChannels (),
|
|
||||||
this->m_audioContext.getSampleRate (),
|
|
||||||
audioBuffer
|
|
||||||
);
|
|
||||||
assert(data_size <= bufferSize);
|
assert(data_size <= bufferSize);
|
||||||
}
|
}
|
||||||
if (data_size <= 0) {
|
if (data_size <= 0) {
|
||||||
|
@ -10,7 +10,7 @@ extern "C"
|
|||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
#include <libavutil/opt.h>
|
#include <libavutil/opt.h>
|
||||||
};
|
}
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_thread.h>
|
#include <SDL_thread.h>
|
||||||
@ -61,7 +61,7 @@ namespace WallpaperEngine::Audio
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void loadCustomContent (const char* filename = nullptr);
|
void loadCustomContent (const char* filename = nullptr);
|
||||||
int resampleAudio (AVFrame * decoded_audio_frame, enum AVSampleFormat out_sample_fmt, int out_channels, int out_sample_rate, uint8_t* out_buf);
|
int resampleAudio (AVFrame * decoded_audio_frame, uint8_t* out_buf);
|
||||||
bool doQueue (AVPacket* pkt);
|
bool doQueue (AVPacket* pkt);
|
||||||
void initialize ();
|
void initialize ();
|
||||||
|
|
||||||
@ -100,4 +100,4 @@ namespace WallpaperEngine::Audio
|
|||||||
SDL_cond *cond;
|
SDL_cond *cond;
|
||||||
} *m_queue;
|
} *m_queue;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -24,11 +24,11 @@ void audio_callback (void* userdata, uint8_t* streamData, int length)
|
|||||||
|
|
||||||
// sound is not initialized or stopped and is not in loop mode
|
// sound is not initialized or stopped and is not in loop mode
|
||||||
// ignore mixing it in
|
// ignore mixing it in
|
||||||
if (buffer->stream->isInitialized () == false)
|
if (!buffer->stream->isInitialized ())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check if thread is empty and signal the read thread
|
// check if queue is empty and signal the read thread
|
||||||
if (buffer->stream->isQueueEmpty () == true)
|
if (buffer->stream->isQueueEmpty ())
|
||||||
{
|
{
|
||||||
SDL_CondSignal (buffer->stream->getWaitCondition ());
|
SDL_CondSignal (buffer->stream->getWaitCondition ());
|
||||||
continue;
|
continue;
|
||||||
@ -74,7 +74,8 @@ void audio_callback (void* userdata, uint8_t* streamData, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSDLAudioDriver::CSDLAudioDriver () :
|
CSDLAudioDriver::CSDLAudioDriver () :
|
||||||
m_initialized (false)
|
m_initialized (false),
|
||||||
|
m_audioSpec ()
|
||||||
{
|
{
|
||||||
if (SDL_InitSubSystem (SDL_INIT_AUDIO) < 0)
|
if (SDL_InitSubSystem (SDL_INIT_AUDIO) < 0)
|
||||||
{
|
{
|
||||||
@ -110,7 +111,7 @@ CSDLAudioDriver::CSDLAudioDriver () :
|
|||||||
|
|
||||||
CSDLAudioDriver::~CSDLAudioDriver ()
|
CSDLAudioDriver::~CSDLAudioDriver ()
|
||||||
{
|
{
|
||||||
if (this->m_initialized == false)
|
if (!this->m_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_CloseAudioDevice (this->m_deviceID);
|
SDL_CloseAudioDevice (this->m_deviceID);
|
||||||
|
@ -54,9 +54,9 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
|||||||
auto text_it = data.find ("text");
|
auto text_it = data.find ("text");
|
||||||
auto light_it = data.find ("light");
|
auto light_it = data.find ("light");
|
||||||
|
|
||||||
CObject* object = nullptr;
|
CObject* object;
|
||||||
|
|
||||||
if (image_it != data.end () && (*image_it).is_null () == false)
|
if (image_it != data.end () && !(*image_it).is_null ())
|
||||||
{
|
{
|
||||||
object = Objects::CImage::fromJSON (
|
object = Objects::CImage::fromJSON (
|
||||||
scene,
|
scene,
|
||||||
@ -70,7 +70,7 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
|||||||
WallpaperEngine::Core::aToVector3 (angles_val)
|
WallpaperEngine::Core::aToVector3 (angles_val)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (sound_it != data.end () && (*sound_it).is_null () == false)
|
else if (sound_it != data.end () && !(*sound_it).is_null ())
|
||||||
{
|
{
|
||||||
object = Objects::CSound::fromJSON (
|
object = Objects::CSound::fromJSON (
|
||||||
scene,
|
scene,
|
||||||
@ -83,7 +83,7 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
|||||||
WallpaperEngine::Core::aToVector3 (angles_val)
|
WallpaperEngine::Core::aToVector3 (angles_val)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (particle_it != data.end () && (*particle_it).is_null () == false)
|
else if (particle_it != data.end () && !(*particle_it).is_null ())
|
||||||
{
|
{
|
||||||
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
|
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
|
||||||
try
|
try
|
||||||
@ -99,17 +99,17 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
|||||||
scale
|
scale
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (std::runtime_error ex)
|
catch (std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (text_it != data.end () && (*text_it).is_null () == false)
|
else if (text_it != data.end () && !(*text_it).is_null ())
|
||||||
{
|
{
|
||||||
/// TODO: XXXHACK -- TO REMOVE WHEN TEXT SUPPORT IS IMPLEMENTED
|
/// TODO: XXXHACK -- TO REMOVE WHEN TEXT SUPPORT IS IMPLEMENTED
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
else if (light_it != data.end () && (*light_it).is_null () == false)
|
else if (light_it != data.end () && !(*light_it).is_null ())
|
||||||
{
|
{
|
||||||
/// TODO: XXXHACK -- TO REMOVE WHEN LIGHT SUPPORT IS IMPLEMENTED
|
/// TODO: XXXHACK -- TO REMOVE WHEN LIGHT SUPPORT IS IMPLEMENTED
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -119,23 +119,24 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
|||||||
sLog.exception ("Unknown object type detected: ", *name_it);
|
sLog.exception ("Unknown object type detected: ", *name_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effects_it != data.end () && (*effects_it).is_array () == true)
|
if (effects_it != data.end () && (*effects_it).is_array ())
|
||||||
{
|
{
|
||||||
for (const auto& cur : *effects_it)
|
for (const auto& cur : *effects_it)
|
||||||
{
|
{
|
||||||
auto effectVisible = jsonFindUserConfig <CUserSettingBoolean> (data, "visible", true);
|
auto effectVisible = jsonFindUserConfig <CUserSettingBoolean> (data, "visible", true);
|
||||||
|
|
||||||
|
if (!effectVisible->processValue (scene->getProject ()->getProperties ()))
|
||||||
|
continue;
|
||||||
|
|
||||||
object->insertEffect (
|
object->insertEffect (
|
||||||
Objects::CEffect::fromJSON (cur, effectVisible, object, container)
|
Objects::CEffect::fromJSON (cur, effectVisible, object, container)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dependencies_it != data.end () && (*dependencies_it).is_array () == true)
|
if (dependencies_it != data.end () && (*dependencies_it).is_array ())
|
||||||
{
|
|
||||||
for (const auto& cur : *dependencies_it)
|
for (const auto& cur : *dependencies_it)
|
||||||
object->insertDependency (cur);
|
object->insertDependency (cur);
|
||||||
}
|
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@ -170,7 +171,7 @@ const std::vector<uint32_t>& CObject::getDependencies () const
|
|||||||
return this->m_dependencies;
|
return this->m_dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CObject::isVisible () const
|
bool CObject::isVisible () const
|
||||||
{
|
{
|
||||||
// TODO: cache this
|
// TODO: cache this
|
||||||
return this->m_visible->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_visible->processValue (this->getScene ()->getProject ()->getProperties ());
|
||||||
@ -181,7 +182,7 @@ CScene* CObject::getScene () const
|
|||||||
return this->m_scene;
|
return this->m_scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int CObject::getId () const
|
int CObject::getId () const
|
||||||
{
|
{
|
||||||
return this->m_id;
|
return this->m_id;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,14 @@ namespace WallpaperEngine::Core
|
|||||||
|
|
||||||
const std::vector<Objects::CEffect*>& getEffects () const;
|
const std::vector<Objects::CEffect*>& getEffects () const;
|
||||||
const std::vector<uint32_t>& getDependencies () const;
|
const std::vector<uint32_t>& getDependencies () const;
|
||||||
const int getId () const;
|
int getId () const;
|
||||||
|
|
||||||
glm::vec3 getOrigin () const;
|
glm::vec3 getOrigin () const;
|
||||||
glm::vec3 getScale () const;
|
glm::vec3 getScale () const;
|
||||||
const glm::vec3& getAngles () const;
|
const glm::vec3& getAngles () const;
|
||||||
const std::string& getName () const;
|
const std::string& getName () const;
|
||||||
|
|
||||||
const bool isVisible () const;
|
bool isVisible () const;
|
||||||
CScene* getScene () const;
|
CScene* getScene () const;
|
||||||
protected:
|
protected:
|
||||||
CObject (
|
CObject (
|
||||||
@ -80,4 +80,4 @@ namespace WallpaperEngine::Core
|
|||||||
|
|
||||||
CScene* m_scene;
|
CScene* m_scene;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -38,4 +38,4 @@ namespace WallpaperEngine::Core
|
|||||||
CWallpaper* m_wallpaper;
|
CWallpaper* m_wallpaper;
|
||||||
CContainer& m_container;
|
CContainer& m_container;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -97,4 +97,4 @@ namespace WallpaperEngine::Core
|
|||||||
std::map<uint32_t, CObject*> m_objects;
|
std::map<uint32_t, CObject*> m_objects;
|
||||||
std::vector<CObject*> m_objectsByRenderOrder;
|
std::vector<CObject*> m_objectsByRenderOrder;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -16,9 +16,7 @@ namespace WallpaperEngine::Core
|
|||||||
class CVideo : public CWallpaper
|
class CVideo : public CWallpaper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CVideo (
|
explicit CVideo (std::string filename);
|
||||||
std::string filename
|
|
||||||
);
|
|
||||||
|
|
||||||
const std::string& getFilename ();
|
const std::string& getFilename ();
|
||||||
|
|
||||||
@ -31,4 +29,4 @@ namespace WallpaperEngine::Core
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#include "CWallpaper.h"
|
#include "CWallpaper.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace WallpaperEngine::Core;
|
using namespace WallpaperEngine::Core;
|
||||||
|
|
||||||
CWallpaper::CWallpaper (std::string type) :
|
CWallpaper::CWallpaper (std::string type) :
|
||||||
m_type (type)
|
m_type (std::move(type)),
|
||||||
|
m_project (nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
|
|
||||||
#include "CProject.h"
|
#include "CProject.h"
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ glm::vec3 Core::aToColorf (const std::string& str)
|
|||||||
|
|
||||||
glm::ivec3 Core::aToColori (const char* str)
|
glm::ivec3 Core::aToColori (const char* str)
|
||||||
{
|
{
|
||||||
uint8_t r = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
auto r = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
||||||
uint8_t g = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
auto g = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
||||||
uint8_t b = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10));
|
auto b = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10));
|
||||||
|
|
||||||
return {r, g, b};
|
return {r, g, b};
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,4 @@ namespace WallpaperEngine::Core
|
|||||||
nlohmann::json::iterator jsonFindRequired (nlohmann::json::iterator& data, const char *key, const char *notFoundMsg);
|
nlohmann::json::iterator jsonFindRequired (nlohmann::json::iterator& data, const char *key, const char *notFoundMsg);
|
||||||
template <typename T> T jsonFindDefault (nlohmann::json& data, const char *key, T defaultValue);
|
template <typename T> T jsonFindDefault (nlohmann::json& data, const char *key, T defaultValue);
|
||||||
template <typename T> T* jsonFindUserConfig (nlohmann::json& data, const char *key, typename T::data_type defaultValue);
|
template <typename T> T* jsonFindUserConfig (nlohmann::json& data, const char *key, typename T::data_type defaultValue);
|
||||||
};
|
}
|
||||||
|
@ -51,7 +51,7 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, Core::CObje
|
|||||||
auto dependencies_it = jsonFindRequired (content, "dependencies", "");
|
auto dependencies_it = jsonFindRequired (content, "dependencies", "");
|
||||||
auto fbos_it = content.find ("fbos");
|
auto fbos_it = content.find ("fbos");
|
||||||
|
|
||||||
CEffect* effect = new CEffect (
|
auto* effect = new CEffect (
|
||||||
*name_it,
|
*name_it,
|
||||||
description,
|
description,
|
||||||
*group_it,
|
*group_it,
|
||||||
@ -64,9 +64,7 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, Core::CObje
|
|||||||
CEffect::dependencyFromJSON (dependencies_it, effect);
|
CEffect::dependencyFromJSON (dependencies_it, effect);
|
||||||
|
|
||||||
if (fbos_it != content.end ())
|
if (fbos_it != content.end ())
|
||||||
{
|
|
||||||
CEffect::fbosFromJSON (fbos_it, effect);
|
CEffect::fbosFromJSON (fbos_it, effect);
|
||||||
}
|
|
||||||
|
|
||||||
if (effectpasses_it != data.end ())
|
if (effectpasses_it != data.end ())
|
||||||
{
|
{
|
||||||
@ -94,11 +92,11 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, Core::CObje
|
|||||||
{
|
{
|
||||||
std::string texture;
|
std::string texture;
|
||||||
|
|
||||||
if (texturesCur.is_null () == true)
|
if (texturesCur.is_null ())
|
||||||
{
|
{
|
||||||
if (textureNumber == 0)
|
if (textureNumber == 0)
|
||||||
{
|
{
|
||||||
CImage* image = object->as <CImage> ();
|
auto* image = object->as <CImage> ();
|
||||||
|
|
||||||
texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ());
|
texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ());
|
||||||
}
|
}
|
||||||
@ -151,13 +149,13 @@ void CEffect::constantsFromJSON (json::const_iterator constants_it, Core::Object
|
|||||||
{
|
{
|
||||||
auto val = cur.value ();
|
auto val = cur.value ();
|
||||||
|
|
||||||
Effects::Constants::CShaderConstant* constant = nullptr;
|
Effects::Constants::CShaderConstant* constant;
|
||||||
|
|
||||||
// if the constant is an object, that means the constant has some extra information
|
// if the constant is an object, that means the constant has some extra information
|
||||||
// for the UI, take the value, which is what we need
|
// for the UI, take the value, which is what we need
|
||||||
|
|
||||||
// TODO: SUPPORT USER SETTINGS HERE
|
// TODO: SUPPORT USER SETTINGS HERE
|
||||||
if (cur.value ().is_object () == true)
|
if (cur.value ().is_object ())
|
||||||
{
|
{
|
||||||
auto it = cur.value ().find ("value");
|
auto it = cur.value ().find ("value");
|
||||||
|
|
||||||
@ -170,15 +168,15 @@ void CEffect::constantsFromJSON (json::const_iterator constants_it, Core::Object
|
|||||||
val = it.value ();
|
val = it.value ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val.is_number_float () == true)
|
if (val.is_number_float ())
|
||||||
{
|
{
|
||||||
constant = new Effects::Constants::CShaderConstantFloat (val.get <float> ());
|
constant = new Effects::Constants::CShaderConstantFloat (val.get <float> ());
|
||||||
}
|
}
|
||||||
else if (val.is_number_integer () == true)
|
else if (val.is_number_integer ())
|
||||||
{
|
{
|
||||||
constant = new Effects::Constants::CShaderConstantInteger (val.get <int> ());
|
constant = new Effects::Constants::CShaderConstantInteger (val.get <int> ());
|
||||||
}
|
}
|
||||||
else if (val.is_string () == true)
|
else if (val.is_string ())
|
||||||
{
|
{
|
||||||
// try a vector 4 first, then a vector3 and then a vector 2
|
// try a vector 4 first, then a vector3 and then a vector 2
|
||||||
constant = new Effects::Constants::CShaderConstantVector4 (WallpaperEngine::Core::aToVector4 (val));
|
constant = new Effects::Constants::CShaderConstantVector4 (WallpaperEngine::Core::aToVector4 (val));
|
||||||
@ -215,7 +213,7 @@ void CEffect::materialsFromJSON (json::const_iterator passes_it, CEffect* effect
|
|||||||
if (materialfile == cur.end ())
|
if (materialfile == cur.end ())
|
||||||
sLog.exception ("Found an effect ", effect->m_name, " without material");
|
sLog.exception ("Found an effect ", effect->m_name, " without material");
|
||||||
|
|
||||||
Images::CMaterial* material = nullptr;
|
Images::CMaterial* material;
|
||||||
|
|
||||||
if (target == cur.end ())
|
if (target == cur.end ())
|
||||||
material = Images::CMaterial::fromFile ((*materialfile).get <std::string> (), container);
|
material = Images::CMaterial::fromFile ((*materialfile).get <std::string> (), container);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
namespace WallpaperEngine::Core
|
namespace WallpaperEngine::Core
|
||||||
{
|
{
|
||||||
class CObject;
|
class CObject;
|
||||||
};
|
}
|
||||||
|
|
||||||
namespace WallpaperEngine::Core::UserSettings
|
namespace WallpaperEngine::Core::UserSettings
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
|
|||||||
Images::CMaterial::fromFile ((*material_it).get <std::string> (), container),
|
Images::CMaterial::fromFile ((*material_it).get <std::string> (), container),
|
||||||
visible,
|
visible,
|
||||||
id,
|
id,
|
||||||
name,
|
std::move(name),
|
||||||
origin,
|
origin,
|
||||||
scale,
|
scale,
|
||||||
angles,
|
angles,
|
||||||
@ -99,7 +99,7 @@ const std::string& CImage::getAlignment () const
|
|||||||
return this->m_alignment;
|
return this->m_alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float CImage::getAlpha () const
|
float CImage::getAlpha () const
|
||||||
{
|
{
|
||||||
return this->m_alpha->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_alpha->processValue (this->getScene ()->getProject ()->getProperties ());
|
||||||
}
|
}
|
||||||
@ -109,12 +109,12 @@ glm::vec3 CImage::getColor () const
|
|||||||
return this->m_color->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_color->processValue (this->getScene ()->getProject ()->getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
const float CImage::getBrightness () const
|
float CImage::getBrightness () const
|
||||||
{
|
{
|
||||||
return this->m_brightness;
|
return this->m_brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CImage::getColorBlendMode () const
|
uint32_t CImage::getColorBlendMode () const
|
||||||
{
|
{
|
||||||
return this->m_colorBlendMode;
|
return this->m_colorBlendMode;
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ namespace WallpaperEngine::Core::Objects
|
|||||||
const Images::CMaterial* getMaterial () const;
|
const Images::CMaterial* getMaterial () const;
|
||||||
const glm::vec2& getSize () const;
|
const glm::vec2& getSize () const;
|
||||||
const std::string& getAlignment () const;
|
const std::string& getAlignment () const;
|
||||||
const float getAlpha () const;
|
float getAlpha () const;
|
||||||
glm::vec3 getColor () const;
|
glm::vec3 getColor () const;
|
||||||
const float getBrightness () const;
|
float getBrightness () const;
|
||||||
const uint32_t getColorBlendMode () const;
|
uint32_t getColorBlendMode () const;
|
||||||
const glm::vec2& getParallaxDepth () const;
|
const glm::vec2& getParallaxDepth () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -78,4 +78,4 @@ namespace WallpaperEngine::Core::Objects
|
|||||||
CUserSettingVector3* m_color;
|
CUserSettingVector3* m_color;
|
||||||
uint32_t m_colorBlendMode;
|
uint32_t m_colorBlendMode;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#include "CParticle.h"
|
#include "CParticle.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects;
|
using namespace WallpaperEngine::Core::Objects;
|
||||||
@ -20,13 +22,13 @@ CParticle* CParticle::fromFile (
|
|||||||
auto emitter_it = jsonFindRequired (data, "emitter", "Particles must have emitters");
|
auto emitter_it = jsonFindRequired (data, "emitter", "Particles must have emitters");
|
||||||
auto initializer_it = jsonFindRequired (data, "initializer", "Particles must have initializers");
|
auto initializer_it = jsonFindRequired (data, "initializer", "Particles must have initializers");
|
||||||
|
|
||||||
CParticle* particle = new CParticle (
|
auto* particle = new CParticle (
|
||||||
scene,
|
scene,
|
||||||
*starttime_it,
|
*starttime_it,
|
||||||
*maxcount_it,
|
*maxcount_it,
|
||||||
visible,
|
visible,
|
||||||
id,
|
id,
|
||||||
name,
|
std::move(name),
|
||||||
origin,
|
origin,
|
||||||
scale
|
scale
|
||||||
);
|
);
|
||||||
|
@ -54,4 +54,4 @@ namespace WallpaperEngine::Core::Objects
|
|||||||
std::vector<Particles::CEmitter*> m_emitters;
|
std::vector<Particles::CEmitter*> m_emitters;
|
||||||
std::vector<Particles::CInitializer*> m_initializers;
|
std::vector<Particles::CInitializer*> m_initializers;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -24,7 +24,7 @@ WallpaperEngine::Core::CObject* CSound::fromJSON (
|
|||||||
json data,
|
json data,
|
||||||
CUserSettingBoolean* visible,
|
CUserSettingBoolean* visible,
|
||||||
uint32_t id,
|
uint32_t id,
|
||||||
std::string name,
|
const std::string& name,
|
||||||
CUserSettingVector3* origin,
|
CUserSettingVector3* origin,
|
||||||
CUserSettingVector3* scale,
|
CUserSettingVector3* scale,
|
||||||
const glm::vec3& angles)
|
const glm::vec3& angles)
|
||||||
@ -37,10 +37,10 @@ WallpaperEngine::Core::CObject* CSound::fromJSON (
|
|||||||
if (playbackmode == "loop")
|
if (playbackmode == "loop")
|
||||||
repeat = true;
|
repeat = true;
|
||||||
|
|
||||||
if ((*sound_it).is_array () == false)
|
if (!(*sound_it).is_array ())
|
||||||
sLog.exception ("Expected sound list on element ", name);
|
sLog.exception ("Expected sound list on element ", name);
|
||||||
|
|
||||||
CSound* sound = new CSound (
|
auto* sound = new CSound (
|
||||||
scene,
|
scene,
|
||||||
visible,
|
visible,
|
||||||
id,
|
id,
|
||||||
@ -57,7 +57,7 @@ WallpaperEngine::Core::CObject* CSound::fromJSON (
|
|||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::insertSound (std::string filename)
|
void CSound::insertSound (const std::string& filename)
|
||||||
{
|
{
|
||||||
this->m_sounds.push_back (filename);
|
this->m_sounds.push_back (filename);
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ namespace WallpaperEngine::Core::Objects
|
|||||||
json data,
|
json data,
|
||||||
CUserSettingBoolean* visible,
|
CUserSettingBoolean* visible,
|
||||||
uint32_t id,
|
uint32_t id,
|
||||||
std::string name,
|
const std::string& name,
|
||||||
CUserSettingVector3* origin,
|
CUserSettingVector3* origin,
|
||||||
CUserSettingVector3* scale,
|
CUserSettingVector3* scale,
|
||||||
const glm::vec3& angles
|
const glm::vec3& angles
|
||||||
);
|
);
|
||||||
|
|
||||||
void insertSound (std::string filename);
|
void insertSound (const std::string& filename);
|
||||||
const std::vector<std::string>& getSounds () const;
|
const std::vector<std::string>& getSounds () const;
|
||||||
bool isRepeat () const;
|
bool isRepeat () const;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace WallpaperEngine::Core::Objects::Effects::Constants
|
|||||||
class CShaderConstant
|
class CShaderConstant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CShaderConstant (std::string type);
|
explicit CShaderConstant (std::string type);
|
||||||
|
|
||||||
template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
|
template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
|
||||||
template<class T> T* as () { assert (is <T> ()); return (T*) this; }
|
template<class T> T* as () { assert (is <T> ()); return (T*) this; }
|
||||||
|
@ -9,7 +9,7 @@ namespace WallpaperEngine::Core::Objects::Effects::Constants
|
|||||||
class CShaderConstantFloat : public CShaderConstant
|
class CShaderConstantFloat : public CShaderConstant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CShaderConstantFloat (float value);
|
explicit CShaderConstantFloat (float value);
|
||||||
|
|
||||||
float* getValue ();
|
float* getValue ();
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ namespace WallpaperEngine::Core::Objects::Effects::Constants
|
|||||||
class CShaderConstantInteger : public CShaderConstant
|
class CShaderConstantInteger : public CShaderConstant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CShaderConstantInteger (int32_t value);
|
explicit CShaderConstantInteger (int32_t value);
|
||||||
|
|
||||||
int32_t* getValue ();
|
int32_t* getValue ();
|
||||||
|
|
||||||
|
@ -14,4 +14,4 @@ glm::vec2* CShaderConstantVector2::getValue ()
|
|||||||
return &this->m_value;
|
return &this->m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CShaderConstantVector3::Type = "vec2";
|
const std::string CShaderConstantVector2::Type = "vec2";
|
@ -3,6 +3,7 @@
|
|||||||
#include "CShaderConstant.h"
|
#include "CShaderConstant.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <glm/vec2.hpp>
|
||||||
#include <glm/vec3.hpp>
|
#include <glm/vec3.hpp>
|
||||||
|
|
||||||
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
@ -10,7 +11,7 @@ namespace WallpaperEngine::Core::Objects::Effects::Constants
|
|||||||
class CShaderConstantVector2 : public CShaderConstant
|
class CShaderConstantVector2 : public CShaderConstant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CShaderConstantVector2 (glm::vec2 value);
|
explicit CShaderConstantVector2 (glm::vec2 value);
|
||||||
|
|
||||||
glm::vec2* getValue ();
|
glm::vec2* getValue ();
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ namespace WallpaperEngine::Core::Objects::Effects::Constants
|
|||||||
class CShaderConstantVector3 : public CShaderConstant
|
class CShaderConstantVector3 : public CShaderConstant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CShaderConstantVector3 (glm::vec3 value);
|
explicit CShaderConstantVector3 (glm::vec3 value);
|
||||||
|
|
||||||
glm::vec3* getValue ();
|
glm::vec3* getValue ();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "CMaterial.h"
|
#include "CMaterial.h"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||||
|
|
||||||
@ -9,9 +10,9 @@ using namespace WallpaperEngine::Assets;
|
|||||||
using namespace WallpaperEngine::Core::Objects;
|
using namespace WallpaperEngine::Core::Objects;
|
||||||
using namespace WallpaperEngine::Core::Objects::Images;
|
using namespace WallpaperEngine::Core::Objects::Images;
|
||||||
|
|
||||||
CMaterial::CMaterial (const std::string& name) :
|
CMaterial::CMaterial (std::string name) :
|
||||||
m_target (""),
|
m_target (),
|
||||||
m_name (name)
|
m_name (std::move(name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ CMaterial* CMaterial::fromFile (const std::string& filename, const std::string&
|
|||||||
|
|
||||||
CMaterial* CMaterial::fromJSON (const std::string& name, json data, const std::string& target)
|
CMaterial* CMaterial::fromJSON (const std::string& name, json data, const std::string& target)
|
||||||
{
|
{
|
||||||
CMaterial* material = fromJSON (name, data);
|
CMaterial* material = fromJSON (name, std::move(data));
|
||||||
|
|
||||||
material->setTarget (target);
|
material->setTarget (target);
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ CMaterial* CMaterial::fromJSON (const std::string& name, json data)
|
|||||||
{
|
{
|
||||||
auto passes_it = jsonFindRequired (data, "passes", "Material must have at least one pass");
|
auto passes_it = jsonFindRequired (data, "passes", "Material must have at least one pass");
|
||||||
|
|
||||||
CMaterial* material = new CMaterial (name);
|
auto* material = new CMaterial (name);
|
||||||
|
|
||||||
for (const auto& cur : (*passes_it))
|
for (const auto& cur : (*passes_it))
|
||||||
material->insertPass (Materials::CPass::fromJSON (cur));
|
material->insertPass (Materials::CPass::fromJSON (cur));
|
||||||
@ -83,7 +84,7 @@ const std::string& CMaterial::getName () const
|
|||||||
return this->m_name;
|
return this->m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CMaterial::hasTarget () const
|
bool CMaterial::hasTarget () const
|
||||||
{
|
{
|
||||||
return this->m_target.empty () == false;
|
return !this->m_target.empty ();
|
||||||
}
|
}
|
@ -25,10 +25,10 @@ namespace WallpaperEngine::Core::Objects::Images
|
|||||||
const std::vector <Materials::CPass*>& getPasses () const;
|
const std::vector <Materials::CPass*>& getPasses () const;
|
||||||
const std::map <int, Effects::CBind*>& getTextureBinds () const;
|
const std::map <int, Effects::CBind*>& getTextureBinds () const;
|
||||||
const std::string& getTarget () const;
|
const std::string& getTarget () const;
|
||||||
const bool hasTarget () const;
|
bool hasTarget () const;
|
||||||
const std::string& getName () const;
|
const std::string& getName () const;
|
||||||
protected:
|
protected:
|
||||||
CMaterial (const std::string& name);
|
explicit CMaterial (std::string name);
|
||||||
|
|
||||||
void setTarget (const std::string& target);
|
void setTarget (const std::string& target);
|
||||||
private:
|
private:
|
||||||
@ -37,4 +37,4 @@ namespace WallpaperEngine::Core::Objects::Images
|
|||||||
std::string m_target;
|
std::string m_target;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "CPass.h"
|
#include "CPass.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
using namespace WallpaperEngine::Core::Objects::Images::Materials;
|
using namespace WallpaperEngine::Core::Objects::Images::Materials;
|
||||||
|
|
||||||
@ -27,11 +29,11 @@ CPass* CPass::fromJSON (json data)
|
|||||||
if (textures_it != data.end ())
|
if (textures_it != data.end ())
|
||||||
{
|
{
|
||||||
// TODO: FETCH THIS FROM CImage TO MAKE IT COMPATIBLE WITH OLDER WALLPAPERS
|
// TODO: FETCH THIS FROM CImage TO MAKE IT COMPATIBLE WITH OLDER WALLPAPERS
|
||||||
if ((*textures_it).is_array () == false)
|
if (!(*textures_it).is_array ())
|
||||||
sLog.exception ("Material's textures must be a list");
|
sLog.exception ("Material's textures must be a list");
|
||||||
}
|
}
|
||||||
|
|
||||||
CPass* pass = new CPass (
|
auto* pass = new CPass (
|
||||||
blending,
|
blending,
|
||||||
cullmode,
|
cullmode,
|
||||||
*depthtest_it,
|
*depthtest_it,
|
||||||
@ -40,28 +42,15 @@ CPass* CPass::fromJSON (json data)
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (textures_it != data.end ())
|
if (textures_it != data.end ())
|
||||||
{
|
|
||||||
for (const auto& cur : (*textures_it))
|
for (const auto& cur : (*textures_it))
|
||||||
{
|
pass->insertTexture (cur.is_null () ? "" : cur);
|
||||||
if (cur.is_null () == true)
|
|
||||||
{
|
|
||||||
pass->insertTexture ("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pass->insertTexture (cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (combos_it != data.end ())
|
if (combos_it != data.end ())
|
||||||
{
|
{
|
||||||
for (const auto& cur : (*combos_it).items ())
|
for (const auto& cur : (*combos_it).items ())
|
||||||
{
|
{
|
||||||
std::string name = cur.key ();
|
if (cur.value ().is_number_integer ())
|
||||||
|
pass->insertCombo (cur.key (), cur.value ());
|
||||||
if (cur.value ().is_number_integer () == true)
|
|
||||||
pass->insertCombo (name, cur.value ());
|
|
||||||
else
|
else
|
||||||
sLog.exception ("unexpected non-integer combo on pass");
|
sLog.exception ("unexpected non-integer combo on pass");
|
||||||
}
|
}
|
||||||
@ -128,7 +117,7 @@ const std::string& CPass::getDepthWrite ()const
|
|||||||
return this->m_depthwrite;
|
return this->m_depthwrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPass::setBlendingMode (std::string mode)
|
void CPass::setBlendingMode (const std::string& mode)
|
||||||
{
|
{
|
||||||
this->m_blending = mode;
|
this->m_blending = mode;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
namespace WallpaperEngine::Core::Objects
|
namespace WallpaperEngine::Core::Objects
|
||||||
{
|
{
|
||||||
class CEffect;
|
class CEffect;
|
||||||
};
|
}
|
||||||
|
|
||||||
namespace WallpaperEngine::Core::Objects::Images::Materials
|
namespace WallpaperEngine::Core::Objects::Images::Materials
|
||||||
{
|
{
|
||||||
@ -28,7 +28,7 @@ namespace WallpaperEngine::Core::Objects::Images::Materials
|
|||||||
const std::string& getCullingMode () const;
|
const std::string& getCullingMode () const;
|
||||||
const std::string& getDepthTest () const;
|
const std::string& getDepthTest () const;
|
||||||
const std::string& getDepthWrite () const;
|
const std::string& getDepthWrite () const;
|
||||||
void setBlendingMode (std::string mode);
|
void setBlendingMode (const std::string& mode);
|
||||||
|
|
||||||
void insertCombo (const std::string& name, int value);
|
void insertCombo (const std::string& name, int value);
|
||||||
void insertConstant (const std::string& name, Effects::Constants::CShaderConstant* constant);
|
void insertConstant (const std::string& name, Effects::Constants::CShaderConstant* constant);
|
||||||
|
@ -8,17 +8,13 @@ CControlPoint* CControlPoint::fromJSON (json data)
|
|||||||
auto id_it = jsonFindRequired (data, "id", "Particle's control point must have id");
|
auto id_it = jsonFindRequired (data, "id", "Particle's control point must have id");
|
||||||
auto offset_it = data.find ("offset");
|
auto offset_it = data.find ("offset");
|
||||||
|
|
||||||
CControlPoint* controlpoint = new CControlPoint (*id_it, 0);
|
auto* controlpoint = new CControlPoint (*id_it, 0);
|
||||||
|
|
||||||
if (offset_it != data.end ())
|
if (offset_it != data.end ())
|
||||||
{
|
|
||||||
controlpoint->setOffset (WallpaperEngine::Core::aToVector3 (*offset_it));
|
controlpoint->setOffset (WallpaperEngine::Core::aToVector3 (*offset_it));
|
||||||
}
|
|
||||||
|
|
||||||
if (flags_it != data.end ())
|
if (flags_it != data.end ())
|
||||||
{
|
|
||||||
controlpoint->setFlags (*flags_it);
|
controlpoint->setFlags (*flags_it);
|
||||||
}
|
|
||||||
|
|
||||||
return controlpoint;
|
return controlpoint;
|
||||||
}
|
}
|
||||||
@ -39,13 +35,17 @@ void CControlPoint::setFlags (uint32_t flags)
|
|||||||
{
|
{
|
||||||
this->m_flags = flags;
|
this->m_flags = flags;
|
||||||
}
|
}
|
||||||
|
uint32_t CControlPoint::getId () const
|
||||||
|
{
|
||||||
|
return this->m_id;
|
||||||
|
}
|
||||||
|
|
||||||
const glm::vec3& CControlPoint::getOffset () const
|
const glm::vec3& CControlPoint::getOffset () const
|
||||||
{
|
{
|
||||||
return this->m_offset;
|
return this->m_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CControlPoint::getFlags () const
|
uint32_t CControlPoint::getFlags () const
|
||||||
{
|
{
|
||||||
return this->m_flags;
|
return this->m_flags;
|
||||||
}
|
}
|
@ -11,10 +11,11 @@ namespace WallpaperEngine::Core::Objects::Particles
|
|||||||
public:
|
public:
|
||||||
static CControlPoint* fromJSON (json data);
|
static CControlPoint* fromJSON (json data);
|
||||||
|
|
||||||
|
uint32_t getId () const;
|
||||||
const glm::vec3& getOffset () const;
|
const glm::vec3& getOffset () const;
|
||||||
const uint32_t getFlags () const;
|
uint32_t getFlags () const;
|
||||||
protected:
|
protected:
|
||||||
CControlPoint (uint32_t id, uint32_t flags = 0);
|
explicit CControlPoint (uint32_t id, uint32_t flags = 0);
|
||||||
|
|
||||||
void setOffset (const glm::vec3& offset);
|
void setOffset (const glm::vec3& offset);
|
||||||
void setFlags (uint32_t flags);
|
void setFlags (uint32_t flags);
|
||||||
@ -23,4 +24,4 @@ namespace WallpaperEngine::Core::Objects::Particles
|
|||||||
uint32_t m_flags;
|
uint32_t m_flags;
|
||||||
glm::vec3 m_offset;
|
glm::vec3 m_offset;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -41,6 +41,10 @@ CEmitter::CEmitter (
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t CEmitter::getId () const
|
||||||
|
{
|
||||||
|
return this->m_id;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& CEmitter::getName () const
|
const std::string& CEmitter::getName () const
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@ namespace WallpaperEngine::Core::Objects::Particles
|
|||||||
public:
|
public:
|
||||||
static CEmitter* fromJSON (json data);
|
static CEmitter* fromJSON (json data);
|
||||||
|
|
||||||
|
uint32_t getId () const;
|
||||||
const std::string& getName () const;
|
const std::string& getName () const;
|
||||||
const uint32_t getDistanceMax () const;
|
const uint32_t getDistanceMax () const;
|
||||||
const uint32_t getDistanceMin () const;
|
const uint32_t getDistanceMin () const;
|
||||||
@ -36,4 +37,4 @@ namespace WallpaperEngine::Core::Objects::Particles
|
|||||||
glm::vec3 m_origin;
|
glm::vec3 m_origin;
|
||||||
double m_rate;
|
double m_rate;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -69,7 +69,7 @@ const std::string& CInitializer::getName () const
|
|||||||
return this->m_name;
|
return this->m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CInitializer::getId () const
|
uint32_t CInitializer::getId () const
|
||||||
{
|
{
|
||||||
return this->m_id;
|
return this->m_id;
|
||||||
}
|
}
|
@ -12,11 +12,11 @@ namespace WallpaperEngine::Core::Objects::Particles
|
|||||||
static CInitializer* fromJSON (json data);
|
static CInitializer* fromJSON (json data);
|
||||||
|
|
||||||
const std::string& getName () const;
|
const std::string& getName () const;
|
||||||
const uint32_t getId () const;
|
uint32_t getId () const;
|
||||||
protected:
|
protected:
|
||||||
CInitializer (uint32_t id, std::string name);
|
CInitializer (uint32_t id, std::string name);
|
||||||
private:
|
private:
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -17,12 +17,12 @@ CAlphaRandom::CAlphaRandom (uint32_t id, double min, double max) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const double CAlphaRandom::getMinimum () const
|
double CAlphaRandom::getMinimum () const
|
||||||
{
|
{
|
||||||
return this->m_min;
|
return this->m_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double CAlphaRandom::getMaximum () const
|
double CAlphaRandom::getMaximum () const
|
||||||
{
|
{
|
||||||
return this->m_max;
|
return this->m_max;
|
||||||
}
|
}
|
@ -9,8 +9,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
class CAlphaRandom : CInitializer
|
class CAlphaRandom : CInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const double getMinimum () const;
|
double getMinimum () const;
|
||||||
const double getMaximum () const;
|
double getMaximum () const;
|
||||||
protected:
|
protected:
|
||||||
friend class CInitializer;
|
friend class CInitializer;
|
||||||
|
|
||||||
@ -21,4 +21,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
double m_max;
|
double m_max;
|
||||||
double m_min;
|
double m_min;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -21,4 +21,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
glm::vec3 m_max;
|
glm::vec3 m_max;
|
||||||
glm::vec3 m_min;
|
glm::vec3 m_min;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -21,4 +21,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
glm::ivec3 m_max;
|
glm::ivec3 m_max;
|
||||||
glm::ivec3 m_min;
|
glm::ivec3 m_min;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -18,12 +18,12 @@ CLifeTimeRandom::CLifeTimeRandom (uint32_t id, uint32_t min, uint32_t max) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CLifeTimeRandom::getMinimum () const
|
uint32_t CLifeTimeRandom::getMinimum () const
|
||||||
{
|
{
|
||||||
return this->m_min;
|
return this->m_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CLifeTimeRandom::getMaximum () const
|
uint32_t CLifeTimeRandom::getMaximum () const
|
||||||
{
|
{
|
||||||
return this->m_max;
|
return this->m_max;
|
||||||
}
|
}
|
@ -9,8 +9,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
class CLifeTimeRandom : CInitializer
|
class CLifeTimeRandom : CInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const uint32_t getMinimum () const;
|
uint32_t getMinimum () const;
|
||||||
const uint32_t getMaximum () const;
|
uint32_t getMaximum () const;
|
||||||
protected:
|
protected:
|
||||||
friend class CInitializer;
|
friend class CInitializer;
|
||||||
|
|
||||||
@ -21,4 +21,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
uint32_t m_max;
|
uint32_t m_max;
|
||||||
uint32_t m_min;
|
uint32_t m_min;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -60,42 +60,42 @@ CRotationRandom::CRotationRandom (
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const glm::vec3 CRotationRandom::getMinimumVector () const
|
glm::vec3 CRotationRandom::getMinimumVector () const
|
||||||
{
|
{
|
||||||
return this->m_minVector;
|
return this->m_minVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
const glm::vec3 CRotationRandom::getMaximumVector () const
|
glm::vec3 CRotationRandom::getMaximumVector () const
|
||||||
{
|
{
|
||||||
return this->m_maxVector;
|
return this->m_maxVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double CRotationRandom::getMinimumNumber () const
|
double CRotationRandom::getMinimumNumber () const
|
||||||
{
|
{
|
||||||
return this->m_minNumber;
|
return this->m_minNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double CRotationRandom::getMaximumNumber () const
|
double CRotationRandom::getMaximumNumber () const
|
||||||
{
|
{
|
||||||
return this->m_maxNumber;
|
return this->m_maxNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CRotationRandom::isMinimumVector () const
|
bool CRotationRandom::isMinimumVector () const
|
||||||
{
|
{
|
||||||
return this->m_isMinimumVector == true;
|
return this->m_isMinimumVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CRotationRandom::isMinimumNumber () const
|
bool CRotationRandom::isMinimumNumber () const
|
||||||
{
|
{
|
||||||
return this->m_isMinimumVector == false;
|
return !this->m_isMinimumVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CRotationRandom::isMaximumVector () const
|
bool CRotationRandom::isMaximumVector () const
|
||||||
{
|
{
|
||||||
return this->m_isMaximumVector == true;
|
return this->m_isMaximumVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CRotationRandom::isMaximumNumber () const
|
bool CRotationRandom::isMaximumNumber () const
|
||||||
{
|
{
|
||||||
return this->m_isMaximumVector == false;
|
return !this->m_isMaximumVector;
|
||||||
}
|
}
|
@ -9,15 +9,15 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
class CRotationRandom : CInitializer
|
class CRotationRandom : CInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const glm::vec3 getMinimumVector () const;
|
glm::vec3 getMinimumVector () const;
|
||||||
const glm::vec3 getMaximumVector () const;
|
glm::vec3 getMaximumVector () const;
|
||||||
const double getMinimumNumber () const;
|
double getMinimumNumber () const;
|
||||||
const double getMaximumNumber () const;
|
double getMaximumNumber () const;
|
||||||
|
|
||||||
const bool isMinimumVector () const;
|
bool isMinimumVector () const;
|
||||||
const bool isMinimumNumber () const;
|
bool isMinimumNumber () const;
|
||||||
const bool isMaximumVector () const;
|
bool isMaximumVector () const;
|
||||||
const bool isMaximumNumber () const;
|
bool isMaximumNumber () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class CInitializer;
|
friend class CInitializer;
|
||||||
@ -42,4 +42,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
bool m_isMinimumVector;
|
bool m_isMinimumVector;
|
||||||
bool m_isMaximumVector;
|
bool m_isMaximumVector;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -17,12 +17,12 @@ CSizeRandom::CSizeRandom (uint32_t id, uint32_t min, uint32_t max) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CSizeRandom::getMinimum () const
|
uint32_t CSizeRandom::getMinimum () const
|
||||||
{
|
{
|
||||||
return this->m_min;
|
return this->m_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t CSizeRandom::getMaximum () const
|
uint32_t CSizeRandom::getMaximum () const
|
||||||
{
|
{
|
||||||
return this->m_max;
|
return this->m_max;
|
||||||
}
|
}
|
@ -9,8 +9,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
class CSizeRandom : CInitializer
|
class CSizeRandom : CInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const uint32_t getMinimum () const;
|
uint32_t getMinimum () const;
|
||||||
const uint32_t getMaximum () const;
|
uint32_t getMaximum () const;
|
||||||
protected:
|
protected:
|
||||||
friend class CInitializer;
|
friend class CInitializer;
|
||||||
|
|
||||||
@ -21,4 +21,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
uint32_t m_max;
|
uint32_t m_max;
|
||||||
uint32_t m_min;
|
uint32_t m_min;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -29,4 +29,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
uint32_t m_speedmin;
|
uint32_t m_speedmin;
|
||||||
uint32_t m_speedmax;
|
uint32_t m_speedmax;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -21,4 +21,4 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
|||||||
glm::vec3 m_max;
|
glm::vec3 m_max;
|
||||||
glm::vec3 m_min;
|
glm::vec3 m_min;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -8,16 +8,12 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
CPropertyBoolean* CPropertyBoolean::fromJSON (json data, const std::string& name)
|
CPropertyBoolean* CPropertyBoolean::fromJSON (json data, const std::string& name)
|
||||||
{
|
{
|
||||||
json::const_iterator value = data.find ("value");
|
json::const_iterator value = data.find ("value");
|
||||||
std::string text = jsonFindDefault <std::string> (data, "text", "");
|
auto text = jsonFindDefault <std::string> (data, "text", "");
|
||||||
|
|
||||||
return new CPropertyBoolean (
|
return new CPropertyBoolean (*value, name, text);
|
||||||
*value,
|
|
||||||
name,
|
|
||||||
text
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPropertyBoolean::getValue ()
|
bool CPropertyBoolean::getValue () const
|
||||||
{
|
{
|
||||||
return this->m_value;
|
return this->m_value;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace WallpaperEngine::Core::Projects
|
|||||||
public:
|
public:
|
||||||
static CPropertyBoolean* fromJSON (json data, const std::string& name);
|
static CPropertyBoolean* fromJSON (json data, const std::string& name);
|
||||||
|
|
||||||
bool getValue ();
|
bool getValue () const;
|
||||||
std::string dump () const override;
|
std::string dump () const override;
|
||||||
void update (const std::string& value) override;
|
void update (const std::string& value) override;
|
||||||
|
|
||||||
@ -22,4 +22,4 @@ namespace WallpaperEngine::Core::Projects
|
|||||||
|
|
||||||
bool m_value;
|
bool m_value;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -29,13 +29,9 @@ glm::vec3 ParseColor (std::string value)
|
|||||||
CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name)
|
CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name)
|
||||||
{
|
{
|
||||||
std::string value = *jsonFindRequired (data, "value", "Color property must have a value");
|
std::string value = *jsonFindRequired (data, "value", "Color property must have a value");
|
||||||
std::string text = jsonFindDefault <std::string> (data, "text", "");
|
auto text = jsonFindDefault <std::string> (data, "text", "");
|
||||||
|
|
||||||
return new CPropertyColor (
|
return new CPropertyColor (ParseColor (value), name, text);
|
||||||
ParseColor (value),
|
|
||||||
name,
|
|
||||||
text
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const glm::vec3& CPropertyColor::getValue () const
|
const glm::vec3& CPropertyColor::getValue () const
|
||||||
|
@ -24,4 +24,4 @@ namespace WallpaperEngine::Core::Projects
|
|||||||
|
|
||||||
glm::vec3 m_color;
|
glm::vec3 m_color;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -11,29 +11,29 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
CPropertyCombo* CPropertyCombo::fromJSON (json data, const std::string& name)
|
CPropertyCombo* CPropertyCombo::fromJSON (json data, const std::string& name)
|
||||||
{
|
{
|
||||||
auto value = data.find ("value");
|
auto value = data.find ("value");
|
||||||
std::string text = jsonFindDefault <std::string> (data, "text", "");
|
auto text = jsonFindDefault <std::string> (data, "text", "");
|
||||||
auto options = jsonFindRequired (data, "options", "Options for a property combo is required");
|
auto options = jsonFindRequired (data, "options", "Options for a property combo is required");
|
||||||
|
|
||||||
CPropertyCombo* combo = new CPropertyCombo (
|
auto* combo = new CPropertyCombo (
|
||||||
name,
|
name,
|
||||||
text,
|
text,
|
||||||
*value
|
*value
|
||||||
);
|
);
|
||||||
|
|
||||||
if (options->is_array () == false)
|
if (!options->is_array ())
|
||||||
sLog.exception ("Property combo options should be an array");
|
sLog.exception ("Property combo options should be an array");
|
||||||
|
|
||||||
for (auto& cur : (*options))
|
for (auto& cur : (*options))
|
||||||
{
|
{
|
||||||
// TODO: PROPERLY REPORT THESE ISSUES
|
// TODO: PROPERLY REPORT THESE ISSUES
|
||||||
if (cur.is_object () == false)
|
if (!cur.is_object ())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check for label and value to ensure they're there
|
// check for label and value to ensure they're there
|
||||||
auto label = jsonFindRequired (cur, "label", "Label is required for a property combo option");
|
auto label = jsonFindRequired (cur, "label", "Label is required for a property combo option");
|
||||||
auto value = jsonFindRequired (cur, "value", "Value is required for a property combo option");
|
auto propertyValue = jsonFindRequired (cur, "value", "Value is required for a property combo option");
|
||||||
|
|
||||||
combo->addValue (*label, *value);
|
combo->addValue (*label, *propertyValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return combo;
|
return combo;
|
||||||
@ -61,9 +61,7 @@ std::string CPropertyCombo::dump () const
|
|||||||
<< "\t\t" << "Posible values:" << std::endl;
|
<< "\t\t" << "Posible values:" << std::endl;
|
||||||
|
|
||||||
for (auto cur : this->m_values)
|
for (auto cur : this->m_values)
|
||||||
{
|
|
||||||
ss << "\t\t" << cur->label << " -> " << cur->value << std::endl;
|
ss << "\t\t" << cur->label << " -> " << cur->value << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
@ -81,7 +79,7 @@ void CPropertyCombo::update (const std::string& value)
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == false)
|
if (!found)
|
||||||
sLog.exception ("Assigning invalid value to property ", this->m_name);
|
sLog.exception ("Assigning invalid value to property ", this->m_name);
|
||||||
|
|
||||||
this->m_defaultValue = value;
|
this->m_defaultValue = value;
|
||||||
@ -90,7 +88,7 @@ void CPropertyCombo::update (const std::string& value)
|
|||||||
|
|
||||||
void CPropertyCombo::addValue (std::string label, std::string value)
|
void CPropertyCombo::addValue (std::string label, std::string value)
|
||||||
{
|
{
|
||||||
CPropertyComboValue* prop = new CPropertyComboValue;
|
auto* prop = new CPropertyComboValue;
|
||||||
|
|
||||||
prop->label = std::move (label);
|
prop->label = std::move (label);
|
||||||
prop->value = std::move (value);
|
prop->value = std::move (value);
|
||||||
|
@ -32,4 +32,4 @@ namespace WallpaperEngine::Core::Projects
|
|||||||
std::vector <CPropertyComboValue*> m_values;
|
std::vector <CPropertyComboValue*> m_values;
|
||||||
std::string m_defaultValue;
|
std::string m_defaultValue;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -7,19 +7,12 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
CPropertySlider* CPropertySlider::fromJSON (json data, const std::string& name)
|
CPropertySlider* CPropertySlider::fromJSON (json data, const std::string& name)
|
||||||
{
|
{
|
||||||
auto value = data.find ("value");
|
auto value = data.find ("value");
|
||||||
std::string text = jsonFindDefault <std::string> (data, "text", "");
|
auto text = jsonFindDefault <std::string> (data, "text", "");
|
||||||
auto min = jsonFindDefault(data, "min", 0.0);
|
auto min = jsonFindDefault(data, "min", 0.0);
|
||||||
auto max = jsonFindDefault (data, "max", 0.0);
|
auto max = jsonFindDefault (data, "max", 0.0);
|
||||||
auto step = jsonFindDefault (data, "step", 0.0);
|
auto step = jsonFindDefault (data, "step", 0.0);
|
||||||
|
|
||||||
return new CPropertySlider (
|
return new CPropertySlider (*value, name, text, min, max, step);
|
||||||
*value,
|
|
||||||
name,
|
|
||||||
text,
|
|
||||||
min,
|
|
||||||
max,
|
|
||||||
step
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const double& CPropertySlider::getValue () const
|
const double& CPropertySlider::getValue () const
|
||||||
@ -59,7 +52,7 @@ std::string CPropertySlider::dump () const
|
|||||||
|
|
||||||
void CPropertySlider::update (const std::string& value)
|
void CPropertySlider::update (const std::string& value)
|
||||||
{
|
{
|
||||||
double newValue = atof (value.c_str ());
|
double newValue = strtod (value.c_str (), nullptr);
|
||||||
|
|
||||||
if (newValue < this->m_min || newValue > this->m_max)
|
if (newValue < this->m_min || newValue > this->m_max)
|
||||||
sLog.exception ("Slider value (", newValue, ") is out of range (", this->m_min, ",", this->m_max, ")");
|
sLog.exception ("Slider value (", newValue, ") is out of range (", this->m_min, ",", this->m_max, ")");
|
||||||
|
@ -30,4 +30,4 @@ namespace WallpaperEngine::Core::Projects
|
|||||||
double m_max;
|
double m_max;
|
||||||
double m_step;
|
double m_step;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -18,4 +18,4 @@ namespace WallpaperEngine::Core::Projects
|
|||||||
private:
|
private:
|
||||||
CPropertyText (const std::string& name, const std::string& text);
|
CPropertyText (const std::string& name, const std::string& text);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -21,4 +21,4 @@ namespace WallpaperEngine::Core::Scenes
|
|||||||
glm::vec3 m_eye;
|
glm::vec3 m_eye;
|
||||||
glm::vec3 m_up;
|
glm::vec3 m_up;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -3,13 +3,16 @@
|
|||||||
using namespace WallpaperEngine::Core::Scenes;
|
using namespace WallpaperEngine::Core::Scenes;
|
||||||
|
|
||||||
CProjection::CProjection (uint32_t width, uint32_t height) :
|
CProjection::CProjection (uint32_t width, uint32_t height) :
|
||||||
|
m_isAuto (false),
|
||||||
m_width (width),
|
m_width (width),
|
||||||
m_height (height)
|
m_height (height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CProjection::CProjection (bool isAuto) :
|
CProjection::CProjection (bool isAuto) :
|
||||||
m_isAuto (isAuto)
|
m_isAuto (isAuto),
|
||||||
|
m_width (0),
|
||||||
|
m_height (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +26,7 @@ const uint32_t& CProjection::getHeight () const
|
|||||||
return this->m_height;
|
return this->m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CProjection::isAuto () const
|
bool CProjection::isAuto () const
|
||||||
{
|
{
|
||||||
return this->m_isAuto;
|
return this->m_isAuto;
|
||||||
}
|
}
|
||||||
@ -46,7 +49,7 @@ CProjection* CProjection::fromJSON (json data)
|
|||||||
auto height_it = jsonFindRequired (data, "height", "Projection must have height");
|
auto height_it = jsonFindRequired (data, "height", "Projection must have height");
|
||||||
|
|
||||||
// TODO: PROPERLY SUPPORT AUTO-DETECTING SIZE
|
// TODO: PROPERLY SUPPORT AUTO-DETECTING SIZE
|
||||||
if (auto_it == true)
|
if (auto_it)
|
||||||
return new CProjection (true);
|
return new CProjection (true);
|
||||||
else
|
else
|
||||||
return new CProjection (
|
return new CProjection (
|
||||||
|
@ -13,7 +13,7 @@ namespace WallpaperEngine::Core::Scenes
|
|||||||
|
|
||||||
const uint32_t& getWidth () const;
|
const uint32_t& getWidth () const;
|
||||||
const uint32_t& getHeight () const;
|
const uint32_t& getHeight () const;
|
||||||
const bool isAuto () const;
|
bool isAuto () const;
|
||||||
|
|
||||||
void setWidth (uint32_t width);
|
void setWidth (uint32_t width);
|
||||||
void setHeight (uint32_t height);
|
void setHeight (uint32_t height);
|
||||||
@ -26,4 +26,4 @@ namespace WallpaperEngine::Core::Scenes
|
|||||||
uint32_t m_height;
|
uint32_t m_height;
|
||||||
bool m_isAuto;
|
bool m_isAuto;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -26,15 +26,15 @@ CUserSettingBoolean* CUserSettingBoolean::fromJSON (nlohmann::json& data)
|
|||||||
{
|
{
|
||||||
bool hasCondition = false;
|
bool hasCondition = false;
|
||||||
bool hasSource = false;
|
bool hasSource = false;
|
||||||
bool defaultValue = false;
|
bool defaultValue;
|
||||||
std::string source;
|
std::string source;
|
||||||
std::string expectedValue;
|
std::string expectedValue;
|
||||||
|
|
||||||
if (data.is_object () == true)
|
if (data.is_object ())
|
||||||
{
|
{
|
||||||
hasSource = true;
|
hasSource = true;
|
||||||
auto userIt = data.find ("user");
|
auto userIt = data.find ("user");
|
||||||
defaultValue = jsonFindDefault (data, "value", false); // is this default value right?
|
defaultValue = jsonFindDefault (data, "value", true); // is this default value right?
|
||||||
|
|
||||||
if (userIt != data.end ())
|
if (userIt != data.end ())
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ CUserSettingBoolean* CUserSettingBoolean::fromJSON (nlohmann::json& data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (data.is_boolean () == false)
|
if (!data.is_boolean ())
|
||||||
sLog.error ("Expected boolean value on user setting");
|
sLog.error ("Expected boolean value on user setting");
|
||||||
|
|
||||||
defaultValue = data.get<bool> ();
|
defaultValue = data.get<bool> ();
|
||||||
@ -70,14 +70,14 @@ CUserSettingBoolean* CUserSettingBoolean::fromScalar (bool value)
|
|||||||
return new CUserSettingBoolean (false, false, value, "", "");
|
return new CUserSettingBoolean (false, false, value, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUserSettingBoolean::getDefaultValue ()
|
bool CUserSettingBoolean::getDefaultValue () const
|
||||||
{
|
{
|
||||||
return this->m_default;
|
return this->m_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUserSettingBoolean::processValue (const std::vector<Projects::CProperty*>& properties)
|
bool CUserSettingBoolean::processValue (const std::vector<Projects::CProperty*>& properties)
|
||||||
{
|
{
|
||||||
if (this->m_hasSource == false && this->m_hasCondition == false)
|
if (!this->m_hasSource && !this->m_hasCondition)
|
||||||
return this->getDefaultValue ();
|
return this->getDefaultValue ();
|
||||||
|
|
||||||
for (auto cur : properties)
|
for (auto cur : properties)
|
||||||
@ -85,7 +85,7 @@ bool CUserSettingBoolean::processValue (const std::vector<Projects::CProperty*>&
|
|||||||
if (cur->getName () != this->m_source)
|
if (cur->getName () != this->m_source)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this->m_hasCondition == false)
|
if (!this->m_hasCondition)
|
||||||
{
|
{
|
||||||
if (cur->is <CPropertyBoolean> ())
|
if (cur->is <CPropertyBoolean> ())
|
||||||
return cur->as <CPropertyBoolean> ()->getValue ();
|
return cur->as <CPropertyBoolean> ()->getValue ();
|
||||||
|
@ -19,7 +19,7 @@ namespace WallpaperEngine::Core::UserSettings
|
|||||||
static std::string Type;
|
static std::string Type;
|
||||||
|
|
||||||
bool processValue (const std::vector<Projects::CProperty*>& properties);
|
bool processValue (const std::vector<Projects::CProperty*>& properties);
|
||||||
bool getDefaultValue ();
|
bool getDefaultValue () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingBoolean (bool hasCondition, bool hasSource, bool defaultValue, std::string source, std::string expectedValue);
|
CUserSettingBoolean (bool hasCondition, bool hasSource, bool defaultValue, std::string source, std::string expectedValue);
|
||||||
|
@ -21,13 +21,13 @@ CUserSettingFloat::CUserSettingFloat (bool hasCondition, bool hasSource, double
|
|||||||
|
|
||||||
CUserSettingFloat* CUserSettingFloat::fromJSON (nlohmann::json& data)
|
CUserSettingFloat* CUserSettingFloat::fromJSON (nlohmann::json& data)
|
||||||
{
|
{
|
||||||
bool hasCondition = false;
|
double defaultValue;
|
||||||
bool hasSource = false;
|
|
||||||
double defaultValue = false;
|
|
||||||
std::string source;
|
std::string source;
|
||||||
std::string expectedValue;
|
std::string expectedValue;
|
||||||
|
bool hasCondition = false;
|
||||||
|
bool hasSource = false;
|
||||||
|
|
||||||
if (data.is_object () == true)
|
if (data.is_object ())
|
||||||
{
|
{
|
||||||
hasSource = true;
|
hasSource = true;
|
||||||
auto userIt = data.find ("user");
|
auto userIt = data.find ("user");
|
||||||
@ -53,7 +53,7 @@ CUserSettingFloat* CUserSettingFloat::fromJSON (nlohmann::json& data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (data.is_number () == false)
|
if (!data.is_number ())
|
||||||
sLog.exception ("Expected numeric value on user settings");
|
sLog.exception ("Expected numeric value on user settings");
|
||||||
|
|
||||||
defaultValue = data.get<double> ();
|
defaultValue = data.get<double> ();
|
||||||
@ -67,14 +67,14 @@ CUserSettingFloat* CUserSettingFloat::fromScalar (double value)
|
|||||||
return new CUserSettingFloat (false, false, value, "", "");
|
return new CUserSettingFloat (false, false, value, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
double CUserSettingFloat::getDefaultValue ()
|
double CUserSettingFloat::getDefaultValue () const
|
||||||
{
|
{
|
||||||
return this->m_default;
|
return this->m_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
double CUserSettingFloat::processValue (const std::vector<Projects::CProperty*>& properties)
|
double CUserSettingFloat::processValue (const std::vector<Projects::CProperty*>& properties)
|
||||||
{
|
{
|
||||||
if (this->m_hasSource == false && this->m_hasCondition == false)
|
if (!this->m_hasSource && !this->m_hasCondition)
|
||||||
return this->getDefaultValue ();
|
return this->getDefaultValue ();
|
||||||
|
|
||||||
for (auto cur : properties)
|
for (auto cur : properties)
|
||||||
@ -82,7 +82,7 @@ double CUserSettingFloat::processValue (const std::vector<Projects::CProperty*>&
|
|||||||
if (cur->getName () != this->m_source)
|
if (cur->getName () != this->m_source)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this->m_hasCondition == false)
|
if (!this->m_hasCondition)
|
||||||
{
|
{
|
||||||
if (cur->is <CPropertySlider> ())
|
if (cur->is <CPropertySlider> ())
|
||||||
return cur->as <CPropertySlider> ()->getValue ();
|
return cur->as <CPropertySlider> ()->getValue ();
|
||||||
|
@ -19,7 +19,7 @@ namespace WallpaperEngine::Core::UserSettings
|
|||||||
static std::string Type;
|
static std::string Type;
|
||||||
|
|
||||||
double processValue (const std::vector<Projects::CProperty*>& properties);
|
double processValue (const std::vector<Projects::CProperty*>& properties);
|
||||||
double getDefaultValue ();
|
double getDefaultValue () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingFloat (bool hasCondition, bool hasSource, double defaultValue, std::string source, std::string expectedValue);
|
CUserSettingFloat (bool hasCondition, bool hasSource, double defaultValue, std::string source, std::string expectedValue);
|
||||||
|
@ -13,9 +13,9 @@ namespace WallpaperEngine::Core::UserSettings
|
|||||||
template<class T> bool is () { return this->m_type == T::Type; }
|
template<class T> bool is () { return this->m_type == T::Type; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CUserSettingValue (std::string type);
|
explicit CUserSettingValue (std::string type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_type;
|
std::string m_type;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -28,7 +28,7 @@ CUserSettingVector3* CUserSettingVector3::fromJSON (nlohmann::json& data)
|
|||||||
std::string source;
|
std::string source;
|
||||||
std::string expectedValue;
|
std::string expectedValue;
|
||||||
|
|
||||||
if (data.is_object () == true)
|
if (data.is_object ())
|
||||||
{
|
{
|
||||||
hasSource = true;
|
hasSource = true;
|
||||||
auto userIt = data.find ("user");
|
auto userIt = data.find ("user");
|
||||||
@ -54,7 +54,7 @@ CUserSettingVector3* CUserSettingVector3::fromJSON (nlohmann::json& data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (data.is_string () == false)
|
if (!data.is_string ())
|
||||||
sLog.exception ("Expected vector value on user settings");
|
sLog.exception ("Expected vector value on user settings");
|
||||||
|
|
||||||
defaultValue = WallpaperEngine::Core::aToColorf (data.get <std::string> ().c_str ());
|
defaultValue = WallpaperEngine::Core::aToColorf (data.get <std::string> ().c_str ());
|
||||||
@ -68,14 +68,14 @@ CUserSettingVector3* CUserSettingVector3::fromScalar (glm::vec3 value)
|
|||||||
return new CUserSettingVector3 (false, false, value, "", "");
|
return new CUserSettingVector3 (false, false, value, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 CUserSettingVector3::getDefaultValue ()
|
glm::vec3 CUserSettingVector3::getDefaultValue () const
|
||||||
{
|
{
|
||||||
return this->m_default;
|
return this->m_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 CUserSettingVector3::processValue (const std::vector<Projects::CProperty*>& properties)
|
glm::vec3 CUserSettingVector3::processValue (const std::vector<Projects::CProperty*>& properties)
|
||||||
{
|
{
|
||||||
if (this->m_hasSource == false && this->m_hasCondition == false)
|
if (!this->m_hasSource && !this->m_hasCondition)
|
||||||
return this->getDefaultValue ();
|
return this->getDefaultValue ();
|
||||||
|
|
||||||
for (auto cur : properties)
|
for (auto cur : properties)
|
||||||
@ -83,7 +83,7 @@ glm::vec3 CUserSettingVector3::processValue (const std::vector<Projects::CProper
|
|||||||
if (cur->getName () != this->m_source)
|
if (cur->getName () != this->m_source)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this->m_hasCondition == false)
|
if (!this->m_hasCondition)
|
||||||
{
|
{
|
||||||
if (cur->is <CPropertyColor> ())
|
if (cur->is <CPropertyColor> ())
|
||||||
return cur->as <CPropertyColor> ()->getValue ();
|
return cur->as <CPropertyColor> ()->getValue ();
|
||||||
|
@ -21,7 +21,7 @@ namespace WallpaperEngine::Core::UserSettings
|
|||||||
static std::string Type;
|
static std::string Type;
|
||||||
|
|
||||||
glm::vec3 processValue (const std::vector<Projects::CProperty*>& properties);
|
glm::vec3 processValue (const std::vector<Projects::CProperty*>& properties);
|
||||||
glm::vec3 getDefaultValue ();
|
glm::vec3 getDefaultValue () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingVector3 (bool hasCondition, bool hasSource, glm::vec3 defaultValue, std::string source, std::string expectedValue);
|
CUserSettingVector3 (bool hasCondition, bool hasSource, glm::vec3 defaultValue, std::string source, std::string expectedValue);
|
||||||
|
@ -13,7 +13,7 @@ namespace WallpaperEngine::Input
|
|||||||
class CInputContext
|
class CInputContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CInputContext (Render::Drivers::COpenGLDriver& videoDriver);
|
explicit CInputContext (Render::Drivers::COpenGLDriver& videoDriver);
|
||||||
void update ();
|
void update ();
|
||||||
|
|
||||||
const CMouseInput& getMouseInput () const;
|
const CMouseInput& getMouseInput () const;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Input;
|
using namespace WallpaperEngine::Input;
|
||||||
|
|
||||||
CMouseInput::CMouseInput (GLFWwindow* window) : position(0, 0), m_window (window) {}
|
CMouseInput::CMouseInput (GLFWwindow* window) : position (), m_mousePosition (), m_window (window) {}
|
||||||
|
|
||||||
void CMouseInput::update ()
|
void CMouseInput::update ()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace WallpaperEngine::Input
|
|||||||
class CMouseInput
|
class CMouseInput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMouseInput(GLFWwindow* window);
|
explicit CMouseInput(GLFWwindow* window);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes current mouse position and updates it
|
* Takes current mouse position and updates it
|
||||||
@ -33,5 +33,5 @@ namespace WallpaperEngine::Input
|
|||||||
*/
|
*/
|
||||||
glm::dvec2 m_mousePosition;
|
glm::dvec2 m_mousePosition;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,9 @@ using namespace WallpaperEngine::Render;
|
|||||||
CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
|
CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
|
||||||
m_camera (camera),
|
m_camera (camera),
|
||||||
m_scene (scene),
|
m_scene (scene),
|
||||||
m_isOrthogonal (false)
|
m_isOrthogonal (false),
|
||||||
|
m_projection (),
|
||||||
|
m_lookat ()
|
||||||
{
|
{
|
||||||
// get the lookat position
|
// get the lookat position
|
||||||
// TODO: ENSURE THIS IS ONLY USED WHEN NOT DOING AN ORTOGRAPHIC CAMERA AS IT THROWS OFF POINTS
|
// TODO: ENSURE THIS IS ONLY USED WHEN NOT DOING AN ORTOGRAPHIC CAMERA AS IT THROWS OFF POINTS
|
||||||
@ -17,9 +19,7 @@ CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CCamera::~CCamera ()
|
CCamera::~CCamera ()
|
||||||
{
|
= default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const glm::vec3& CCamera::getCenter () const
|
const glm::vec3& CCamera::getCenter () const
|
||||||
{
|
{
|
||||||
@ -46,11 +46,16 @@ const glm::mat4& CCamera::getLookAt () const
|
|||||||
return this->m_lookat;
|
return this->m_lookat;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CCamera::isOrthogonal () const
|
bool CCamera::isOrthogonal () const
|
||||||
{
|
{
|
||||||
return this->m_isOrthogonal;
|
return this->m_isOrthogonal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CScene* CCamera::getScene () const
|
||||||
|
{
|
||||||
|
return this->m_scene;
|
||||||
|
}
|
||||||
|
|
||||||
void CCamera::setOrthogonalProjection (float width, float height)
|
void CCamera::setOrthogonalProjection (float width, float height)
|
||||||
{
|
{
|
||||||
// TODO: GET THE ZNEAR AND ZFAR FROM THE BACKGROUND (IF AVAILABLE)
|
// TODO: GET THE ZNEAR AND ZFAR FROM THE BACKGROUND (IF AVAILABLE)
|
||||||
|
@ -24,7 +24,8 @@ namespace WallpaperEngine::Render
|
|||||||
const glm::vec3& getUp () const;
|
const glm::vec3& getUp () const;
|
||||||
const glm::mat4& getProjection () const;
|
const glm::mat4& getProjection () const;
|
||||||
const glm::mat4& getLookAt () const;
|
const glm::mat4& getLookAt () const;
|
||||||
const bool isOrthogonal () const;
|
CScene* getScene () const;
|
||||||
|
bool isOrthogonal () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isOrthogonal;
|
bool m_isOrthogonal;
|
||||||
|
@ -14,7 +14,11 @@ CFBO::CFBO (
|
|||||||
m_name (std::move (name)),
|
m_name (std::move (name)),
|
||||||
m_format (format),
|
m_format (format),
|
||||||
m_scale (scale),
|
m_scale (scale),
|
||||||
m_flags (flags)
|
m_flags (flags),
|
||||||
|
m_framebuffer (GL_NONE),
|
||||||
|
m_depthbuffer (GL_NONE),
|
||||||
|
m_texture (GL_NONE),
|
||||||
|
m_resolution ()
|
||||||
{
|
{
|
||||||
// create an empty texture that'll be free'd so the FBO is transparent
|
// create an empty texture that'll be free'd so the FBO is transparent
|
||||||
GLenum drawBuffers [1] = {GL_COLOR_ATTACHMENT0};
|
GLenum drawBuffers [1] = {GL_COLOR_ATTACHMENT0};
|
||||||
@ -28,9 +32,9 @@ CFBO::CFBO (
|
|||||||
// give OpenGL an empty image
|
// give OpenGL an empty image
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||||
// label stuff for debugging
|
// label stuff for debugging
|
||||||
if (DEBUG)
|
#if DEBUG
|
||||||
glObjectLabel (GL_TEXTURE, this->m_texture, -1, this->m_name.c_str ());
|
glObjectLabel (GL_TEXTURE, this->m_texture, -1, this->m_name.c_str ());
|
||||||
|
#endif /* DEBUG */
|
||||||
// set filtering parameters, otherwise the texture is not rendered
|
// set filtering parameters, otherwise the texture is not rendered
|
||||||
if (flags & TextureFlags::ClampUVs)
|
if (flags & TextureFlags::ClampUVs)
|
||||||
{
|
{
|
||||||
@ -74,7 +78,7 @@ CFBO::CFBO (
|
|||||||
};
|
};
|
||||||
|
|
||||||
// create the textureframe entries
|
// create the textureframe entries
|
||||||
TextureFrame* frame = new TextureFrame;
|
auto* frame = new TextureFrame;
|
||||||
|
|
||||||
frame->frameNumber = 0;
|
frame->frameNumber = 0;
|
||||||
frame->frametime = 0;
|
frame->frametime = 0;
|
||||||
|
@ -41,4 +41,4 @@ namespace WallpaperEngine::Render
|
|||||||
/** Placeholder for frames, FBOs only have ONE */
|
/** Placeholder for frames, FBOs only have ONE */
|
||||||
std::vector<TextureFrame*> m_frames;
|
std::vector<TextureFrame*> m_frames;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -13,8 +13,7 @@ CObject::CObject(CScene* scene, std::string type, Core::CObject *object) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CObject::~CObject ()
|
CObject::~CObject ()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
CScene* CObject::getScene () const
|
CScene* CObject::getScene () const
|
||||||
{
|
{
|
||||||
@ -26,7 +25,7 @@ const CContainer& CObject::getContainer () const
|
|||||||
return this->getScene ()->getContainer ();
|
return this->getScene ()->getContainer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int CObject::getId () const
|
int CObject::getId () const
|
||||||
{
|
{
|
||||||
return this->m_object->getId ();
|
return this->m_object->getId ();
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ namespace WallpaperEngine::Render
|
|||||||
|
|
||||||
CScene* getScene () const;
|
CScene* getScene () const;
|
||||||
const CContainer& getContainer () const;
|
const CContainer& getContainer () const;
|
||||||
const int getId () const;
|
int getId () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CObject (CScene* scene, std::string type, Core::CObject *object);
|
CObject (CScene* scene, std::string type, Core::CObject *object);
|
||||||
|
@ -59,14 +59,20 @@ CRenderContext::CRenderContext (std::vector <std::string> screens, CVideoDriver&
|
|||||||
m_container (container),
|
m_container (container),
|
||||||
m_app (app),
|
m_app (app),
|
||||||
m_input (input),
|
m_input (input),
|
||||||
m_textureCache (new CTextureCache (*this))
|
m_textureCache (new CTextureCache (*this)),
|
||||||
|
m_display (nullptr),
|
||||||
|
m_pixmap (0),
|
||||||
|
m_gc (nullptr),
|
||||||
|
m_image (nullptr),
|
||||||
|
m_imageData (nullptr),
|
||||||
|
m_fbo (nullptr)
|
||||||
{
|
{
|
||||||
this->initialize ();
|
this->initialize ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRenderContext::initialize ()
|
void CRenderContext::initialize ()
|
||||||
{
|
{
|
||||||
if (this->m_screens.empty () == true)
|
if (this->m_screens.empty ())
|
||||||
this->setupWindow ();
|
this->setupWindow ();
|
||||||
else
|
else
|
||||||
this->setupScreens ();
|
this->setupScreens ();
|
||||||
@ -162,7 +168,7 @@ void CRenderContext::setupScreens ()
|
|||||||
|
|
||||||
CRenderContext::~CRenderContext ()
|
CRenderContext::~CRenderContext ()
|
||||||
{
|
{
|
||||||
if (this->m_screens.empty () == false)
|
if (!this->m_screens.empty ())
|
||||||
{
|
{
|
||||||
// free any used resource
|
// free any used resource
|
||||||
XDestroyImage (this->m_image);
|
XDestroyImage (this->m_image);
|
||||||
@ -182,12 +188,11 @@ void CRenderContext::renderScreens ()
|
|||||||
|
|
||||||
for (const auto& cur : this->m_viewports)
|
for (const auto& cur : this->m_viewports)
|
||||||
{
|
{
|
||||||
if (DEBUG)
|
#if DEBUG
|
||||||
{
|
|
||||||
std::string str = "Rendering to screen " + cur.name;
|
std::string str = "Rendering to screen " + cur.name;
|
||||||
|
|
||||||
glPushDebugGroup (GL_DEBUG_SOURCE_APPLICATION, 0, -1, str.c_str ());
|
glPushDebugGroup (GL_DEBUG_SOURCE_APPLICATION, 0, -1, str.c_str ());
|
||||||
}
|
#endif /* DEBUG */
|
||||||
|
|
||||||
// render the background
|
// render the background
|
||||||
this->m_wallpaper->render (cur.viewport, false, renderFrame, firstFrame);
|
this->m_wallpaper->render (cur.viewport, false, renderFrame, firstFrame);
|
||||||
@ -196,8 +201,9 @@ void CRenderContext::renderScreens ()
|
|||||||
firstFrame = false;
|
firstFrame = false;
|
||||||
renderFrame = !this->m_wallpaper->is <CVideo> ();
|
renderFrame = !this->m_wallpaper->is <CVideo> ();
|
||||||
|
|
||||||
if (DEBUG)
|
#if DEBUG
|
||||||
glPopDebugGroup ();
|
glPopDebugGroup ();
|
||||||
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the full texture into the image
|
// read the full texture into the image
|
||||||
@ -229,10 +235,10 @@ void CRenderContext::render ()
|
|||||||
if (this->m_wallpaper == nullptr)
|
if (this->m_wallpaper == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this->m_viewports.empty () == false)
|
if (this->m_viewports.empty ())
|
||||||
this->renderScreens ();
|
|
||||||
else
|
|
||||||
this->renderWindow ();
|
this->renderWindow ();
|
||||||
|
else
|
||||||
|
this->renderScreens ();
|
||||||
|
|
||||||
this->m_driver.swapBuffers ();
|
this->m_driver.swapBuffers ();
|
||||||
}
|
}
|
||||||
@ -242,7 +248,7 @@ void CRenderContext::setWallpaper (CWallpaper* wallpaper)
|
|||||||
this->m_wallpaper = wallpaper;
|
this->m_wallpaper = wallpaper;
|
||||||
|
|
||||||
// update the wallpaper's texcoords based on the mode we're running
|
// update the wallpaper's texcoords based on the mode we're running
|
||||||
if (this->m_screens.empty () == false)
|
if (!this->m_screens.empty ())
|
||||||
{
|
{
|
||||||
GLfloat texCoords [] = {
|
GLfloat texCoords [] = {
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
|
@ -15,18 +15,21 @@ using namespace WallpaperEngine;
|
|||||||
using namespace WallpaperEngine::Render;
|
using namespace WallpaperEngine::Render;
|
||||||
|
|
||||||
CScene::CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& audioContext) :
|
CScene::CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& audioContext) :
|
||||||
CWallpaper (scene, Type, context, audioContext)
|
CWallpaper (scene, Type, context, audioContext),
|
||||||
|
m_mousePosition (),
|
||||||
|
m_mousePositionLast (),
|
||||||
|
m_parallaxDisplacement ()
|
||||||
{
|
{
|
||||||
// setup the scene camera
|
// setup the scene camera
|
||||||
this->m_camera = new CCamera (this, scene->getCamera ());
|
this->m_camera = new CCamera (this, scene->getCamera ());
|
||||||
|
|
||||||
// detect size if the orthogonal project is auto
|
// detect size if the orthogonal project is auto
|
||||||
if (scene->getOrthogonalProjection ()->isAuto () == true)
|
if (scene->getOrthogonalProjection ()->isAuto ())
|
||||||
{
|
{
|
||||||
// calculate the size of the projection based on the size of everything
|
// calculate the size of the projection based on the size of everything
|
||||||
for (const auto& cur : scene->getObjects ())
|
for (const auto& cur : scene->getObjects ())
|
||||||
{
|
{
|
||||||
if (cur.second->is<Core::Objects::CImage> () == false)
|
if (!cur.second->is <Core::Objects::CImage> ())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
glm::vec2 size = cur.second->as <Core::Objects::CImage> ()->getSize ();
|
glm::vec2 size = cur.second->as <Core::Objects::CImage> ()->getSize ();
|
||||||
@ -149,7 +152,7 @@ CScene::CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& aud
|
|||||||
auto json = nlohmann::json::parse (imagejson);
|
auto json = nlohmann::json::parse (imagejson);
|
||||||
|
|
||||||
// create image for bloom passes
|
// create image for bloom passes
|
||||||
if (this->getScene ()->isBloom () == true)
|
if (this->getScene ()->isBloom ())
|
||||||
{
|
{
|
||||||
this->m_bloomObject = this->createObject (
|
this->m_bloomObject = this->createObject (
|
||||||
WallpaperEngine::Core::CObject::fromJSON (
|
WallpaperEngine::Core::CObject::fromJSON (
|
||||||
@ -184,15 +187,15 @@ Render::CObject* CScene::createObject (Core::CObject* object)
|
|||||||
this->createObject ((*dep).second);
|
this->createObject ((*dep).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object->is<Core::Objects::CImage>() == true)
|
if (object->is <Core::Objects::CImage> ())
|
||||||
{
|
{
|
||||||
Objects::CImage* image = new Objects::CImage (this, object->as<Core::Objects::CImage>());
|
auto* image = new Objects::CImage (this, object->as<Core::Objects::CImage>());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
image->setup ();
|
image->setup ();
|
||||||
}
|
}
|
||||||
catch (std::runtime_error ex)
|
catch (std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
// this error message is already printed, so just show extra info about it
|
// this error message is already printed, so just show extra info about it
|
||||||
sLog.error ("Cannot setup image ", image->getImage ()->getName ());
|
sLog.error ("Cannot setup image ", image->getImage ()->getName ());
|
||||||
@ -200,7 +203,7 @@ Render::CObject* CScene::createObject (Core::CObject* object)
|
|||||||
|
|
||||||
renderObject = image;
|
renderObject = image;
|
||||||
}
|
}
|
||||||
else if (object->is<Core::Objects::CSound>() == true)
|
else if (object->is <Core::Objects::CSound> ())
|
||||||
{
|
{
|
||||||
renderObject = new Objects::CSound (this, object->as<Core::Objects::CSound>());
|
renderObject = new Objects::CSound (this, object->as<Core::Objects::CSound>());
|
||||||
}
|
}
|
||||||
@ -222,7 +225,7 @@ void CScene::renderFrame (glm::ivec4 viewport)
|
|||||||
this->updateMouse (viewport);
|
this->updateMouse (viewport);
|
||||||
|
|
||||||
// update the parallax position if required
|
// update the parallax position if required
|
||||||
if (this->getScene ()->isCameraParallax () == true)
|
if (this->getScene ()->isCameraParallax ())
|
||||||
{
|
{
|
||||||
float influence = this->getScene ()->getCameraParallaxMouseInfluence ();
|
float influence = this->getScene ()->getCameraParallaxMouseInfluence ();
|
||||||
float amount = this->getScene ()->getCameraParallaxAmount ();
|
float amount = this->getScene ()->getCameraParallaxAmount ();
|
||||||
|
@ -8,8 +8,7 @@ CTextureCache::CTextureCache (CRenderContext& context) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CTextureCache::~CTextureCache ()
|
CTextureCache::~CTextureCache ()
|
||||||
{
|
= default;
|
||||||
}
|
|
||||||
|
|
||||||
const ITexture* CTextureCache::resolve (const std::string& filename)
|
const ITexture* CTextureCache::resolve (const std::string& filename)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,8 @@ void* get_proc_address (void* ctx, const char* name)
|
|||||||
CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext) :
|
CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext) :
|
||||||
CWallpaper (video, Type, context, audioContext),
|
CWallpaper (video, Type, context, audioContext),
|
||||||
m_width (16),
|
m_width (16),
|
||||||
m_height (16)
|
m_height (16),
|
||||||
|
m_mpvGl (nullptr)
|
||||||
{
|
{
|
||||||
double volume = g_AudioVolume * 100.0 / 128.0;
|
double volume = g_AudioVolume * 100.0 / 128.0;
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& aud
|
|||||||
if (mpv_command (this->m_mpv, command) < 0)
|
if (mpv_command (this->m_mpv, command) < 0)
|
||||||
sLog.exception ("Cannot load video to play");
|
sLog.exception ("Cannot load video to play");
|
||||||
|
|
||||||
if (g_AudioEnabled == false)
|
if (!g_AudioEnabled)
|
||||||
{
|
{
|
||||||
const char* mutecommand [] = {
|
const char* mutecommand [] = {
|
||||||
"set", "mute", "yes", nullptr
|
"set", "mute", "yes", nullptr
|
||||||
@ -98,9 +99,7 @@ void CVideo::renderFrame (glm::ivec4 viewport)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// we do not care about any of the events
|
// we do not care about any of the events
|
||||||
switch (event->event_id)
|
if (event->event_id == MPV_EVENT_VIDEO_RECONFIG)
|
||||||
{
|
|
||||||
case MPV_EVENT_VIDEO_RECONFIG:
|
|
||||||
{
|
{
|
||||||
int64_t width, height;
|
int64_t width, height;
|
||||||
|
|
||||||
@ -108,8 +107,6 @@ void CVideo::renderFrame (glm::ivec4 viewport)
|
|||||||
mpv_get_property (this->m_mpv, "dheight", MPV_FORMAT_INT64, &height) >= 0)
|
mpv_get_property (this->m_mpv, "dheight", MPV_FORMAT_INT64, &height) >= 0)
|
||||||
this->setSize (width, height);
|
this->setSize (width, height);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the next
|
// render the next
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user