Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
892f8ce0c4
|
||
|
|
c373b15bab
|
||
|
|
fb46f4d36a
|
||
|
|
337c016824
|
||
|
|
d2806b2061
|
||
|
|
da79db223f
|
||
|
|
b2c7c1fdbf
|
||
|
|
4a73e8c8da
|
||
|
|
641fc27e55
|
||
|
|
b8c25d6901
|
||
|
|
931e02aefb
|
||
|
|
0db4953125
|
||
|
|
2b7d25cf06
|
||
|
|
0ef6d34435
|
||
|
|
eb5d5f9974
|
+334
@@ -0,0 +1,334 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: true
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCaseArrows: false
|
||||
AlignCaseColons: false
|
||||
AlignConsecutiveTableGenBreakingDAGArgColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenCondOperatorColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveTableGenDefinitionColons:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
AlignFunctionDeclarations: false
|
||||
AlignFunctionPointers: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowBreakBeforeNoexceptSpecifier: Never
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseExpressionOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortCompoundRequirementOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortNamespacesOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
- absl_nonnull
|
||||
- absl_nullable
|
||||
- absl_nullability_unknown
|
||||
BinPackArguments: true
|
||||
BinPackLongBracedList: true
|
||||
BinPackParameters: BinPack
|
||||
BitFieldColonSpacing: Both
|
||||
BracedInitializerIndentWidth: -1
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterExternBlock: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAdjacentStringLiterals: true
|
||||
BreakAfterAttributes: Leave
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakAfterReturnType: None
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTemplateCloser: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakBinaryOperations: Never
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakFunctionDefinitionParameters: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
BreakTemplateDeclarations: Yes
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
EnumTrailingComma: Leave
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: true
|
||||
IndentExportBlock: true
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
BinaryMinDigits: 0
|
||||
Decimal: 0
|
||||
DecimalMinDigits: 0
|
||||
Hex: 0
|
||||
HexMinDigits: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLines:
|
||||
AtEndOfFile: false
|
||||
AtStartOfBlock: false
|
||||
AtStartOfFile: true
|
||||
KeepFormFeed: false
|
||||
LambdaBodyIndentation: Signature
|
||||
LineEnding: DeriveLF
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MainIncludeChar: Quote
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
OneLineFormatOffRegex: ''
|
||||
PackConstructorInitializers: NextLine
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakBeforeMemberAccess: 150
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakScopeResolution: 500
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
- cc
|
||||
- CC
|
||||
- cpp
|
||||
- Cpp
|
||||
- CPP
|
||||
- 'c++'
|
||||
- 'C++'
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
- ParseTestProto
|
||||
- ParsePartialTestProto
|
||||
CanonicalDelimiter: pb
|
||||
BasedOnStyle: google
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: Always
|
||||
RemoveBracesLLVM: false
|
||||
RemoveEmptyLinesInUnwrappedLines: false
|
||||
RemoveParentheses: Leave
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SkipMacroDefinitionBody: false
|
||||
SortIncludes:
|
||||
Enabled: true
|
||||
IgnoreCase: false
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterOperatorKeyword: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeJsonColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterNot: false
|
||||
AfterOverloadedOperator: false
|
||||
AfterPlacementOperator: true
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: Never
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InCStyleCasts: false
|
||||
InConditionalStatements: false
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TableGenBreakInsideDAGArg: DontBreak
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
VerilogBreakBetweenInstancePorts: true
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
WrapNamespaceBodyWithEmptyLines: Leave
|
||||
...
|
||||
|
||||
+71
-14
@@ -8,29 +8,86 @@ set(PD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
include(cmake/palladium.cmake)
|
||||
|
||||
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF)
|
||||
option(PD_BUILD_SHARED "Build Shared Libraries" OFF)
|
||||
option(PD_BUILD_SHARED "Build Shared Library" OFF)
|
||||
option(PD_BUILD_TOOLS "Build Palladium Tools" OFF)
|
||||
|
||||
if(${PD_BUILD_TOOLS})
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
|
||||
## Include Library Source
|
||||
# # Include Library Source
|
||||
set(PD_SOURCES
|
||||
|
||||
add_subdirectory(pd/drivers)
|
||||
add_subdirectory(pd/core)
|
||||
add_subdirectory(pd/image)
|
||||
add_subdirectory(pd/external)
|
||||
add_subdirectory(pd/lithium)
|
||||
add_subdirectory(pd/ui7)
|
||||
# Core
|
||||
source/core/bit_util.cpp
|
||||
source/core/color.cpp
|
||||
source/core/io.cpp
|
||||
source/core/mat.cpp
|
||||
source/core/strings.cpp
|
||||
source/core/timer.cpp
|
||||
source/core/timetrace.cpp
|
||||
|
||||
add_library(palladium INTERFACE)
|
||||
target_link_libraries(palladium INTERFACE
|
||||
pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net
|
||||
# Drivers
|
||||
source/drivers/gfx.cpp
|
||||
source/drivers/hid.cpp
|
||||
source/drivers/os.cpp
|
||||
|
||||
# External
|
||||
source/external/stb.cpp
|
||||
|
||||
# Image
|
||||
source/image/image.cpp
|
||||
source/image/img_blur.cpp
|
||||
source/image/img_convert.cpp
|
||||
|
||||
# Lithium
|
||||
source/lithium/command.cpp
|
||||
source/lithium/drawlist.cpp
|
||||
source/lithium/font.cpp
|
||||
source/lithium/fonts.cpp
|
||||
source/lithium/renderer.cpp
|
||||
|
||||
# UI7
|
||||
source/ui7/container/button.cpp
|
||||
source/ui7/container/checkbox.cpp
|
||||
source/ui7/container/coloredit.cpp
|
||||
source/ui7/container/container.cpp
|
||||
source/ui7/container/dragdata.cpp
|
||||
source/ui7/container/dynobj.cpp
|
||||
source/ui7/container/image.cpp
|
||||
source/ui7/container/label.cpp
|
||||
source/ui7/container/slider.cpp
|
||||
source/ui7/io.cpp
|
||||
source/ui7/layout.cpp
|
||||
source/ui7/menu.cpp
|
||||
source/ui7/theme.cpp
|
||||
source/ui7/ui7.cpp
|
||||
)
|
||||
|
||||
add_dependencies(palladium
|
||||
pd-drivers pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net
|
||||
)
|
||||
if(${PD_BUILD_SHARED})
|
||||
add_library(palladium SHARED ${PD_SOURCES})
|
||||
target_compile_definitions(palladium PRIVATE -DPD_BUILD_SHARED)
|
||||
else()
|
||||
add_library(palladium STATIC ${PD_SOURCES})
|
||||
endif()
|
||||
|
||||
target_include_directories(palladium PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
install(DIRECTORY include DESTINATION ".")
|
||||
install(TARGETS palladium)
|
||||
|
||||
find_program(CLANG_FORMAT clang-format)
|
||||
|
||||
file(GLOB_RECURSE PD_FMTFILES CONFIGURE_DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/core/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/drivers/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/image/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/lithium/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/ui7/*.hpp
|
||||
)
|
||||
|
||||
add_custom_target(pd-clang-format
|
||||
COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES}
|
||||
COMMENT "Formatting Project Sources"
|
||||
)
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -42,13 +41,13 @@ class GfxC3D : public GfxDriver {
|
||||
void Deinit() override;
|
||||
void NewFrame() override;
|
||||
void BindTex(PD::Li::TexAddress addr) override;
|
||||
void RenderDrawData(
|
||||
const std::vector<PD::Li::Command::Ref>& Commands) override;
|
||||
void RenderDrawData(const PD::Li::CmdPool& Commands) override;
|
||||
PD::Li::Texture::Ref LoadTex(
|
||||
const std::vector<PD::u8>& pixels, int w, int h,
|
||||
PD::Li::Texture::Type type = PD::Li::Texture::Type::RGBA32,
|
||||
PD::Li::Texture::Filter filter =
|
||||
PD::Li::Texture::Filter::LINEAR) override;
|
||||
void DestroyTex(PD::Li::Texture::Ref tex) override;
|
||||
|
||||
std::vector<Li::Vertex, LinearAllocator<Li::Vertex>> VertexBuffer;
|
||||
std::vector<u16, LinearAllocator<u16>> IndexBuffer;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -95,6 +94,11 @@ void FragCfg(GPU_TEXCOLOR clr) {
|
||||
C3D_TexEnvFunc(env, C3D_RGB, GPU_REPLACE);
|
||||
C3D_TexEnvFunc(env, C3D_Alpha, GPU_MODULATE);
|
||||
break;
|
||||
case GPU_RGB565:
|
||||
C3D_TexEnvSrc(env, C3D_Alpha, GPU_TEXTURE0);
|
||||
C3D_TexEnvFunc(env, C3D_RGB, GPU_MODULATE);
|
||||
C3D_TexEnvFunc(env, C3D_Alpha, GPU_REPLACE);
|
||||
break;
|
||||
|
||||
default:
|
||||
C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0);
|
||||
@@ -142,7 +146,7 @@ void GfxC3D::BindTex(PD::Li::TexAddress addr) {
|
||||
C3D_TexBind(0, reinterpret_cast<C3D_Tex*>(addr));
|
||||
}
|
||||
|
||||
void GfxC3D::RenderDrawData(const std::vector<PD::Li::Command::Ref>& Commands) {
|
||||
void GfxC3D::RenderDrawData(const PD::Li::CmdPool& Commands) {
|
||||
shaderProgramUse(&Shader);
|
||||
C3D_SetAttrInfo(&ShaderInfo);
|
||||
C3D_Mtx proj;
|
||||
@@ -151,20 +155,20 @@ void GfxC3D::RenderDrawData(const std::vector<PD::Li::Command::Ref>& Commands) {
|
||||
// Mat4 proj = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f);
|
||||
// C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, pLocProjection, (C3D_Mtx*)&proj);
|
||||
size_t index = 0;
|
||||
while (index < Commands.size()) {
|
||||
PD::Li::Texture::Ref Tex = Commands[index]->Tex;
|
||||
while (index < Commands.Size()) {
|
||||
PD::Li::Texture::Ref Tex = Commands.GetCmd(index)->Tex;
|
||||
if (!Tex) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
bool ScissorEnabled = Commands[index]->ScissorOn;
|
||||
ivec4 ScissorRect = Commands[index]->ScissorRect;
|
||||
bool ScissorEnabled = Commands.GetCmd(index)->ScissorOn;
|
||||
ivec4 ScissorRect = Commands.GetCmd(index)->ScissorRect;
|
||||
size_t StartIndex = CurrentIndex;
|
||||
|
||||
while (index < Commands.size() && Commands[index]->Tex == Tex &&
|
||||
Commands[index]->ScissorOn == ScissorEnabled &&
|
||||
Commands[index]->ScissorRect == ScissorRect) {
|
||||
auto c = Commands[index].get();
|
||||
while (index < Commands.Size() && Commands.GetCmd(index)->Tex == Tex &&
|
||||
Commands.GetCmd(index)->ScissorOn == ScissorEnabled &&
|
||||
Commands.GetCmd(index)->ScissorRect == ScissorRect) {
|
||||
auto c = Commands.GetCmd(index);
|
||||
for (size_t i = 0; i < c->IndexBuffer.size(); i++) {
|
||||
IndexBuffer[CurrentIndex++] = CurrentVertex + c->IndexBuffer.at(i);
|
||||
}
|
||||
@@ -255,4 +259,11 @@ PD::Li::Texture::Ref GfxC3D::LoadTex(const std::vector<PD::u8>& pixels, int w,
|
||||
<< std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
void GfxC3D::DestroyTex(PD::Li::Texture::Ref tex) {
|
||||
C3D_Tex* t = reinterpret_cast<C3D_Tex*>(tex->Address);
|
||||
C3D_TexDelete(t);
|
||||
delete t;
|
||||
tex->Address = 0;
|
||||
}
|
||||
} // namespace PD
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,6 +2,14 @@ cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-desktop LANGUAGES CXX VERSION 0.5.0)
|
||||
|
||||
set(PD_GL_VERSION 21 CACHE STRING "OpenGL Version (2.1 -> 21, 3.3 -> 33)")
|
||||
|
||||
if(APPLE)
|
||||
set(PD_GL_VERSION 33 CACHE STRING "33" FORCE)
|
||||
endif()
|
||||
|
||||
message("Using OpenGL: " ${PD_GL_VERSION})
|
||||
|
||||
add_subdirectory(glad)
|
||||
add_subdirectory(glfw)
|
||||
|
||||
@@ -14,3 +22,7 @@ set(SRC
|
||||
pd_add_lib(pd-desktop SRC_FILES ${SRC})
|
||||
target_include_directories(pd-desktop PUBLIC include)
|
||||
target_link_libraries(pd-desktop PUBLIC palladium glad glfw)
|
||||
|
||||
target_compile_definitions(pd-desktop
|
||||
PRIVATE PD_OPENGL=${PD_GL_VERSION}
|
||||
)
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -44,8 +43,7 @@ class GfxGL2 : public GfxDriver {
|
||||
void Deinit() override;
|
||||
void NewFrame() override;
|
||||
void BindTex(PD::Li::TexAddress addr) override;
|
||||
void RenderDrawData(
|
||||
const std::vector<PD::Li::Command::Ref>& Commands) override;
|
||||
void RenderDrawData(const Li::CmdPool& Commands) override;
|
||||
PD::Li::Texture::Ref LoadTex(
|
||||
const std::vector<PD::u8>& pixels, int w, int h,
|
||||
PD::Li::Texture::Type type = PD::Li::Texture::Type::RGBA32,
|
||||
@@ -57,6 +55,35 @@ class GfxGL2 : public GfxDriver {
|
||||
GLuint Shader;
|
||||
GLuint pLocProjection;
|
||||
GLuint pLocTex;
|
||||
GLuint VBO, IBO;
|
||||
GLuint pLocAlfa;
|
||||
GLuint VBO, IBO, VAO; // vao is only used in > 3.3
|
||||
};
|
||||
|
||||
class GfxGL3 : public GfxDriver2 {
|
||||
public:
|
||||
GfxGL3() : GfxDriver2("OpenGL3") {}
|
||||
~GfxGL3() = default;
|
||||
|
||||
PD_SHARED(GfxGL3);
|
||||
|
||||
void Init() override;
|
||||
void Deinit() override;
|
||||
// void NewFrame() override;
|
||||
void TexBind(PD::Li::TexAddress addr) override;
|
||||
void Draw(const Li::CmdPool& pool) override;
|
||||
PD::Li::TexAddress TexLoad(
|
||||
const std::vector<PD::u8>& pixels, int w, int h,
|
||||
PD::Li::Texture::Type type = PD::Li::Texture::Type::RGBA32,
|
||||
PD::Li::Texture::Filter filter =
|
||||
PD::Li::Texture::Filter::LINEAR) override;
|
||||
void TexDelete(PD::Li::TexAddress tex) override;
|
||||
|
||||
std::vector<Li::Vertex> VertexBuffer;
|
||||
std::vector<PD::u16> IndexBuffer;
|
||||
GLuint Shader;
|
||||
GLuint pLocProjection;
|
||||
GLuint pLocTex;
|
||||
GLuint pLocAlfa;
|
||||
GLuint VBO, IBO, VAO; // vao is only used in > 3.3
|
||||
};
|
||||
} // namespace PD
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -64,6 +63,7 @@ class HidGLFW : public HidDriver {
|
||||
GLFWwindow* Window;
|
||||
int PrevState;
|
||||
std::unordered_map<int, int> PrevStates;
|
||||
static GLFWcharfun pOldTextCB;
|
||||
static std::string* pText;
|
||||
bool pInTextMode = false;
|
||||
PD::u64 pLastUpdate = 0;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,6 +24,7 @@ SOFTWARE.
|
||||
#include <pd-desktop/bknd-gfx.hpp>
|
||||
|
||||
namespace PD {
|
||||
#if PD_OPENGL >= 21 && PD_OPENGL < 33
|
||||
const char* vertex_shader = R"(
|
||||
#version 120
|
||||
|
||||
@@ -53,12 +53,62 @@ const char* frag_shader = R"(
|
||||
varying vec4 oColor;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform bool alfa;
|
||||
|
||||
void main() {
|
||||
vec4 tc = texture2D(tex, oUV);
|
||||
gl_FragColor = tc*oColor;
|
||||
if (alfa) {
|
||||
gl_FragColor = vec4(oColor.rgb, tc.a * oColor.a);
|
||||
} else {
|
||||
gl_FragColor = tc * oColor;
|
||||
}
|
||||
}
|
||||
)";
|
||||
#elif PD_OPENGL >= 33
|
||||
const char* vertex_shader = R"(
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec2 pos;
|
||||
layout(location = 1) in vec2 uv;
|
||||
layout(location = 2) in vec4 color;
|
||||
|
||||
out vec2 oUV;
|
||||
out vec4 oColor;
|
||||
|
||||
// Probably forgot about this matrix and
|
||||
// searched hours for why the rendering isn't working :/
|
||||
uniform mat4 projection;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection*vec4(pos, 0.0, 1.0);
|
||||
oUV = uv;
|
||||
oColor = color;
|
||||
}
|
||||
)";
|
||||
|
||||
const char* frag_shader = R"(
|
||||
#version 330 core
|
||||
|
||||
in vec2 oUV;
|
||||
in vec4 oColor;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform bool alfa;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
vec4 tc = texture(tex, oUV);
|
||||
if (alfa) {
|
||||
FragColor = vec4(oColor.rgb, tc.a * oColor.a);
|
||||
} else {
|
||||
FragColor = tc * oColor;
|
||||
}
|
||||
}
|
||||
)";
|
||||
#else
|
||||
// Need to show error
|
||||
#endif
|
||||
|
||||
GLuint compileShader(const std::string& source, GLenum type) {
|
||||
GLuint shader = glCreateShader(type);
|
||||
@@ -128,25 +178,47 @@ void GfxGL2::Init() {
|
||||
Shader = createShaderProgram(vertex_shader, frag_shader);
|
||||
glUseProgram(Shader);
|
||||
|
||||
#if PD_OPENGL >= 33
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
#endif
|
||||
|
||||
glGenBuffers(1, &VBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
|
||||
// Attribs Setup
|
||||
SetupShaderAttribs(Shader);
|
||||
|
||||
#if PD_OPENGL < 33
|
||||
SetupShaderAttribs(Shader); // GL 2.1
|
||||
#else
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(PD::Li::Vertex),
|
||||
(void*)offsetof(PD::Li::Vertex, Pos));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(PD::Li::Vertex),
|
||||
(void*)offsetof(PD::Li::Vertex, UV));
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(PD::Li::Vertex),
|
||||
(void*)offsetof(PD::Li::Vertex, Color));
|
||||
#endif
|
||||
glGenBuffers(1, &IBO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
|
||||
|
||||
pLocTex = glGetUniformLocation(Shader, "tex");
|
||||
pLocAlfa = glGetUniformLocation(Shader, "alfa");
|
||||
pLocProjection = glGetUniformLocation(Shader, "projection");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
#if PD_OPENGL >= 33
|
||||
glBindVertexArray(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GfxGL2::Deinit() {
|
||||
glDeleteBuffers(1, &VBO);
|
||||
glDeleteBuffers(1, &IBO);
|
||||
#if PD_OPENGL >= 33
|
||||
glDeleteBuffers(1, &VAO);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GfxGL2::NewFrame() {
|
||||
@@ -172,24 +244,27 @@ void GfxGL2::BindTex(PD::Li::TexAddress addr) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)addr);
|
||||
glUniform1i(pLocTex, 0);
|
||||
GLint fmt = 0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
|
||||
glUniform1i(pLocAlfa, fmt == GL_ALPHA);
|
||||
}
|
||||
|
||||
void GfxGL2::RenderDrawData(const std::vector<PD::Li::Command::Ref>& Commands) {
|
||||
void GfxGL2::RenderDrawData(const Li::CmdPool& Commands) {
|
||||
size_t index = 0;
|
||||
while (index < Commands.size()) {
|
||||
PD::Li::Texture::Ref Tex = Commands[index]->Tex;
|
||||
while (index < Commands.Size()) {
|
||||
PD::Li::TexAddress Tex = Commands.GetCmd(index)->Tex;
|
||||
if (!Tex) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
size_t StartIndex = CurrentIndex;
|
||||
bool ScissorOn = Commands[index]->ScissorOn;
|
||||
ivec4 ScissorRect = Commands[index]->ScissorRect;
|
||||
bool ScissorOn = Commands.GetCmd(index)->ScissorOn;
|
||||
ivec4 ScissorRect = Commands.GetCmd(index)->ScissorRect;
|
||||
|
||||
while (index < Commands.size() && Commands[index]->Tex == Tex &&
|
||||
Commands[index]->ScissorOn == ScissorOn &&
|
||||
Commands[index]->ScissorRect == ScissorRect) {
|
||||
auto c = Commands[index].get();
|
||||
while (index < Commands.Size() && Commands.GetCmd(index)->Tex == Tex &&
|
||||
Commands.GetCmd(index)->ScissorOn == ScissorOn &&
|
||||
Commands.GetCmd(index)->ScissorRect == ScissorRect) {
|
||||
auto c = Commands.GetCmd(index);
|
||||
for (size_t i = 0; i < c->IndexBuffer.size(); i++) {
|
||||
IndexBuffer[CurrentIndex++] = CurrentVertex + c->IndexBuffer.at(i);
|
||||
}
|
||||
@@ -205,13 +280,21 @@ void GfxGL2::RenderDrawData(const std::vector<PD::Li::Command::Ref>& Commands) {
|
||||
} else {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
BindTex(Tex->Address);
|
||||
BindTex(Tex);
|
||||
|
||||
#if PD_OPENGL >= 33
|
||||
glBindVertexArray(VAO);
|
||||
#endif
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, CurrentVertex * sizeof(PD::Li::Vertex),
|
||||
&VertexBuffer[0], GL_DYNAMIC_DRAW);
|
||||
|
||||
#if PD_OPENGL < 33
|
||||
// For some reason we need to set these every frame for every buffer
|
||||
// Found that out when creating My 3d Engine
|
||||
SetupShaderAttribs(Shader);
|
||||
#endif
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, CurrentIndex * sizeof(PD::u16),
|
||||
@@ -223,6 +306,9 @@ void GfxGL2::RenderDrawData(const std::vector<PD::Li::Command::Ref>& Commands) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
BindTex(0);
|
||||
#if PD_OPENGL >= 33
|
||||
glBindVertexArray(0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,4 +339,161 @@ PD::Li::Texture::Ref GfxGL2::LoadTex(const std::vector<PD::u8>& pixels, int w,
|
||||
auto res = PD::Li::Texture::New(texID, PD::ivec2(w, h));
|
||||
return res;
|
||||
}
|
||||
|
||||
void GfxGL3::Init() {
|
||||
VertexBuffer.resize(4 * 8192);
|
||||
IndexBuffer.resize(6 * 8192);
|
||||
Shader = createShaderProgram(vertex_shader, frag_shader);
|
||||
glUseProgram(Shader);
|
||||
|
||||
#if PD_OPENGL >= 33
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
#endif
|
||||
|
||||
glGenBuffers(1, &VBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
|
||||
#if PD_OPENGL < 33
|
||||
SetupShaderAttribs(Shader); // GL 2.1
|
||||
#else
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(PD::Li::Vertex),
|
||||
(void*)offsetof(PD::Li::Vertex, Pos));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(PD::Li::Vertex),
|
||||
(void*)offsetof(PD::Li::Vertex, UV));
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(PD::Li::Vertex),
|
||||
(void*)offsetof(PD::Li::Vertex, Color));
|
||||
#endif
|
||||
glGenBuffers(1, &IBO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
|
||||
|
||||
pLocTex = glGetUniformLocation(Shader, "tex");
|
||||
pLocAlfa = glGetUniformLocation(Shader, "alfa");
|
||||
pLocProjection = glGetUniformLocation(Shader, "projection");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
#if PD_OPENGL >= 33
|
||||
glBindVertexArray(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GfxGL3::Deinit() {
|
||||
glDeleteBuffers(1, &VBO);
|
||||
glDeleteBuffers(1, &IBO);
|
||||
#if PD_OPENGL >= 33
|
||||
glDeleteBuffers(1, &VAO);
|
||||
#endif
|
||||
}
|
||||
|
||||
// void NewFrame() {
|
||||
//}
|
||||
|
||||
void GfxGL3::TexBind(PD::Li::TexAddress addr) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)addr);
|
||||
glUniform1i(pLocTex, 0);
|
||||
GLint fmt = 0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
|
||||
glUniform1i(pLocAlfa, fmt == GL_ALPHA);
|
||||
}
|
||||
|
||||
void GfxGL3::Draw(const Li::CmdPool& pool) {
|
||||
size_t index = 0;
|
||||
while (index < pool.Size()) {
|
||||
PD::Li::TexAddress Tex = pool.GetCmd(index)->Tex;
|
||||
if (Tex == 0) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
size_t StartIndex = CurrentIndex;
|
||||
bool ScissorOn = pool.GetCmd(index)->ScissorOn;
|
||||
ivec4 ScissorRect = pool.GetCmd(index)->ScissorRect;
|
||||
|
||||
while (index < pool.Size() && pool.GetCmd(index)->Tex == Tex &&
|
||||
pool.GetCmd(index)->ScissorOn == ScissorOn &&
|
||||
pool.GetCmd(index)->ScissorRect == ScissorRect) {
|
||||
auto c = pool.GetCmd(index);
|
||||
for (size_t i = 0; i < c->IndexBuffer.size(); i++) {
|
||||
IndexBuffer[CurrentIndex++] = CurrentVertex + c->IndexBuffer.at(i);
|
||||
}
|
||||
for (size_t i = 0; i < c->VertexBuffer.size(); i++) {
|
||||
VertexBuffer[CurrentVertex++] = c->VertexBuffer.at(i);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if (ScissorOn) {
|
||||
glScissor(ScissorRect.x, ViewPort.y - (ScissorRect.y + ScissorRect.w),
|
||||
ScissorRect.z, ScissorRect.w);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
} else {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
TexBind(Tex);
|
||||
|
||||
#if PD_OPENGL >= 33
|
||||
glBindVertexArray(VAO);
|
||||
#endif
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, CurrentVertex * sizeof(PD::Li::Vertex),
|
||||
&VertexBuffer[0], GL_DYNAMIC_DRAW);
|
||||
|
||||
#if PD_OPENGL < 33
|
||||
// For some reason we need to set these every frame for every buffer
|
||||
// Found that out when creating My 3d Engine
|
||||
SetupShaderAttribs(Shader);
|
||||
#endif
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, CurrentIndex * sizeof(PD::u16),
|
||||
&IndexBuffer[0], GL_DYNAMIC_DRAW);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, CurrentIndex - StartIndex, GL_UNSIGNED_SHORT,
|
||||
(void*)(StartIndex * sizeof(PD::u16)));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
TexBind(0);
|
||||
#if PD_OPENGL >= 33
|
||||
glBindVertexArray(0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
PD::Li::TexAddress GfxGL3::TexLoad(const std::vector<PD::u8>& pixels, int w,
|
||||
int h, PD::Li::Texture::Type type,
|
||||
PD::Li::Texture::Filter filter) {
|
||||
GLuint texID;
|
||||
glGenTextures(1, &texID);
|
||||
glBindTexture(GL_TEXTURE_2D, texID);
|
||||
|
||||
// Set base format (Always using RGBA as base)
|
||||
GLenum fmt = GL_RGBA;
|
||||
if (type == PD::Li::Texture::Type::RGB24) {
|
||||
fmt = GL_RGB;
|
||||
} else if (type == PD::Li::Texture::Type::A8) {
|
||||
fmt = GL_ALPHA;
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE,
|
||||
pixels.data());
|
||||
if (filter == PD::Li::Texture::Filter::LINEAR) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
} else if (filter == PD::Li::Texture::Filter::NEAREST) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
return texID;
|
||||
}
|
||||
|
||||
void GfxGL3::TexDelete(PD::Li::TexAddress tex) {
|
||||
GLuint tex_ = tex;
|
||||
glDeleteTextures(1, &tex_);
|
||||
}
|
||||
|
||||
} // namespace PD
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,11 +23,21 @@ SOFTWARE.
|
||||
|
||||
#include <pd-desktop/bknd-hid.hpp>
|
||||
namespace PD {
|
||||
std::string* HidGLFW::pText;
|
||||
std::string* HidGLFW::pText = nullptr;
|
||||
GLFWcharfun HidGLFW::pOldTextCB = nullptr;
|
||||
// Default Call back (If no Text input is requsted)
|
||||
void NullTextCB(GLFWwindow* win, unsigned int c) {}
|
||||
void NullTextCB(GLFWwindow* win, unsigned int c) {
|
||||
// Chain
|
||||
if (HidGLFW::pOldTextCB) {
|
||||
HidGLFW::pOldTextCB(win, c);
|
||||
}
|
||||
}
|
||||
// Text callback if requested
|
||||
void TextCB(GLFWwindow* win, unsigned int c) {
|
||||
// Chain
|
||||
if (HidGLFW::pOldTextCB) {
|
||||
HidGLFW::pOldTextCB(win, c);
|
||||
}
|
||||
if (!HidGLFW::pText) {
|
||||
return;
|
||||
}
|
||||
@@ -36,7 +45,7 @@ void TextCB(GLFWwindow* win, unsigned int c) {
|
||||
}
|
||||
HidGLFW::HidGLFW(GLFWwindow* win) : HidDriver("HidGLFW") {
|
||||
Window = win;
|
||||
glfwSetCharCallback(Window, NullTextCB);
|
||||
HidGLFW::pOldTextCB = glfwSetCharCallback(Window, NullTextCB);
|
||||
Flags |= Flags_HasKeyboard;
|
||||
Flags |= Flags_HasMouse;
|
||||
pBinds[GLFW_MOUSE_BUTTON_LEFT] = Touch;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/drivers/drivers.hpp>
|
||||
#include <pd/external/json.hpp>
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -36,12 +35,12 @@ namespace BitUtil {
|
||||
* @param v 32 bit unsigned int
|
||||
* @return true if its a single bit number
|
||||
*/
|
||||
PD_CORE_API bool IsSingleBit(u32 v);
|
||||
PD_API bool IsSingleBit(u32 v);
|
||||
/**
|
||||
* Get the Next Power of two Number
|
||||
* @param v Current Number
|
||||
* @return Next Number thats a Pow of 2
|
||||
*/
|
||||
PD_CORE_API u32 GetPow2(u32 v);
|
||||
PD_API u32 GetPow2(u32 v);
|
||||
} // namespace BitUtil
|
||||
} // namespace PD
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,7 +27,7 @@ SOFTWARE.
|
||||
#include <pd/core/strings.hpp>
|
||||
|
||||
namespace PD {
|
||||
class PD_CORE_API Color {
|
||||
class PD_API Color {
|
||||
public:
|
||||
/**
|
||||
* Default Constructor (all variables are set to 0)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -42,7 +42,7 @@ SOFTWARE.
|
||||
#include <vector>
|
||||
|
||||
/** Dynamic Lib loading */
|
||||
#include <pd/core/pd_p_api.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
/** Memory Management */
|
||||
|
||||
@@ -53,6 +53,16 @@ SOFTWARE.
|
||||
return std::make_shared<x>(std::forward<Args>(args)...); \
|
||||
}
|
||||
|
||||
#define PD_RAW(x) \
|
||||
using Ref = x*; \
|
||||
template <typename... Args> \
|
||||
static Ref New(Args&&... args) { \
|
||||
x* v = new x; \
|
||||
new (v) x(std::forward<Args>(args)...); \
|
||||
return v; \
|
||||
} \
|
||||
static void Delete(Ref ref) { delete ref; }
|
||||
|
||||
#define PD_UNIQUE(x) \
|
||||
using Ref = std::unique_ptr<x>; \
|
||||
template <typename... Args> \
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -35,28 +35,28 @@ namespace IO {
|
||||
* @param path Path to the File
|
||||
* @return 8Bit FileBuffer
|
||||
*/
|
||||
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path);
|
||||
PD_API std::vector<u8> LoadFile2Mem(const std::string& path);
|
||||
/**
|
||||
* Load a File into a std::string
|
||||
* @param path Path to the File
|
||||
* @return std::string file content
|
||||
*/
|
||||
PD_CORE_API std::string LoadFile2Str(const std::string& path);
|
||||
PD_API std::string LoadFile2Str(const std::string& path);
|
||||
/**
|
||||
* Hash a 8Bit Memory Buffer
|
||||
* @param data 8Bit input Buffer
|
||||
* @return 32Bit Hash
|
||||
*/
|
||||
PD_CORE_API u32 HashMemory(const std::vector<u8>& data);
|
||||
PD_API u32 HashMemory(const std::vector<u8>& data);
|
||||
/**
|
||||
* Function to decrompress RLE buffer
|
||||
* @param data Data buffer to decompress
|
||||
*/
|
||||
PD_CORE_API void DecompressRLE(std::vector<u8>& data);
|
||||
PD_API void DecompressRLE(std::vector<u8>& data);
|
||||
/**
|
||||
* Function to compress data with RLE Algorithm
|
||||
* @param data Data buf
|
||||
*/
|
||||
PD_CORE_API void CompressRLE(std::vector<u8>& data);
|
||||
PD_API void CompressRLE(std::vector<u8>& data);
|
||||
} // namespace IO
|
||||
} // namespace PD
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -41,7 +40,7 @@ constexpr float Radians(float v) { return v * (Numbers::Tau / 360.0f); }
|
||||
* @note That this is not a full Matrix Library
|
||||
*/
|
||||
|
||||
struct PD_CORE_API Mat4 {
|
||||
struct PD_API Mat4 {
|
||||
std::array<float, 16> m;
|
||||
constexpr Mat4() : m{} {}
|
||||
constexpr static Mat4 Diagonal(float x, float y, float z, float w) {
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/** Generated with ppam */
|
||||
|
||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
||||
#ifdef PD_CORE_BUILD_SHARED
|
||||
#define PD_CORE_API __declspec(dllexport)
|
||||
#else
|
||||
#define PD_CORE_API __declspec(dllimport)
|
||||
#endif
|
||||
#elif defined(__APPLE__) // macOS (untested yet)
|
||||
#ifdef PD_CORE_BUILD_SHARED
|
||||
#define PD_CORE_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_CORE_API
|
||||
#endif
|
||||
#elif defined(__linux__) // Linux (untested yet)
|
||||
#ifdef PD_CORE_BUILD_SHARED
|
||||
#define PD_CORE_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_CORE_API
|
||||
#endif
|
||||
#elif defined(__3DS__) // 3ds Specific
|
||||
// Only Static supported
|
||||
#define PD_CORE_API
|
||||
#else
|
||||
#define PD_CORE_API
|
||||
#endif
|
||||
Executable → Regular
+10
-10
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -43,7 +43,7 @@ constexpr int HexChar2Int(char c) {
|
||||
* @param exts List of Extensions to check for
|
||||
* @return true if one of the extensions is found in the String
|
||||
*/
|
||||
PD_CORE_API bool StringEndsWith(const std::string& str,
|
||||
PD_API bool StringEndsWith(const std::string& str,
|
||||
const std::vector<std::string>& exts);
|
||||
/**
|
||||
* Function to Create a wstring of a string
|
||||
@@ -51,39 +51,39 @@ PD_CORE_API bool StringEndsWith(const std::string& str,
|
||||
* @return Result wstring
|
||||
* @note Returns Empty if it has an error
|
||||
*/
|
||||
PD_CORE_API std::wstring MakeWstring(const std::string& s);
|
||||
PD_API std::wstring MakeWstring(const std::string& s);
|
||||
/**
|
||||
* Generate a Formatted String by an Nanoseconds Input
|
||||
* @param nanos Nanoseconds Input
|
||||
* @return Result String
|
||||
*/
|
||||
PD_CORE_API const std::string FormatNanos(unsigned long long nanos);
|
||||
PD_API const std::string FormatNanos(unsigned long long nanos);
|
||||
/**
|
||||
* Generate a Formatted String by an Milliseconds Input
|
||||
* @param millis Milliseconds Input
|
||||
* @return Result String
|
||||
*/
|
||||
PD_CORE_API const std::string FormatMillis(unsigned long long millis);
|
||||
PD_API const std::string FormatMillis(unsigned long long millis);
|
||||
/**
|
||||
* Create a formatted String by an input bytes value
|
||||
* @param bytes value in bytes
|
||||
* @result Formatted String for example `2.5MB`
|
||||
*/
|
||||
PD_CORE_API const std::string FormatBytes(unsigned long long bytes);
|
||||
PD_API const std::string FormatBytes(unsigned long long bytes);
|
||||
/**
|
||||
* Extract the Filename out of a Path
|
||||
* @param path Path to extract from
|
||||
* @param saperators Path Split Chars
|
||||
* @return extracted filename
|
||||
*/
|
||||
PD_CORE_API const std::string GetFileName(
|
||||
const std::string& path, const std::string& saperators = "/\\");
|
||||
PD_API const std::string GetFileName(const std::string& path,
|
||||
const std::string& saperators = "/\\");
|
||||
/**
|
||||
* Remove Extension from a Path / Filename
|
||||
* @param path Input Path
|
||||
* @return Path without Extension
|
||||
*/
|
||||
PD_CORE_API const std::string PathRemoveExtension(const std::string& path);
|
||||
PD_API const std::string PathRemoveExtension(const std::string& path);
|
||||
/**
|
||||
* Function to Convert a Type to a hex value
|
||||
* @tparam T Type
|
||||
@@ -101,7 +101,7 @@ inline const std::string ToHex(const T& v) {
|
||||
* @param s String to hash
|
||||
* @return 32Bit Hash
|
||||
*/
|
||||
PD_CORE_API u32 FastHash(const std::string& s);
|
||||
PD_API u32 FastHash(const std::string& s);
|
||||
/**
|
||||
* Function to Generate a Compiler Name and Version String
|
||||
* Based on their Macros
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@ namespace PD {
|
||||
/**
|
||||
* Timer class
|
||||
*/
|
||||
class PD_CORE_API Timer {
|
||||
class PD_API Timer {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
Executable → Regular
+7
-7
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -102,12 +102,12 @@ class TimeStats {
|
||||
* Get Data Buffer
|
||||
* @return data bufer (not edidable)
|
||||
*/
|
||||
const std::vector<u64> &GetData() { return val; }
|
||||
const std::vector<u64>& GetData() { return val; }
|
||||
/**
|
||||
* Access an element in the list [not edidable]
|
||||
* @return value to access
|
||||
*/
|
||||
const u64 &operator[](int i) { return val[smart_idx(i)]; }
|
||||
const u64& operator[](int i) { return val[smart_idx(i)]; }
|
||||
/**
|
||||
* Get List Lengh
|
||||
* @return Lengh
|
||||
@@ -160,7 +160,7 @@ class Res {
|
||||
* Setter for the ID (Name)
|
||||
* @param v ID of the Trace
|
||||
*/
|
||||
void SetID(const std::string &v) { id = v; }
|
||||
void SetID(const std::string& v) { id = v; }
|
||||
/**
|
||||
* Getter for the traces ID
|
||||
* @return Trace ID
|
||||
@@ -218,12 +218,12 @@ class Res {
|
||||
* Begin a Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
PD_CORE_API void Beg(const std::string &id);
|
||||
PD_API void Beg(const std::string& id);
|
||||
/**
|
||||
* End a Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
PD_CORE_API void End(const std::string &id);
|
||||
PD_API void End(const std::string& id);
|
||||
/**
|
||||
* Collect Start end end of the trace by tracking
|
||||
* when the Scope object goes out of scope
|
||||
@@ -245,7 +245,7 @@ class Scope {
|
||||
* Constructor requiring a Name for the Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
Scope(const std::string &id) {
|
||||
Scope(const std::string& id) {
|
||||
this->ID = id;
|
||||
Beg(id);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -34,6 +34,31 @@ enum LiBackendFlags_ {
|
||||
};
|
||||
|
||||
namespace PD {
|
||||
// The backend api nobody asked for
|
||||
class GfxDriver2 {
|
||||
public:
|
||||
GfxDriver2(const std::string& name = "NullGfx") : pName(name) {};
|
||||
~GfxDriver2() = default;
|
||||
|
||||
virtual void Init() {}
|
||||
virtual void Deinit() {}
|
||||
virtual void Draw(const PD::Li::CmdPool& pool) {}
|
||||
virtual void TexBind(PD::Li::TexAddress addr) {}
|
||||
virtual PD::Li::TexAddress TexLoad(
|
||||
const std::vector<PD::u8>& pixels, int w, int h,
|
||||
PD::Li::Texture::Type type = PD::Li::Texture::Type::RGBA32,
|
||||
PD::Li::Texture::Filter filter = PD::Li::Texture::Filter::LINEAR) {
|
||||
return 0;
|
||||
}
|
||||
virtual void TexDelete(PD::Li::TexAddress tex) {}
|
||||
|
||||
protected:
|
||||
const std::string pName;
|
||||
LiBackendFlags pFlags = 0;
|
||||
size_t CurrentIndex = 0;
|
||||
size_t CurrentVertex = 0;
|
||||
ivec2 ViewPort;
|
||||
};
|
||||
class GfxDriver {
|
||||
public:
|
||||
GfxDriver(const std::string& name = "NullGfx") : pName(name) {};
|
||||
@@ -49,7 +74,7 @@ class GfxDriver {
|
||||
|
||||
virtual void BindTex(Li::TexAddress addr) {}
|
||||
|
||||
virtual void RenderDrawData(const std::vector<Li::Command::Ref>& Commands) {}
|
||||
virtual void RenderDrawData(const Li::CmdPool& Commands) {}
|
||||
|
||||
void SetViewPort(const ivec2& vp) { ViewPort = vp; }
|
||||
|
||||
@@ -61,6 +86,8 @@ class GfxDriver {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void DestroyTex(PD::Li::Texture::Ref tex) {}
|
||||
|
||||
Li::Texture::Ref GetSolidTex() { return pSolid; }
|
||||
|
||||
const std::string pName = "NullGfx";
|
||||
@@ -96,7 +123,7 @@ class Gfx {
|
||||
static void SetViewPort(const ivec2& vp) { pGfx->SetViewPort(vp); }
|
||||
static void SetViewPort(int w, int h) { pGfx->SetViewPort(PD::ivec2(w, h)); }
|
||||
|
||||
static void RenderDrawData(const std::vector<Li::Command::Ref>& Commands) {
|
||||
static void RenderDrawData(const Li::CmdPool& Commands) {
|
||||
pGfx->RenderDrawData(Commands);
|
||||
}
|
||||
|
||||
@@ -108,6 +135,8 @@ class Gfx {
|
||||
return pGfx->LoadTex(pixels, w, h, type, filter);
|
||||
}
|
||||
|
||||
static void DestroyTex(Li::Texture::Ref tex) { pGfx->DestroyTex(tex); }
|
||||
|
||||
static Li::Texture::Ref GetSolidTex() { return pGfx->GetSolidTex(); }
|
||||
|
||||
static GfxDriver::Ref pGfx;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+2232
-2232
File diff suppressed because it is too large
Load Diff
+862
-862
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,10 +24,10 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/image/pd_p_api.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
class PD_IMAGE_API Image {
|
||||
class PD_API Image {
|
||||
public:
|
||||
enum Format {
|
||||
RGBA, // bpp == 4
|
||||
@@ -57,6 +56,7 @@ class PD_IMAGE_API Image {
|
||||
|
||||
int Width() const { return pWidth; }
|
||||
int Height() const { return pHeight; }
|
||||
ivec2 Size() const { return ivec2(pWidth, pHeight); }
|
||||
Format Fmt() const { return pFmt; }
|
||||
|
||||
void FlipVertical();
|
||||
|
||||
Executable → Regular
+7
-8
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +24,7 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/image/pd_p_api.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
@@ -38,7 +37,7 @@ namespace ImgBlur {
|
||||
* @param si sigma value to use
|
||||
* @return list of kernel values
|
||||
*/
|
||||
PD_IMAGE_API std::vector<float> GaussianKernel(int radius, float si);
|
||||
PD_API std::vector<float> GaussianKernel(int radius, float si);
|
||||
/**
|
||||
* Gaussian Blur for basic Image Buffer
|
||||
* @param buf Image Buffer (unsigned char)
|
||||
@@ -48,8 +47,8 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int radius, float si);
|
||||
* @param si Blur sigma
|
||||
* @param idxfn Indexing function
|
||||
*/
|
||||
PD_IMAGE_API void GaussianBlur(
|
||||
std::vector<u8> &buf, int w, int h, float radius, float si,
|
||||
PD_API void GaussianBlur(
|
||||
std::vector<u8>& buf, int w, int h, float radius, float si,
|
||||
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
|
||||
return y * w + x;
|
||||
});
|
||||
@@ -63,8 +62,8 @@ PD_IMAGE_API void GaussianBlur(
|
||||
* @param si Blur sigma
|
||||
* @param idxfn Indexing function
|
||||
*/
|
||||
PD_IMAGE_API void GaussianBlur(
|
||||
void *buf, int w, int h, int bpp, float radius, float si,
|
||||
PD_API void GaussianBlur(
|
||||
void* buf, int w, int h, int bpp, float radius, float si,
|
||||
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
|
||||
return y * w + x;
|
||||
});
|
||||
|
||||
Executable → Regular
+10
-11
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +25,7 @@ SOFTWARE.
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/image/image.hpp>
|
||||
#include <pd/image/pd_p_api.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
@@ -41,19 +40,19 @@ namespace ImgConvert {
|
||||
* @param w width of the image
|
||||
* @param h height of the image
|
||||
*/
|
||||
PD_IMAGE_API
|
||||
void RGB24toRGBA32(std::vector<PD::u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h);
|
||||
PD_IMAGE_API
|
||||
void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h);
|
||||
PD_API
|
||||
void RGB24toRGBA32(std::vector<PD::u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h);
|
||||
PD_API
|
||||
void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h);
|
||||
/**
|
||||
* Reverse 32 (RGBA -> ABGR || ABGR -> RGBA)
|
||||
* @param buf Buffer to convert
|
||||
* @param w width
|
||||
* @param h height
|
||||
*/
|
||||
PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h);
|
||||
PD_IMAGE_API void ReverseBuf(std::vector<u8> &buf, size_t bpp, int w, int h);
|
||||
PD_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h);
|
||||
PD_API void ReverseBuf(std::vector<u8>& buf, size_t bpp, int w, int h);
|
||||
} // namespace ImgConvert
|
||||
} // namespace PD
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/** Generated with ppam */
|
||||
|
||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
||||
#ifdef PD_IMAGE_BUILD_SHARED
|
||||
#define PD_IMAGE_API __declspec(dllexport)
|
||||
#else
|
||||
#define PD_IMAGE_API __declspec(dllimport)
|
||||
#endif
|
||||
#elif defined(__APPLE__) // macOS (untested yet)
|
||||
#ifdef PD_IMAGE_BUILD_SHARED
|
||||
#define PD_IMAGE_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_IMAGE_API
|
||||
#endif
|
||||
#elif defined(__linux__) // Linux (untested yet)
|
||||
#ifdef PD_IMAGE_BUILD_SHARED
|
||||
#define PD_IMAGE_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_IMAGE_API
|
||||
#endif
|
||||
#elif defined(__3DS__) // 3ds Specific
|
||||
// Only Static supported
|
||||
#define PD_IMAGE_API
|
||||
#else
|
||||
#define PD_IMAGE_API
|
||||
#endif
|
||||
Executable → Regular
+44
-5
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,7 @@ SOFTWARE.
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/lithium/texture.hpp>
|
||||
#include <pd/lithium/vertex.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
@@ -34,7 +35,7 @@ class Command {
|
||||
Command() = default;
|
||||
~Command() = default;
|
||||
|
||||
PD_UNIQUE(Command);
|
||||
PD_RAW(Command);
|
||||
|
||||
Command& AddIdx(const u16& idx) {
|
||||
IndexBuffer.push_back(VertexBuffer.size() + idx);
|
||||
@@ -52,13 +53,51 @@ class Command {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
VertexBuffer.clear();
|
||||
IndexBuffer.clear();
|
||||
Index = 0;
|
||||
Layer = 0;
|
||||
Tex = 0;
|
||||
ScissorOn = false;
|
||||
ScissorRect = ivec4();
|
||||
}
|
||||
|
||||
std::vector<Vertex> VertexBuffer;
|
||||
std::vector<u16> IndexBuffer;
|
||||
ivec4 ScissorRect;
|
||||
bool ScissorOn = false;
|
||||
int Layer;
|
||||
int Index;
|
||||
Texture::Ref Tex;
|
||||
int Layer = 0;
|
||||
int Index = 0;
|
||||
TexAddress Tex;
|
||||
};
|
||||
|
||||
class PD_API CmdPool {
|
||||
public:
|
||||
CmdPool() {}
|
||||
~CmdPool() {}
|
||||
|
||||
Command::Ref NewCmd();
|
||||
void Init(size_t initial_size);
|
||||
void Deinit();
|
||||
void Resize(size_t nulen);
|
||||
void Reset();
|
||||
Command::Ref GetCmd(size_t idx) const;
|
||||
Command::Ref GetCmd(size_t idx);
|
||||
size_t Size() const;
|
||||
size_t Cap() const;
|
||||
void Merge(CmdPool& p);
|
||||
void Copy(CmdPool& p);
|
||||
void Sort();
|
||||
|
||||
private:
|
||||
static bool pTheOrder(const Command::Ref& a, const Command::Ref& b);
|
||||
friend class DrawList;
|
||||
Command::Ref* begin() { return &pPool[0]; }
|
||||
Command::Ref* end() { return &pPool[pPoolIdx - 1]; }
|
||||
std::vector<Command::Ref> pPool;
|
||||
u32 pPoolIdx = 0;
|
||||
int Layer = 0;
|
||||
};
|
||||
} // namespace Li
|
||||
} // namespace PD
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +25,7 @@ SOFTWARE.
|
||||
|
||||
#include <pd/lithium/command.hpp>
|
||||
#include <pd/lithium/font.hpp>
|
||||
#include <pd/lithium/pd_p_api.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
/** Path Rect Flags */
|
||||
using LiPathRectFlags = PD::u32;
|
||||
@@ -46,10 +45,10 @@ enum LiPathRectFlags_ : PD::u32 {
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
class PD_LITHIUM_API DrawList {
|
||||
class PD_API DrawList {
|
||||
public:
|
||||
DrawList() { DrawSolid(); }
|
||||
~DrawList() { pDrawList.clear(); }
|
||||
DrawList(int initial_size = 64);
|
||||
~DrawList();
|
||||
|
||||
/** Require Copy and Move Constructors */
|
||||
|
||||
@@ -81,13 +80,12 @@ class PD_LITHIUM_API DrawList {
|
||||
*/
|
||||
void Optimize();
|
||||
|
||||
Command::Ref PreGenerateCmd();
|
||||
void AddCommand(Command::Ref v);
|
||||
Command::Ref GetNewCmd();
|
||||
void Clear();
|
||||
void Layer(int l) { this->pLayer = l; }
|
||||
int Layer() { return this->pLayer; }
|
||||
void LayerUp() { this->pLayer++; }
|
||||
void LayerDown() { this->pLayer--; }
|
||||
void Layer(int l) { this->pPool.Layer = l; }
|
||||
int Layer() { return this->pPool.Layer; }
|
||||
void LayerUp() { this->pPool.Layer++; }
|
||||
void LayerDown() { this->pPool.Layer--; }
|
||||
|
||||
void SetFont(Font::Ref font) { pCurrentFont = font; }
|
||||
void SetFontScale(float scale) { pFontScale = scale; }
|
||||
@@ -206,18 +204,17 @@ class PD_LITHIUM_API DrawList {
|
||||
}
|
||||
pClipRects.pop();
|
||||
}
|
||||
const std::vector<Command::Ref>& Data() const { return pDrawList; }
|
||||
const CmdPool& Data() const { return pPool; }
|
||||
/** One linear Clip rect Setup */
|
||||
void pClipCmd(Command* cmd);
|
||||
|
||||
/** Data Section */
|
||||
|
||||
std::stack<fvec4> pClipRects;
|
||||
int pLayer;
|
||||
float pFontScale = 0.7f;
|
||||
Font::Ref pCurrentFont;
|
||||
Texture::Ref CurrentTex;
|
||||
std::vector<Command::Ref> pDrawList;
|
||||
CmdPool pPool;
|
||||
std::vector<fvec2> pPath;
|
||||
u32 pNumIndices = 0;
|
||||
u32 pNumVertices = 0;
|
||||
|
||||
Executable → Regular
+5
-6
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,9 +25,9 @@ SOFTWARE.
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/lithium/command.hpp>
|
||||
#include <pd/lithium/pd_p_api.hpp>
|
||||
#include <pd/lithium/rect.hpp>
|
||||
#include <pd/lithium/texture.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
using LiTextFlags = PD::u32;
|
||||
enum LiTextFlags_ {
|
||||
@@ -44,7 +43,7 @@ enum LiTextFlags_ {
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
class PD_LITHIUM_API Font {
|
||||
class PD_API Font {
|
||||
public:
|
||||
/** Codepoint Data holder */
|
||||
struct Codepoint {
|
||||
@@ -93,8 +92,8 @@ class PD_LITHIUM_API Font {
|
||||
/**
|
||||
* Extended Draw Text Function that vreates a Command List
|
||||
*/
|
||||
void CmdTextEx(std::vector<Command::Ref>& cmds, const fvec2& pos, u32 color,
|
||||
float scale, const std::string& text, LiTextFlags flags = 0,
|
||||
void CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color, float scale,
|
||||
const std::string& text, LiTextFlags flags = 0,
|
||||
const fvec2& box = 0);
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/** Generated with ppam */
|
||||
|
||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
||||
#ifdef PD_LITHIUM_BUILD_SHARED
|
||||
#define PD_LITHIUM_API __declspec(dllexport)
|
||||
#else
|
||||
#define PD_LITHIUM_API __declspec(dllimport)
|
||||
#endif
|
||||
#elif defined(__APPLE__) // macOS (untested yet)
|
||||
#ifdef PD_LITHIUM_BUILD_SHARED
|
||||
#define PD_LITHIUM_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_LITHIUM_API
|
||||
#endif
|
||||
#elif defined(__linux__) // Linux (untested yet)
|
||||
#ifdef PD_LITHIUM_BUILD_SHARED
|
||||
#define PD_LITHIUM_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_LITHIUM_API
|
||||
#endif
|
||||
#elif defined(__3DS__) // 3ds Specific
|
||||
// Only Static supported
|
||||
#define PD_LITHIUM_API
|
||||
#else
|
||||
#define PD_LITHIUM_API
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -131,6 +131,8 @@ class Rect {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(Rect& r) { return Top == r.Top && Bot == r.Bot; }
|
||||
|
||||
void SwapVec2XY() {
|
||||
Top.SwapXY();
|
||||
Top.SwapZW();
|
||||
|
||||
Executable → Regular
+3
-4
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,15 +24,15 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/drivers/drivers.hpp>
|
||||
#include <pd/lithium/pd_p_api.hpp>
|
||||
#include <pd/lithium/rect.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
/**
|
||||
* Static Class Render Setup Functions
|
||||
*/
|
||||
class PD_LITHIUM_API Renderer {
|
||||
class PD_API Renderer {
|
||||
public:
|
||||
Renderer() = default;
|
||||
~Renderer() = default;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -38,6 +38,8 @@ class Vertex {
|
||||
}
|
||||
~Vertex() {}
|
||||
|
||||
PD_RAW(Vertex);
|
||||
|
||||
// private:
|
||||
|
||||
/** Open Access Data Section */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,26 +26,26 @@ SOFTWARE.
|
||||
/** Generated with ppam */
|
||||
|
||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
||||
#ifdef PD_UI7_BUILD_SHARED
|
||||
#define PD_UI7_API __declspec(dllexport)
|
||||
#ifdef PD_BUILD_SHARED
|
||||
#define PD_API __declspec(dllexport)
|
||||
#else
|
||||
#define PD_UI7_API __declspec(dllimport)
|
||||
#define PD_API __declspec(dllimport)
|
||||
#endif
|
||||
#elif defined(__APPLE__) // macOS (untested yet)
|
||||
#ifdef PD_UI7_BUILD_SHARED
|
||||
#define PD_UI7_API __attribute__((visibility("default")))
|
||||
#ifdef PD_BUILD_SHARED
|
||||
#define PD_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_UI7_API
|
||||
#define PD_API
|
||||
#endif
|
||||
#elif defined(__linux__) // Linux (untested yet)
|
||||
#ifdef PD_UI7_BUILD_SHARED
|
||||
#define PD_UI7_API __attribute__((visibility("default")))
|
||||
#ifdef PD_BUILD_SHARED
|
||||
#define PD_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PD_UI7_API
|
||||
#define PD_API
|
||||
#endif
|
||||
#elif defined(__3DS__) // 3ds Specific
|
||||
// Only Static supported
|
||||
#define PD_UI7_API
|
||||
#define PD_API
|
||||
#else
|
||||
#define PD_UI7_API
|
||||
#define PD_API
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -35,7 +35,7 @@ namespace UI7 {
|
||||
* This only means that InPressed is responding the info in
|
||||
* the next frame
|
||||
*/
|
||||
class PD_UI7_API Button : public Container {
|
||||
class PD_API Button : public Container {
|
||||
public:
|
||||
/**
|
||||
* Button Object constructor
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,7 +33,7 @@ namespace UI7 {
|
||||
* Context::Update while the visual update is done
|
||||
* during the Update
|
||||
*/
|
||||
class PD_UI7_API Checkbox : public Container {
|
||||
class PD_API Checkbox : public Container {
|
||||
public:
|
||||
/**
|
||||
* Constructor for Checkbox Object
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,7 +32,7 @@ namespace UI7 {
|
||||
/**
|
||||
* Color Editor (Creating a PopUP when clicking)
|
||||
*/
|
||||
class PD_UI7_API ColorEdit : public Container {
|
||||
class PD_API ColorEdit : public Container {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
Executable → Regular
+3
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,8 +24,8 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
#include <pd/ui7/io.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
@@ -33,7 +33,7 @@ namespace UI7 {
|
||||
* Container base class all Objects are based on
|
||||
* @note this class can be used to create custom Objects as well
|
||||
*/
|
||||
class PD_UI7_API Container {
|
||||
class PD_API Container {
|
||||
public:
|
||||
Container() = default;
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,7 +33,7 @@ namespace UI7 {
|
||||
* and modifys these by moving left or right when dragging
|
||||
*/
|
||||
template <typename T>
|
||||
class PD_UI7_API DragData : public Container {
|
||||
class PD_API DragData : public Container {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -36,7 +35,7 @@ namespace UI7 {
|
||||
* This only means that InPressed is responding the info in
|
||||
* the next frame
|
||||
*/
|
||||
class PD_UI7_API DynObj : public Container {
|
||||
class PD_API DynObj : public Container {
|
||||
public:
|
||||
/**
|
||||
* Button Object constructor
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,7 +30,7 @@ namespace UI7 {
|
||||
/**
|
||||
* Image Object
|
||||
*/
|
||||
class PD_UI7_API Image : public Container {
|
||||
class PD_API Image : public Container {
|
||||
public:
|
||||
/**
|
||||
* Constructor for the Image Object
|
||||
@@ -39,13 +39,15 @@ class PD_UI7_API Image : public Container {
|
||||
*/
|
||||
Image(Li::Texture::Ref img, fvec2 size = 0.f, Li::Rect uv = fvec4(0.f)) {
|
||||
this->img = img;
|
||||
this->newsize = size;
|
||||
this->cuv = uv;
|
||||
if (size.x != 0 || size.y != 0) {
|
||||
this->SetSize(size);
|
||||
} else {
|
||||
this->SetSize(fvec2(img->GetSize().x, img->GetSize().y));
|
||||
if (size == fvec2(0.f)) {
|
||||
size = img->GetSize();
|
||||
}
|
||||
if (uv == Li::Rect(fvec4(0.f))) {
|
||||
uv = img->GetUV();
|
||||
}
|
||||
this->cuv = uv;
|
||||
this->newsize = size;
|
||||
SetSize(size);
|
||||
}
|
||||
~Image() = default;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,7 +30,7 @@ namespace UI7 {
|
||||
/**
|
||||
* Label [Text] Object
|
||||
*/
|
||||
class PD_UI7_API Label : public Container {
|
||||
class PD_API Label : public Container {
|
||||
public:
|
||||
/**
|
||||
* Constructor for Label Object
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/ui7/container/container.hpp>
|
||||
#include <pd/ui7/io.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
/**
|
||||
* Slider Object can take a datatype or a list
|
||||
* and modifys these by moving left or right when dragging
|
||||
*/
|
||||
template <typename T>
|
||||
class PD_API Slider : public Container {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param label Label of the Button
|
||||
* @param data Data reference (Supported types can be seen in Slider.cpp)
|
||||
* @param num_elms Number of Array elements (for exaple with use ofvec4)
|
||||
* @param io IO Reference
|
||||
* @param min minimum number using Minimum limit
|
||||
* @param max Maximum number set by max limit by default
|
||||
* @param step To set the modifier for drag movement
|
||||
* @param precision for float and double to set precision
|
||||
*/
|
||||
Slider(const std::string& label, T* data, UI7::IO::Ref io,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), int precision = 1) {
|
||||
// PD::Assert(data != nullptr, "Input Data Address is null!");
|
||||
this->label = label;
|
||||
this->data = data;
|
||||
this->min = min;
|
||||
this->max = max;
|
||||
this->precision = precision;
|
||||
this->width = io->CurrentViewPort.z * 0.3f;
|
||||
this->tdim = io->Font->GetTextBounds(label, io->FontScale);
|
||||
}
|
||||
~Slider() = default;
|
||||
|
||||
/** Als ob das funktioniert... */
|
||||
PD_SHARED(Slider<T>);
|
||||
/**
|
||||
* Override for the Input Handler
|
||||
* @note This function is usally called by Menu::Update
|
||||
*/
|
||||
void HandleInput() override;
|
||||
/**
|
||||
* Override for the Rendering Handler
|
||||
* @note This function is usally called by Menu::Update
|
||||
* */
|
||||
void Draw() override;
|
||||
|
||||
/** Function to Update Size if framepadding changes */
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
fvec2 tdim; ///< Text size
|
||||
float width; ///< Size
|
||||
std::string label; ///< Label of the Button
|
||||
T* data;
|
||||
T min;
|
||||
T max;
|
||||
int precision = 1;
|
||||
float slw = 0.f; // silider drag width (calculated in update)
|
||||
float slp = 0.f; // silider drag pos (calculated in update)
|
||||
};
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,3 +30,4 @@ SOFTWARE.
|
||||
#include <pd/ui7/container/dynobj.hpp>
|
||||
#include <pd/ui7/container/image.hpp>
|
||||
#include <pd/ui7/container/label.hpp>
|
||||
#include <pd/ui7/container/slider.hpp>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -49,6 +49,7 @@ enum UI7MenuFlags_ {
|
||||
// POC
|
||||
UI7MenuFlags_Maximize = 1 << 11, ///< Add a Maximize Button
|
||||
UI7MenuFlags_Minimize = 1 << 12, ///< Add a Minimize Button
|
||||
UI7MenuFlags_AlwaysAutoSize = 1 << 13, ///< Always Auto Resize Menu
|
||||
// Enable Horizontal and Vertical Scrolling
|
||||
UI7MenuFlags_Scrolling = UI7MenuFlags_HzScrolling | UI7MenuFlags_VtScrolling,
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -38,6 +38,7 @@ class ID {
|
||||
*/
|
||||
ID(const std::string& text) {
|
||||
pID = PD::Strings::FastHash(text);
|
||||
// pStrName = text;
|
||||
pName = text;
|
||||
}
|
||||
/**
|
||||
@@ -56,7 +57,7 @@ class ID {
|
||||
~ID() = default;
|
||||
|
||||
/** Get The ID Initial Name */
|
||||
constexpr const std::string_view& GetNameView() const { return pName; }
|
||||
// constexpr const std::string_view& GetNameView() const { return pName; }
|
||||
const std::string GetName() const { return std::string(pName); }
|
||||
|
||||
/** Getter for the raw 32bit int id */
|
||||
@@ -66,7 +67,8 @@ class ID {
|
||||
constexpr operator u32() const { return pID; }
|
||||
|
||||
u32 pID; ///< Hash of the name
|
||||
std::string_view pName; ///< Name
|
||||
std::string pName; ///< Name
|
||||
// std::string pStrName; ///< Keep this stringview alive
|
||||
};
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
Executable → Regular
+2
-3
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,8 +25,8 @@ SOFTWARE.
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/lithium/lithium.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
#include <pd/ui7/id.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
|
||||
Executable → Regular
+5
-4
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,14 +24,14 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
#include <pd/ui7/input_api.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
#include <pd/ui7/theme.hpp>
|
||||
#include <pd/ui7/viewport.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
class PD_UI7_API IO {
|
||||
class PD_API IO {
|
||||
public:
|
||||
IO() {
|
||||
Time = Timer::New();
|
||||
@@ -73,6 +72,8 @@ class PD_UI7_API IO {
|
||||
UI7::Theme::Ref Theme;
|
||||
fvec2 MenuPadding = 5.f;
|
||||
fvec2 FramePadding = 5.f;
|
||||
float ItemRowHeight = 0.f;
|
||||
float FrameRounding = 0.f;
|
||||
fvec2 ItemSpace = vec2(5.f, 2.f);
|
||||
fvec2 MinSliderDragSize = 10.f; // Min height (Vt) and Min Width (Hz)
|
||||
bool ShowMenuBorder = true;
|
||||
|
||||
Executable → Regular
+71
-6
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,15 +24,17 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
#include <pd/ui7/container/container.hpp>
|
||||
#include <pd/ui7/container/dragdata.hpp>
|
||||
#include <pd/ui7/container/slider.hpp>
|
||||
#include <pd/ui7/flags.hpp>
|
||||
#include <pd/ui7/input_api.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
#include <pd/ui7/theme.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
class PD_UI7_API Layout {
|
||||
class PD_API Layout {
|
||||
public:
|
||||
Layout(const ID& id, IO::Ref io) : ID(id) {
|
||||
this->IO = io;
|
||||
@@ -44,14 +45,78 @@ class PD_UI7_API Layout {
|
||||
Scrolling[1] = false;
|
||||
CursorInit();
|
||||
Pos = fvec2(io->CurrentViewPort.x, io->CurrentViewPort.y);
|
||||
Size = fvec2(io->CurrentViewPort.z - io->CurrentViewPort.x,
|
||||
io->CurrentViewPort.w - io->CurrentViewPort.y);
|
||||
Size = 0;
|
||||
WorkRect = fvec4(IO->MenuPadding, Size - (fvec2(2) * IO->MenuPadding));
|
||||
}
|
||||
~Layout() = default;
|
||||
|
||||
PD_SHARED(Layout);
|
||||
|
||||
/** SECTION CONTAINERS */
|
||||
/**
|
||||
* Render a Simple Label
|
||||
* @param label The text to draw
|
||||
*/
|
||||
void Label(const std::string& label);
|
||||
template <typename... Args>
|
||||
void Label(std::format_string<Args...> s, Args&&... args) {
|
||||
Label(std::format(s, std::forward<Args>(args)...));
|
||||
}
|
||||
/**
|
||||
* Render a Button
|
||||
* @param label The buttons text
|
||||
* @return if the button was pressed
|
||||
*/
|
||||
bool Button(const std::string& label);
|
||||
/**
|
||||
* Render a Checkbox
|
||||
* @param label Label of the Checkbox
|
||||
* @param v A value to update
|
||||
*/
|
||||
void Checkbox(const std::string& label, bool& v);
|
||||
/**
|
||||
* Render an Image
|
||||
* @param img Texture reference of the image
|
||||
* @param size a Custom Size if needed
|
||||
*/
|
||||
void Image(Li::Texture::Ref img, fvec2 size = 0.f, Li::Rect uv = fvec4(0));
|
||||
/**
|
||||
* Render a Drag Object witth any supported type:
|
||||
* [`int`, `float`, `double`, `u8`, `u16`, `u32`]
|
||||
* @param label Name of the Drag
|
||||
* @param data Reference to Data Object (can be multiple as well)
|
||||
* @param num_elements Defien the number of Elements in the Data addr
|
||||
* @param precission Difine the Format string len for float/double
|
||||
*/
|
||||
template <typename T>
|
||||
void DragData(const std::string& label, T* data, size_t num_elms = 1,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), T step = 1,
|
||||
int precision = 1) {
|
||||
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
|
||||
Container::Ref r = FindObject(id);
|
||||
if (!r) {
|
||||
r = UI7::DragData<T>::New(label, data, num_elms, this->IO, min, max, step,
|
||||
precision);
|
||||
r->SetID(id);
|
||||
}
|
||||
AddObject(r);
|
||||
}
|
||||
template <typename T>
|
||||
void Slider(const std::string& label, T* data,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), int precision = 1) {
|
||||
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
|
||||
Container::Ref r = FindObject(id);
|
||||
if (!r) {
|
||||
r = UI7::Slider<T>::New(label, data, this->IO, min, max, precision);
|
||||
r->SetID(id);
|
||||
}
|
||||
AddObject(r);
|
||||
}
|
||||
|
||||
/** SECTION OTHERSTUFF */
|
||||
|
||||
const std::string GetName() const { return ID.GetName(); }
|
||||
const UI7::ID& GetID() const { return this->ID; }
|
||||
|
||||
|
||||
Executable → Regular
+27
-13
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,17 +24,18 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
#include <pd/ui7/containers.hpp>
|
||||
#include <pd/ui7/io.hpp>
|
||||
#include <pd/ui7/layout.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
|
||||
#include "pd/ui7/container/dragdata.hpp"
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
class PD_UI7_API Menu {
|
||||
class PD_API Menu {
|
||||
public:
|
||||
Menu(const UI7::ID &id, UI7::IO::Ref pIO);
|
||||
Menu(const UI7::ID& id, UI7::IO::Ref pIO);
|
||||
~Menu() {}
|
||||
|
||||
PD_SHARED(Menu);
|
||||
@@ -44,9 +44,9 @@ class PD_UI7_API Menu {
|
||||
* Render a Simple Label
|
||||
* @param label The text to draw
|
||||
*/
|
||||
void Label(const std::string &label);
|
||||
void Label(const std::string& label);
|
||||
template <typename... Args>
|
||||
void Label(std::format_string<Args...> s, Args &&...args) {
|
||||
void Label(std::format_string<Args...> s, Args&&... args) {
|
||||
Label(std::format(s, std::forward<Args>(args)...));
|
||||
}
|
||||
/**
|
||||
@@ -54,13 +54,13 @@ class PD_UI7_API Menu {
|
||||
* @param label The buttons text
|
||||
* @return if the button was pressed
|
||||
*/
|
||||
bool Button(const std::string &label);
|
||||
bool Button(const std::string& label);
|
||||
/**
|
||||
* Render a Checkbox
|
||||
* @param label Label of the Checkbox
|
||||
* @param v A value to update
|
||||
*/
|
||||
void Checkbox(const std::string &label, bool &v);
|
||||
void Checkbox(const std::string& label, bool& v);
|
||||
/**
|
||||
* Render an Image
|
||||
* @param img Texture reference of the image
|
||||
@@ -76,7 +76,7 @@ class PD_UI7_API Menu {
|
||||
* @param precission Difine the Format string len for float/double
|
||||
*/
|
||||
template <typename T>
|
||||
void DragData(const std::string &label, T *data, size_t num_elms = 1,
|
||||
void DragData(const std::string& label, T* data, size_t num_elms = 1,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), T step = 1,
|
||||
int precision = 1) {
|
||||
@@ -92,10 +92,23 @@ class PD_UI7_API Menu {
|
||||
}
|
||||
pLayout->AddObject(r);
|
||||
}
|
||||
template <typename T>
|
||||
void Slider(const std::string& label, T* data,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), int precision = 1) {
|
||||
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
|
||||
Container::Ref r = pLayout->FindObject(id);
|
||||
if (!r) {
|
||||
r = UI7::Slider<T>::New(label, data, pIO, min, max, precision);
|
||||
r->SetID(id);
|
||||
}
|
||||
pLayout->AddObject(r);
|
||||
}
|
||||
void ColorEdit(const std::string& label, u32& clr);
|
||||
void SameLine() { pLayout->SameLine(); }
|
||||
void Separator();
|
||||
void SeparatorText(const std::string &label);
|
||||
bool BeginTreeNode(const ID &id);
|
||||
void SeparatorText(const std::string& label);
|
||||
bool BeginTreeNode(const ID& id);
|
||||
void EndTreeNode();
|
||||
|
||||
void HandleFocus();
|
||||
@@ -107,6 +120,7 @@ class PD_UI7_API Menu {
|
||||
void AddObjectEx(PD::UI7::Container::Ref obj, PD::u32 flags) {
|
||||
pLayout->AddObjectEx(obj, flags);
|
||||
}
|
||||
Container::Ref FindObject(u32 id) { return pLayout->FindObject(id); }
|
||||
|
||||
void Update();
|
||||
|
||||
@@ -116,7 +130,7 @@ class PD_UI7_API Menu {
|
||||
Layout::Ref pLayout;
|
||||
IO::Ref pIO;
|
||||
ID pID;
|
||||
bool *pIsShown = nullptr;
|
||||
bool* pIsShown = nullptr;
|
||||
bool pIsOpen = true;
|
||||
std::unordered_map<u32, bool> pTreeNodes;
|
||||
fvec2 TempScrollXY;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,7 +24,7 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
|
||||
/**
|
||||
* Using this to support 32bit color values as well as
|
||||
@@ -55,7 +55,7 @@ enum UI7Color_ {
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
class PD_UI7_API Theme {
|
||||
class PD_API Theme {
|
||||
public:
|
||||
/**
|
||||
* Default Constructor Setting up the Default theme
|
||||
|
||||
Executable → Regular
+6
-6
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,9 +24,9 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/pd_p_api.hpp>
|
||||
#include <pd/ui7/io.hpp>
|
||||
#include <pd/ui7/menu.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
|
||||
#include "pd/ui7/flags.hpp"
|
||||
|
||||
@@ -46,9 +45,9 @@ namespace UI7 {
|
||||
* @param show_build Show build num (mostly unused)
|
||||
* @return Version String (1.0.0-1 for example)
|
||||
*/
|
||||
PD_UI7_API std::string GetVersion(bool show_build = false);
|
||||
PD_API std::string GetVersion(bool show_build = false);
|
||||
/** Base Context for UI7 */
|
||||
class PD_UI7_API Context {
|
||||
class PD_API Context {
|
||||
public:
|
||||
Context() { pIO = IO::New(); }
|
||||
~Context() = default;
|
||||
@@ -59,7 +58,8 @@ class PD_UI7_API Context {
|
||||
void AddViewPort(const ID& id, const ivec4& vp);
|
||||
void UseViewPort(const ID& id);
|
||||
void Update();
|
||||
bool BeginMenu(const ID& id, UI7MenuFlags flags = 0, bool* pShow = nullptr);
|
||||
Menu::Ref BeginMenu(const ID& id, UI7MenuFlags flags = 0,
|
||||
bool* pShow = nullptr);
|
||||
Menu::Ref CurrentMenu() { return pCurrent; }
|
||||
void EndMenu();
|
||||
void AboutMenu(bool* show = nullptr);
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-core LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
set(SRC
|
||||
source/bit_util.cpp
|
||||
source/color.cpp
|
||||
source/io.cpp
|
||||
source/mat.cpp
|
||||
source/strings.cpp
|
||||
source/timer.cpp
|
||||
source/timetrace.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-core BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-core SRC_FILES ${SRC})
|
||||
endif()
|
||||
|
||||
target_link_libraries(pd-core PUBLIC pd-drivers)
|
||||
@@ -1,13 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
## The Core Core Library
|
||||
project(pd-drivers LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
set(SRC
|
||||
source/hid.cpp
|
||||
source/os.cpp
|
||||
source/gfx.cpp
|
||||
)
|
||||
|
||||
# Only Static Supported
|
||||
pd_add_lib(pd-drivers SRC_FILES ${SRC})
|
||||
@@ -1,39 +0,0 @@
|
||||
#include <pd/drivers/hid.hpp>
|
||||
#include <pd/drivers/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_DEF_EXP(HidDriver::Ref, Hid::pHid);
|
||||
|
||||
bool HidDriver::IsEvent(Event e, Key keys) { return KeyEvents[0][e] & keys; }
|
||||
bool HidDriver::IsEvent(Event e, KbKey keys) {
|
||||
return KbKeyEvents[0][e].Has(keys);
|
||||
}
|
||||
|
||||
void HidDriver::SwapTab() {
|
||||
auto tkd = KeyEvents[1][Event_Down];
|
||||
auto tkh = KeyEvents[1][Event_Held];
|
||||
auto tku = KeyEvents[1][Event_Up];
|
||||
KeyEvents[1][Event_Down] = KeyEvents[0][Event_Down];
|
||||
KeyEvents[1][Event_Held] = KeyEvents[0][Event_Held];
|
||||
KeyEvents[1][Event_Up] = KeyEvents[0][Event_Up];
|
||||
KeyEvents[0][Event_Down] = tkd;
|
||||
KeyEvents[0][Event_Held] = tkh;
|
||||
KeyEvents[0][Event_Up] = tku;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this func has no verride, still clear the stats
|
||||
* cause if they are empty this leads to a crash
|
||||
*/
|
||||
void HidDriver::Update() {
|
||||
// Clear States
|
||||
for (int i = 0; i < 2; i++) {
|
||||
KeyEvents[i][Event_Down] = 0;
|
||||
KeyEvents[i][Event_Held] = 0;
|
||||
KeyEvents[i][Event_Up] = 0;
|
||||
for (auto& it : KbKeyEvents[i]) {
|
||||
it.second = Event_Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace PD
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-external LANGUAGES CXX VERSION 0.5.0)
|
||||
|
||||
set(SRC
|
||||
source/stb.cpp
|
||||
)
|
||||
|
||||
pd_add_lib(pd-external SRC_FILES ${SRC})
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <pd/external/stb_image.h>
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include <pd/external/stb_truetype.h>
|
||||
@@ -1,15 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-image LANGUAGES CXX VERSION 0.5.0)
|
||||
|
||||
set(SRC
|
||||
source/image.cpp
|
||||
source/img_blur.cpp
|
||||
source/img_convert.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-image BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-image SRC_FILES ${SRC})
|
||||
endif()
|
||||
@@ -1,26 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-lithium LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
option(PD_LI_INCLUDE_FONTS "Include Fonts" OFF)
|
||||
|
||||
set(SRC
|
||||
source/drawlist.cpp
|
||||
source/font.cpp
|
||||
source/fonts.cpp
|
||||
source/renderer.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-lithium BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-lithium SRC_FILES ${SRC})
|
||||
endif()
|
||||
|
||||
if(${PD_LI_INCLUDE_FONTS})
|
||||
target_compile_definitions(pd-lithium PUBLIC
|
||||
-DPD_LI_INCLUDE_FONTS=1
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(pd-lithium PUBLIC pd-core)
|
||||
@@ -1,28 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-ui7 LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
set(SRC
|
||||
source/theme.cpp
|
||||
source/ui7.cpp
|
||||
source/io.cpp
|
||||
source/layout.cpp
|
||||
source/menu.cpp
|
||||
|
||||
source/container/button.cpp
|
||||
source/container/checkbox.cpp
|
||||
source/container/coloredit.cpp
|
||||
source/container/container.cpp
|
||||
source/container/dragdata.cpp
|
||||
source/container/dynobj.cpp
|
||||
source/container/image.cpp
|
||||
source/container/label.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-ui7 BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-ui7 SRC_FILES ${SRC})
|
||||
endif()
|
||||
|
||||
target_link_libraries(pd-ui7 PUBLIC pd-lithium pd-core)
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/ui7/container/coloredit.hpp>
|
||||
#include <pd/ui7/container/label.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
PD_UI7_API void ColorEdit::HandleInput() {
|
||||
/// Ensure to only check input once
|
||||
if (inp_done) {
|
||||
return;
|
||||
}
|
||||
// Assert(screen.get(), "Screen is not set up!");
|
||||
// if (screen->ScreenType() == Screen::Bottom) {
|
||||
if (io->InputHandler->DragObject(this->GetID(), fvec4(FinalPos(), size))) {
|
||||
if (io->InputHandler->DragReleased) {
|
||||
is_shown = !is_shown;
|
||||
}
|
||||
}
|
||||
//}
|
||||
inp_done = true;
|
||||
}
|
||||
PD_UI7_API void ColorEdit::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->DrawRectFilled(FinalPos(), fvec2(20, 20), *color_ref);
|
||||
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + 20, 0), label,
|
||||
io->Theme->Get(UI7Color_Text));
|
||||
if (is_shown) {
|
||||
if (!layout) {
|
||||
layout = Layout::New(GetID(), io);
|
||||
}
|
||||
layout->AddObject(Label::New("Hello World!", io));
|
||||
layout->Update();
|
||||
io->RegisterDrawList(GetID(), layout->GetDrawList());
|
||||
}
|
||||
}
|
||||
|
||||
PD_UI7_API void ColorEdit::Update() {
|
||||
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||
this->SetSize(fvec2(tdim.x + io->ItemSpace.x + 20, 20));
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,8 +24,8 @@ SOFTWARE.
|
||||
#include <pd/core/bit_util.hpp>
|
||||
|
||||
namespace PD::BitUtil {
|
||||
PD_CORE_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
|
||||
PD_CORE_API u32 GetPow2(u32 v) {
|
||||
PD_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
|
||||
PD_API u32 GetPow2(u32 v) {
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +24,7 @@ SOFTWARE.
|
||||
#include <pd/core/color.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_CORE_API std::string Color::Hex(bool rgba) const {
|
||||
PD_API std::string Color::Hex(bool rgba) const {
|
||||
/** Need to int cast (so it is used as num and not char...) */
|
||||
std::stringstream s;
|
||||
s << "#";
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace IO {
|
||||
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
|
||||
PD_API std::vector<u8> LoadFile2Mem(const std::string& path) {
|
||||
std::ifstream iff(path, std::ios::binary);
|
||||
if (!iff) {
|
||||
return std::vector<u8>();
|
||||
@@ -39,7 +39,7 @@ PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
|
||||
return res;
|
||||
}
|
||||
|
||||
PD_CORE_API std::string LoadFile2Str(const std::string& path) {
|
||||
PD_API std::string LoadFile2Str(const std::string& path) {
|
||||
std::ifstream iff(path, std::ios::binary);
|
||||
if (!iff) {
|
||||
return "";
|
||||
@@ -53,7 +53,7 @@ PD_CORE_API std::string LoadFile2Str(const std::string& path) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
|
||||
PD_API u32 HashMemory(const std::vector<u8>& data) {
|
||||
u32 hash = 4477;
|
||||
for (auto& it : data) {
|
||||
hash = (hash * 33) + it;
|
||||
@@ -61,7 +61,7 @@ PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
|
||||
PD_API void DecompressRLE(std::vector<u8>& data) {
|
||||
if ((data.size() % 2) != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_CORE_API void CompressRLE(std::vector<u8>& data) {
|
||||
PD_API void CompressRLE(std::vector<u8>& data) {
|
||||
if (data.empty()) {
|
||||
/** No exceptions enabled :( */
|
||||
return;
|
||||
Executable → Regular
+7
-8
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +24,7 @@ SOFTWARE.
|
||||
#include <pd/core/mat.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_CORE_API Mat4 Mat4::RotateX(float a) {
|
||||
PD_API Mat4 Mat4::RotateX(float a) {
|
||||
float c = std::cos(a);
|
||||
float s = std::sin(a);
|
||||
Mat4 ret = Identity();
|
||||
@@ -36,7 +35,7 @@ PD_CORE_API Mat4 Mat4::RotateX(float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::RotateY(float a) {
|
||||
PD_API Mat4 Mat4::RotateY(float a) {
|
||||
float c = std::cos(a);
|
||||
float s = std::sin(a);
|
||||
Mat4 ret = Identity();
|
||||
@@ -47,7 +46,7 @@ PD_CORE_API Mat4 Mat4::RotateY(float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::RotateZ(float a) {
|
||||
PD_API Mat4 Mat4::RotateZ(float a) {
|
||||
float c = std::cos(a);
|
||||
float s = std::sin(a);
|
||||
Mat4 ret = Identity();
|
||||
@@ -58,7 +57,7 @@ PD_CORE_API Mat4 Mat4::RotateZ(float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
|
||||
PD_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
|
||||
float s = std::sin(a);
|
||||
float c = std::cos(a);
|
||||
float t = 1.f - c;
|
||||
@@ -81,7 +80,7 @@ PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
PD_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
float _fov = std::tan(fov / 2.f);
|
||||
Mat4 ret;
|
||||
ret(0, 0) = 1.f / (aspect * _fov);
|
||||
@@ -98,7 +97,7 @@ PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
|
||||
PD_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
|
||||
const fvec3& up) {
|
||||
auto f = fvec3(center - pos).Normalize();
|
||||
auto s = f.Cross(up).Normalize();
|
||||
Executable → Regular
+9
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,7 +24,7 @@ SOFTWARE.
|
||||
#include <pd/core/strings.hpp>
|
||||
|
||||
namespace PD::Strings {
|
||||
PD_CORE_API bool StringEndsWith(const std::string& str,
|
||||
PD_API bool StringEndsWith(const std::string& str,
|
||||
const std::vector<std::string>& exts) {
|
||||
// Changed order to not do an substr on empty string
|
||||
if (str.empty()) {
|
||||
@@ -44,7 +44,7 @@ PD_CORE_API bool StringEndsWith(const std::string& str,
|
||||
return false;
|
||||
}
|
||||
|
||||
PD_CORE_API std::wstring MakeWstring(const std::string& s) {
|
||||
PD_API std::wstring MakeWstring(const std::string& s) {
|
||||
// Manually convert to wstring as they removed wstring_convert :(
|
||||
std::wstring result;
|
||||
size_t i = 0;
|
||||
@@ -85,7 +85,7 @@ PD_CORE_API std::wstring MakeWstring(const std::string& s) {
|
||||
return result;
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
|
||||
PD_API const std::string FormatNanos(unsigned long long nanos) {
|
||||
// Based on some code of my minecraft plugins
|
||||
if (nanos < 1000) {
|
||||
return std::format("{}ns", nanos);
|
||||
@@ -106,7 +106,7 @@ PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
|
||||
return "";
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
|
||||
PD_API const std::string FormatMillis(unsigned long long millis) {
|
||||
// Original Code can be found in some of my mv plugins
|
||||
if (millis < 1000) {
|
||||
return std::format("{}ms", millis);
|
||||
@@ -121,7 +121,7 @@ PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
|
||||
return "";
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
|
||||
PD_API const std::string FormatBytes(unsigned long long bytes) {
|
||||
static const std::vector<std::string> endings = {
|
||||
"B", "KB", "MB", "GB", "TB", "Unk",
|
||||
};
|
||||
@@ -137,7 +137,7 @@ PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
|
||||
return std::format("{:.1f} {}", b, endings[i]);
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string GetFileName(const std::string& path,
|
||||
PD_API const std::string GetFileName(const std::string& path,
|
||||
const std::string& saperators) {
|
||||
auto pos = path.find_last_of(saperators);
|
||||
if (pos != path.npos) {
|
||||
@@ -147,7 +147,7 @@ PD_CORE_API const std::string GetFileName(const std::string& path,
|
||||
return path;
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
|
||||
PD_API const std::string PathRemoveExtension(const std::string& path) {
|
||||
auto pos = path.find_last_of('.');
|
||||
if (pos != path.npos) {
|
||||
return path.substr(0, pos);
|
||||
@@ -156,7 +156,7 @@ PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
PD_CORE_API u32 FastHash(const std::string& s) {
|
||||
PD_API u32 FastHash(const std::string& s) {
|
||||
u32 hash = 5381;
|
||||
for (auto& it : s) {
|
||||
hash = (hash * 33) + static_cast<u8>(it);
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,25 +25,25 @@ SOFTWARE.
|
||||
#include <pd/drivers/drivers.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_CORE_API Timer::Timer(bool autostart) {
|
||||
PD_API Timer::Timer(bool autostart) {
|
||||
pIsRunning = autostart;
|
||||
Reset();
|
||||
}
|
||||
|
||||
PD_CORE_API void Timer::Reset() {
|
||||
PD_API void Timer::Reset() {
|
||||
pStart = OS::GetTime();
|
||||
pNow = pStart;
|
||||
}
|
||||
|
||||
PD_CORE_API void Timer::Update() {
|
||||
PD_API void Timer::Update() {
|
||||
if (pIsRunning) {
|
||||
pNow = OS::GetTime();
|
||||
}
|
||||
}
|
||||
|
||||
PD_CORE_API void Timer::Pause() { pIsRunning = false; }
|
||||
PD_CORE_API void Timer::Rseume() { pIsRunning = true; }
|
||||
PD_CORE_API bool Timer::IsRunning() const { return pIsRunning; }
|
||||
PD_CORE_API u64 Timer::Get() { return pNow - pStart; }
|
||||
PD_CORE_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
|
||||
PD_API void Timer::Pause() { pIsRunning = false; }
|
||||
PD_API void Timer::Rseume() { pIsRunning = true; }
|
||||
PD_API bool Timer::IsRunning() const { return pIsRunning; }
|
||||
PD_API u64 Timer::Get() { return pNow - pStart; }
|
||||
PD_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
|
||||
} // namespace PD
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,12 +25,12 @@ SOFTWARE.
|
||||
#include <pd/drivers/drivers.hpp>
|
||||
|
||||
namespace PD::TT {
|
||||
PD_CORE_API void Beg(const std::string& id) {
|
||||
PD_API void Beg(const std::string& id) {
|
||||
auto trace = OS::GetTraceRef(id);
|
||||
trace->SetStart(PD::OS::GetNanoTime());
|
||||
}
|
||||
|
||||
PD_CORE_API void End(const std::string& id) {
|
||||
PD_API void End(const std::string& id) {
|
||||
auto trace = OS::GetTraceRef(id);
|
||||
trace->SetEnd(PD::OS::GetNanoTime());
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,10 +22,9 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/drivers/gfx.hpp>
|
||||
#include <pd/drivers/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_DEF_EXP(GfxDriver::Ref, Gfx::pGfx);
|
||||
GfxDriver::Ref Gfx::pGfx = nullptr;
|
||||
|
||||
void Gfx::Init(GfxDriver::Ref d) {
|
||||
if (!d) {
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/drivers/hid.hpp>
|
||||
|
||||
namespace PD {
|
||||
HidDriver::Ref Hid::pHid = nullptr;
|
||||
|
||||
bool HidDriver::IsEvent(Event e, Key keys) { return KeyEvents[0][e] & keys; }
|
||||
bool HidDriver::IsEvent(Event e, KbKey keys) {
|
||||
return KbKeyEvents[0][e].Has(keys);
|
||||
}
|
||||
|
||||
void HidDriver::SwapTab() {
|
||||
auto tkd = KeyEvents[1][Event_Down];
|
||||
auto tkh = KeyEvents[1][Event_Held];
|
||||
auto tku = KeyEvents[1][Event_Up];
|
||||
KeyEvents[1][Event_Down] = KeyEvents[0][Event_Down];
|
||||
KeyEvents[1][Event_Held] = KeyEvents[0][Event_Held];
|
||||
KeyEvents[1][Event_Up] = KeyEvents[0][Event_Up];
|
||||
KeyEvents[0][Event_Down] = tkd;
|
||||
KeyEvents[0][Event_Held] = tkh;
|
||||
KeyEvents[0][Event_Up] = tku;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this func has no verride, still clear the stats
|
||||
* cause if they are empty this leads to a crash
|
||||
*/
|
||||
void HidDriver::Update() {
|
||||
// Clear States
|
||||
for (int i = 0; i < 2; i++) {
|
||||
KeyEvents[i][Event_Down] = 0;
|
||||
KeyEvents[i][Event_Held] = 0;
|
||||
KeyEvents[i][Event_Up] = 0;
|
||||
for (auto& it : KbKeyEvents[i]) {
|
||||
it.second = Event_Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace PD
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,10 +22,9 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/drivers/os.hpp>
|
||||
#include <pd/drivers/pd_p_api.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_DEF_EXP(OsDriver::Ref, OS::pOs);
|
||||
OsDriver::Ref OS::pOs = nullptr;
|
||||
|
||||
TT::Res::Ref& OsDriver::GetTraceRef(const std::string& id) {
|
||||
if (!pTraces.count(id)) {
|
||||
@@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,4 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#define PD_DEF_EXP(x, y) x y = nullptr
|
||||
#define PD_IMAGE_IMPLEMENTATION
|
||||
#include <pd/external/stb_image.hpp>
|
||||
#define PD_TRUETYPE_IMPLEMENTATION
|
||||
#include <pd/external/stb_truetype.hpp>
|
||||
Executable → Regular
+21
-24
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,49 +22,47 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef PD_IMAGE_BUILD_SHARED
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define PD_IMAGE_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#include <pd/external/stb_image.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <pd/external/stb_image.hpp>
|
||||
#include <pd/image/image.hpp>
|
||||
#include <pd/image/img_convert.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_IMAGE_API void Image::Load(const std::string& path) {
|
||||
u8* img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
|
||||
PD_API void Image::Load(const std::string& path) {
|
||||
u8* img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
|
||||
if (fmt == 3) {
|
||||
stbi_image_free(img);
|
||||
img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3);
|
||||
pdi_image_free(img);
|
||||
img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3);
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
|
||||
pFmt = RGB;
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
} else if (fmt == 4) {
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
|
||||
pFmt = RGBA;
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
}
|
||||
}
|
||||
PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) {
|
||||
PD_API void Image::Load(const std::vector<u8>& buf) {
|
||||
u8* img =
|
||||
stbi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, 4);
|
||||
pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, 4);
|
||||
if (fmt == 3) {
|
||||
stbi_image_free(img);
|
||||
img = stbi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt,
|
||||
pdi_image_free(img);
|
||||
img = pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt,
|
||||
3);
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
|
||||
pFmt = RGB;
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
} else if (fmt == 4) {
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
pFmt = RGBA;
|
||||
}
|
||||
}
|
||||
PD_IMAGE_API void Image::Copy(const std::vector<u8>& buf, int w, int h,
|
||||
int bpp) {
|
||||
PD_API void Image::Copy(const std::vector<u8>& buf, int w, int h, int bpp) {
|
||||
this->fmt = bpp;
|
||||
if (buf.size() != (size_t)w * h * bpp) {
|
||||
// Size Error
|
||||
@@ -77,7 +74,7 @@ PD_IMAGE_API void Image::Copy(const std::vector<u8>& buf, int w, int h,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::FlipHorizontal() {
|
||||
PD_API void Image::FlipHorizontal() {
|
||||
/**
|
||||
* Dont know if i am brain dead but i think this code
|
||||
* should Horizpntal flip an image
|
||||
@@ -97,7 +94,7 @@ PD_IMAGE_API void Image::FlipHorizontal() {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::FlipVertical() {
|
||||
PD_API void Image::FlipVertical() {
|
||||
/**
|
||||
* Dont know if i am brain dead but i think this code
|
||||
* should Vertical flip an image
|
||||
@@ -117,7 +114,7 @@ PD_IMAGE_API void Image::FlipVertical() {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::Convert(Image::Ref img, Image::Format dst) {
|
||||
PD_API void Image::Convert(Image::Ref img, Image::Format dst) {
|
||||
if (img->pFmt == dst) {
|
||||
return;
|
||||
} else if (img->pFmt == Image::RGB && dst == Image::BGR) {
|
||||
@@ -164,7 +161,7 @@ PD_IMAGE_API void Image::Convert(Image::Ref img, Image::Format dst) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API int Image::Fmt2Bpp(Format fmt) {
|
||||
PD_API int Image::Fmt2Bpp(Format fmt) {
|
||||
switch (fmt) {
|
||||
case RGBA:
|
||||
case ABGR:
|
||||
@@ -184,7 +181,7 @@ PD_IMAGE_API int Image::Fmt2Bpp(Format fmt) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::ReTile(Image::Ref img,
|
||||
PD_API void Image::ReTile(Image::Ref img,
|
||||
std::function<u32(int x, int y, int w)> src,
|
||||
std::function<u32(int x, int y, int w)> dst) {
|
||||
std::vector<PD::u8> cpy = img->pBuffer;
|
||||
Executable → Regular
+10
-13
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +28,7 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace ImgBlur {
|
||||
PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
|
||||
PD_API std::vector<float> GaussianKernel(int r, float si) {
|
||||
/// Define radius as r to be shorter
|
||||
int size = 2 * r + 1;
|
||||
std::vector<float> kernel(size);
|
||||
@@ -45,22 +44,20 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
|
||||
}
|
||||
return kernel;
|
||||
}
|
||||
PD_IMAGE_API void GaussianBlur(std::vector<u8> &buf, int w, int h, float radius,
|
||||
float si,
|
||||
std::function<int(int, int, int)> idxfn) {
|
||||
PD_API void GaussianBlur(std::vector<u8>& buf, int w, int h, float radius,
|
||||
float si, std::function<int(int, int, int)> idxfn) {
|
||||
GaussianBlur(buf.data(), w, h, 4, radius, si, idxfn);
|
||||
}
|
||||
|
||||
PD_IMAGE_API void GaussianBlur(void *buf, int w, int h, int bpp, float radius,
|
||||
float si,
|
||||
std::function<int(int, int, int)> idxfn) {
|
||||
PD_API void GaussianBlur(void* buf, int w, int h, int bpp, float radius,
|
||||
float si, std::function<int(int, int, int)> idxfn) {
|
||||
if (bpp != 4 && bpp != 3) {
|
||||
return;
|
||||
}
|
||||
std::vector<float> kernel = GaussianKernel(radius, si);
|
||||
int hks = kernel.size() / 2;
|
||||
int end = w * h * bpp;
|
||||
std::vector<unsigned char> res((u8 *)buf, ((u8 *)buf) + end);
|
||||
std::vector<unsigned char> res((u8*)buf, ((u8*)buf) + end);
|
||||
ImgConvert::Reverse32(res, w, h);
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -72,9 +69,9 @@ PD_IMAGE_API void GaussianBlur(void *buf, int w, int h, int bpp, float radius,
|
||||
int idx = idxfn(xoff, yoff, w) * 4;
|
||||
|
||||
float weight = kernel[ky + hks] * kernel[kx + hks];
|
||||
r += ((u8 *)buf)[idx] * weight;
|
||||
g += ((u8 *)buf)[idx + 1] * weight;
|
||||
b += ((u8 *)buf)[idx + 2] * weight;
|
||||
r += ((u8*)buf)[idx] * weight;
|
||||
g += ((u8*)buf)[idx + 1] * weight;
|
||||
b += ((u8*)buf)[idx + 2] * weight;
|
||||
}
|
||||
}
|
||||
int idx = idxfn(x, y, w) * bpp;
|
||||
Executable → Regular
+7
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,8 +25,8 @@ SOFTWARE.
|
||||
|
||||
namespace PD::ImgConvert {
|
||||
|
||||
PD_IMAGE_API void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h) {
|
||||
PD_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -40,8 +40,8 @@ PD_IMAGE_API void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h) {
|
||||
PD_API void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -54,7 +54,7 @@ PD_IMAGE_API void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h) {
|
||||
PD_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
int i = y * w + x;
|
||||
@@ -68,7 +68,7 @@ PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void ReverseBuf(std::vector<u8> &buf, size_t bpp, int w, int h) {
|
||||
PD_API void ReverseBuf(std::vector<u8>& buf, size_t bpp, int w, int h) {
|
||||
std::vector<u8> cpy = buf;
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/lithium/command.hpp>
|
||||
|
||||
PD_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
||||
if (pPoolIdx >= pPool.size()) {
|
||||
Resize(pPool.size() + 128);
|
||||
}
|
||||
Command::Ref nu = pPool[pPoolIdx++];
|
||||
nu->Layer = Layer;
|
||||
nu->Index = pPoolIdx - 1;
|
||||
return nu;
|
||||
}
|
||||
|
||||
PD_API void PD::Li::CmdPool::Init(size_t initial_size) { Resize(initial_size); }
|
||||
|
||||
PD_API void PD::Li::CmdPool::Deinit() {
|
||||
for (auto it : pPool) {
|
||||
Command::Delete(it);
|
||||
}
|
||||
pPool.clear();
|
||||
}
|
||||
|
||||
PD_API void PD::Li::CmdPool::Resize(size_t nulen) {
|
||||
if (nulen <= pPool.size()) {
|
||||
return; // no idea yet
|
||||
}
|
||||
size_t oldlen = pPool.size();
|
||||
pPool.resize(nulen);
|
||||
for (size_t i = oldlen; i < pPool.size(); i++) {
|
||||
pPool[i] = Command::New();
|
||||
}
|
||||
}
|
||||
|
||||
PD_API void PD::Li::CmdPool::Reset() {
|
||||
for (u32 i = 0; i < pPoolIdx; i++) {
|
||||
pPool[i]->Clear();
|
||||
}
|
||||
pPoolIdx = 0;
|
||||
}
|
||||
|
||||
PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) const {
|
||||
return pPool[idx];
|
||||
}
|
||||
PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) { return pPool[idx]; }
|
||||
|
||||
size_t PD::Li::CmdPool::Size() const { return pPoolIdx; }
|
||||
size_t PD::Li::CmdPool::Cap() const { return pPool.size(); }
|
||||
|
||||
PD_API void PD::Li::CmdPool::Merge(CmdPool& p) {
|
||||
Copy(p);
|
||||
p.Reset();
|
||||
}
|
||||
|
||||
PD_API void PD::Li::CmdPool::Copy(CmdPool& p) {
|
||||
if (pPoolIdx + p.Size() > pPool.size()) {
|
||||
Resize(pPoolIdx + p.Size());
|
||||
}
|
||||
for (size_t i = 0; i < p.Size(); i++) {
|
||||
size_t idx = pPoolIdx++;
|
||||
*pPool[idx] = *p.GetCmd(i);
|
||||
pPool[idx]->Index = idx;
|
||||
pPool[idx]->Layer += Layer;
|
||||
}
|
||||
}
|
||||
|
||||
PD_API void PD::Li::CmdPool::Sort() {
|
||||
if (pPoolIdx < 2) return;
|
||||
std::sort(begin(), end(), pTheOrder);
|
||||
}
|
||||
|
||||
PD_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
|
||||
const Command::Ref& b) {
|
||||
if (a->Layer == b->Layer) {
|
||||
if (a->Tex == b->Tex) {
|
||||
return a->Index < b->Index;
|
||||
}
|
||||
return a->Tex < b->Tex;
|
||||
}
|
||||
return a->Layer < b->Layer;
|
||||
}
|
||||
Executable → Regular
+64
-76
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -31,12 +30,22 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
PD_LITHIUM_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
|
||||
PD_API DrawList::DrawList(int initial_size) {
|
||||
DrawSolid();
|
||||
pPool.Init(initial_size);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::Clear() {
|
||||
PD_API DrawList::~DrawList() {
|
||||
Clear();
|
||||
pPool.Deinit();
|
||||
}
|
||||
|
||||
PD_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
|
||||
|
||||
PD_API void DrawList::Clear() {
|
||||
pNumIndices = 0;
|
||||
pNumVertices = 0;
|
||||
pDrawList.clear();
|
||||
pPool.Reset();
|
||||
pPath.clear();
|
||||
if (pCurrentFont) {
|
||||
pCurrentFont->CleanupTMS();
|
||||
@@ -46,27 +55,25 @@ PD_LITHIUM_API void DrawList::Clear() {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::AddCommand(Command::Ref v) {
|
||||
pNumIndices += v->IndexBuffer.size();
|
||||
pNumVertices += v->VertexBuffer.size();
|
||||
pDrawList.push_back(std::move(v));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
|
||||
for (size_t i = 0; i < list->pDrawList.size(); i++) {
|
||||
PD_API void DrawList::Merge(DrawList::Ref list) {
|
||||
pPool.Merge(list->pPool);
|
||||
/*for (size_t i = 0; i < list->pDrawList.size(); i++) {
|
||||
pNumIndices += list->pDrawList[i]->IndexBuffer.size();
|
||||
pNumVertices += list->pDrawList[i]->VertexBuffer.size();
|
||||
pDrawList.push_back(std::move(list->pDrawList[i]));
|
||||
}
|
||||
auto cmd = pPool.NewCmd();
|
||||
pDrawList.push_back(list->pDrawList[i]);
|
||||
}*/
|
||||
/** Make sure The list gets cleared */
|
||||
list->Clear();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::Optimize() {
|
||||
PD_API void DrawList::Copy(DrawList::Ref list) { pPool.Copy(list->pPool); }
|
||||
|
||||
PD_API void DrawList::Optimize() {
|
||||
#ifndef NDEBUG
|
||||
PD::TT::Scope s("Optimize");
|
||||
#endif
|
||||
std::sort(pDrawList.begin(), pDrawList.end(),
|
||||
/*std::sort(pDrawList.begin(), pDrawList.end(),
|
||||
[](const PD::Li::Command::Ref &a, const PD::Li::Command::Ref &b) {
|
||||
if (a->Layer == b->Layer) { // Same layer
|
||||
if (a->Tex == b->Tex) { // same tex
|
||||
@@ -75,28 +82,26 @@ PD_LITHIUM_API void DrawList::Optimize() {
|
||||
return a->Tex < b->Tex; // order by address
|
||||
}
|
||||
return a->Layer < b->Layer; // Order by layer
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Command::Ref DrawList::PreGenerateCmd() {
|
||||
Command::Ref cmd = Command::New();
|
||||
cmd->Layer = pLayer;
|
||||
cmd->Index = pDrawList.size();
|
||||
cmd->Tex = CurrentTex;
|
||||
pClipCmd(cmd.get());
|
||||
PD_API Command::Ref DrawList::GetNewCmd() {
|
||||
Command::Ref cmd = pPool.NewCmd();
|
||||
cmd->Index = pPool.Size() - 1;
|
||||
cmd->Tex = CurrentTex->Address;
|
||||
pClipCmd(cmd);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::pClipCmd(Command *cmd) {
|
||||
PD_API void DrawList::pClipCmd(Command::Ref cmd) {
|
||||
if (!pClipRects.empty()) {
|
||||
cmd->ScissorOn = true;
|
||||
cmd->ScissorRect = ivec4(pClipRects.top());
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathArcToN(const fvec2 &c, float radius,
|
||||
float a_min, float a_max,
|
||||
int segments) {
|
||||
PD_API void DrawList::PathArcToN(const fvec2& c, float radius, float a_min,
|
||||
float a_max, int segments) {
|
||||
// Path.push_back(c);
|
||||
PathReserve(segments + 1);
|
||||
for (int i = 0; i < segments; i++) {
|
||||
@@ -105,8 +110,8 @@ PD_LITHIUM_API void DrawList::PathArcToN(const fvec2 &c, float radius,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2 &c, float r,
|
||||
float amin, float amax, int s) {
|
||||
PD_API void DrawList::PathFastArcToN(const fvec2& c, float r, float amin,
|
||||
float amax, int s) {
|
||||
/**
|
||||
* Funcion with less division overhead
|
||||
* Usefull for stuff where a lot of calculations are required
|
||||
@@ -119,7 +124,7 @@ PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2 &c, float r,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
PD_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
PathAdd(vec2(b.x, a.y));
|
||||
@@ -151,8 +156,7 @@ PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
|
||||
u32 flags) {
|
||||
PD_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding, u32 flags) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
PathAdd(vec2(b.x, a.y));
|
||||
@@ -201,37 +205,35 @@ PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawRect(const fvec2 &pos, const fvec2 &size,
|
||||
u32 color, int thickness) {
|
||||
PD_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size, u32 color,
|
||||
int thickness) {
|
||||
PathRect(pos, pos + size);
|
||||
// Flags is currently hardcoded (1 = close)
|
||||
PathStroke(color, thickness, 1);
|
||||
}
|
||||
void DrawList::DrawRectFilled(const fvec2 &pos, const fvec2 &size, u32 color) {
|
||||
void DrawList::DrawRectFilled(const fvec2& pos, const fvec2& size, u32 color) {
|
||||
PathRect(pos, pos + size);
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTriangle(const fvec2 &a, const fvec2 &b,
|
||||
const fvec2 &c, u32 color,
|
||||
int thickness) {
|
||||
PD_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color, int thickness) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathStroke(color, thickness, 1);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTriangleFilled(const fvec2 &a, const fvec2 &b,
|
||||
const fvec2 &c, u32 color) {
|
||||
PD_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawCircle(const fvec2 ¢er, float rad,
|
||||
u32 color, int num_segments,
|
||||
int thickness) {
|
||||
PD_API void DrawList::DrawCircle(const fvec2& center, float rad, u32 color,
|
||||
int num_segments, int thickness) {
|
||||
if (num_segments <= 0) {
|
||||
// Auto Segment
|
||||
} else {
|
||||
@@ -242,7 +244,7 @@ PD_LITHIUM_API void DrawList::DrawCircle(const fvec2 ¢er, float rad,
|
||||
PathStroke(color, thickness, (1 << 0));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2 ¢er, float rad,
|
||||
PD_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||
u32 color, int num_segments) {
|
||||
if (num_segments <= 0) {
|
||||
// Auto Segment
|
||||
@@ -254,13 +256,13 @@ PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2 ¢er, float rad,
|
||||
}
|
||||
|
||||
// TODO: Don't render OOS
|
||||
PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2> &points,
|
||||
u32 clr, u32 flags, int thickness) {
|
||||
PD_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points, u32 clr,
|
||||
u32 flags, int thickness) {
|
||||
if (points.size() < 2) {
|
||||
return;
|
||||
}
|
||||
DrawSolid();
|
||||
auto cmd = PreGenerateCmd();
|
||||
auto cmd = GetNewCmd();
|
||||
bool close = (flags & (1 << 0));
|
||||
int num_points = close ? (int)points.size() : (int)points.size() - 1;
|
||||
if (flags & (1 << 1)) {
|
||||
@@ -270,53 +272,39 @@ PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2> &points,
|
||||
for (int i = 0; i < num_points; i++) {
|
||||
int j = (i + 1) == (int)points.size() ? 0 : (i + 1);
|
||||
auto line = Renderer::PrimLine(points[i], points[j], thickness);
|
||||
Renderer::CmdQuad(cmd.get(), line, vec4(0.f, 1.f, 1.f, 0.f), clr);
|
||||
Renderer::CmdQuad(cmd, line, vec4(0.f, 1.f, 1.f, 0.f), clr);
|
||||
}
|
||||
}
|
||||
AddCommand(std::move(cmd));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
|
||||
const std::vector<fvec2> &points, u32 clr) {
|
||||
PD_API void DrawList::DrawConvexPolyFilled(const std::vector<fvec2>& points,
|
||||
u32 clr) {
|
||||
if (points.size() < 3) {
|
||||
return; // Need at least three points
|
||||
}
|
||||
auto cmd = PreGenerateCmd();
|
||||
Renderer::CmdConvexPolyFilled(cmd.get(), points, clr, CurrentTex);
|
||||
AddCommand(std::move(cmd));
|
||||
auto cmd = GetNewCmd();
|
||||
Renderer::CmdConvexPolyFilled(cmd, points, clr, CurrentTex);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawText(const fvec2 &pos,
|
||||
const std::string &text, u32 color) {
|
||||
PD_API void DrawList::DrawText(const fvec2& pos, const std::string& text,
|
||||
u32 color) {
|
||||
if (!pCurrentFont) {
|
||||
return;
|
||||
}
|
||||
std::vector<Command::Ref> cmds;
|
||||
pCurrentFont->CmdTextEx(cmds, pos, color, pFontScale, text);
|
||||
for (size_t i = 0; i < cmds.size(); i++) {
|
||||
cmds[i]->Index = pDrawList.size() + i;
|
||||
cmds[i]->Layer = pLayer;
|
||||
AddCommand(std::move(cmds[i]));
|
||||
}
|
||||
pCurrentFont->CmdTextEx(pPool, pos, color, pFontScale, text);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTextEx(const fvec2 &p,
|
||||
const std::string &text, u32 color,
|
||||
LiTextFlags flags, const fvec2 &box) {
|
||||
PD_API void DrawList::DrawTextEx(const fvec2& p, const std::string& text,
|
||||
u32 color, LiTextFlags flags,
|
||||
const fvec2& box) {
|
||||
if (!pCurrentFont) {
|
||||
return;
|
||||
}
|
||||
std::vector<Command::Ref> cmds;
|
||||
pCurrentFont->CmdTextEx(cmds, p, color, pFontScale, text, flags, box);
|
||||
for (size_t i = 0; i < cmds.size(); i++) {
|
||||
cmds[i]->Index = pDrawList.size() + i;
|
||||
cmds[i]->Layer = pLayer;
|
||||
AddCommand(std::move(cmds[i]));
|
||||
}
|
||||
pCurrentFont->CmdTextEx(pPool, p, color, pFontScale, text, flags, box);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawLine(const fvec2 &a, const fvec2 &b,
|
||||
u32 color, int t) {
|
||||
PD_API void DrawList::DrawLine(const fvec2& a, const fvec2& b, u32 color,
|
||||
int t) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathStroke(color, t);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user