flatten 20260225

This commit is contained in:
Timothy Prepscius
2026-02-25 12:32:21 -05:00
commit 20d622f1c6
113 changed files with 57358 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.DS_Store
*.pyc
xcuserdata
.bin

View File

@@ -0,0 +1,814 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
F61AAB4A28A0AE6600E2ABDB /* FontSTB_SDF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F61AAB4928A0ADD300E2ABDB /* FontSTB_SDF.cpp */; };
F61AAB4B28A0AE6600E2ABDB /* FontSTB_SDF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F61AAB4928A0ADD300E2ABDB /* FontSTB_SDF.cpp */; };
F62773D029425DC500FA748D /* FontMulti.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F62773CB29425AA700FA748D /* FontMulti.cpp */; };
F62773D129425DC600FA748D /* FontMulti.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F62773CB29425AA700FA748D /* FontMulti.cpp */; };
F62773D52942610F00FA748D /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F62773CE29425B2000FA748D /* Font.cpp */; };
F62773D62942611000FA748D /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F62773CE29425B2000FA748D /* Font.cpp */; };
F64035B429452048007B0A67 /* AtlasAggregate.h in Headers */ = {isa = PBXBuildFile; fileRef = F66AE43A288F2B6900668C66 /* AtlasAggregate.h */; };
F64035B529452048007B0A67 /* AtlasAggregate.h in Headers */ = {isa = PBXBuildFile; fileRef = F66AE43A288F2B6900668C66 /* AtlasAggregate.h */; };
F650BA5D289064AB006D2316 /* IconAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F650BA5C289064AB006D2316 /* IconAtlas.cpp */; };
F650BA5E289064AB006D2316 /* IconAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F650BA5C289064AB006D2316 /* IconAtlas.cpp */; };
F662BBE02BE5DEDD000BDDC5 /* Memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F608ABC52828714B005C276B /* Memory.cpp */; };
F66AE435288F241900668C66 /* FontSTB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F66AE434288F23DB00668C66 /* FontSTB.cpp */; };
F66AE436288F241900668C66 /* FontSTB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F66AE434288F23DB00668C66 /* FontSTB.cpp */; };
F66AE43C288F2BBB00668C66 /* AtlasAggregate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F66AE43B288F2B6F00668C66 /* AtlasAggregate.cpp */; };
F66AE43D288F2BBC00668C66 /* AtlasAggregate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F66AE43B288F2B6F00668C66 /* AtlasAggregate.cpp */; };
F6A3CDCB293413670062FEC1 /* PushOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6A3CDCA293411420062FEC1 /* PushOffsets.cpp */; };
F6A3CDCE29341E7A0062FEC1 /* PushOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6A3CDCD29341D8E0062FEC1 /* PushOffsets.cpp */; };
F6A3CDCF29341E7B0062FEC1 /* PushOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6A3CDCD29341D8E0062FEC1 /* PushOffsets.cpp */; };
F6A3CDD029341EB40062FEC1 /* PushOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6A3CDCD29341D8E0062FEC1 /* PushOffsets.cpp */; };
F6BF6DD529AE56CC00D84632 /* AtlasAggregate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6BF6DD429AE56CC00D84632 /* AtlasAggregate.cpp */; };
F6BF6DD629AE56CC00D84632 /* AtlasAggregate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6BF6DD429AE56CC00D84632 /* AtlasAggregate.cpp */; };
F6BF6DDC29AE609800D84632 /* AtlasLayers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6BF6DDB29AE609800D84632 /* AtlasLayers.cpp */; };
F6BF6DDD29AE609800D84632 /* AtlasLayers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6BF6DDB29AE609800D84632 /* AtlasLayers.cpp */; };
F6CA38572933A7ED00556E1C /* MemoryStandard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6CA38552933A58F00556E1C /* MemoryStandard.cpp */; };
F6CA38582933A7EE00556E1C /* MemoryStandard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6CA38552933A58F00556E1C /* MemoryStandard.cpp */; };
F6CA38692933B0B100556E1C /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6CA38682933B09300556E1C /* main.cpp */; };
F6DECA7F288EFD0700635410 /* Atlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6DECA7E288EF35500635410 /* Atlas.cpp */; };
F6DECA80288EFD0700635410 /* Atlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6DECA7E288EF35500635410 /* Atlas.cpp */; };
F6DECA83288F031400635410 /* GlyphAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6DECA82288F031400635410 /* GlyphAtlas.cpp */; };
F6DECA84288F031400635410 /* GlyphAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6DECA82288F031400635410 /* GlyphAtlas.cpp */; };
F6E540AE2BDE9B3900CE3A75 /* AtlasAggregate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F65B0E9B2BD6057500ED927A /* AtlasAggregate.cpp */; };
F6E540AF2BDE9B3D00CE3A75 /* AtlasAggregate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F65B0E9B2BD6057500ED927A /* AtlasAggregate.cpp */; };
F6E540B12BDEB52300CE3A75 /* opengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6E540B02BDE9D2A00CE3A75 /* opengl.cpp */; };
F6E540B22BDEB52400CE3A75 /* opengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6E540B02BDE9D2A00CE3A75 /* opengl.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
F6CA385D2933AD8400556E1C /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
F608ABB328287108005C276B /* libCore_Graphics_Render.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCore_Graphics_Render.a; sourceTree = BUILT_PRODUCTS_DIR; };
F608ABBC2828714B005C276B /* imgui.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = imgui.h; sourceTree = "<group>"; };
F608ABBE2828714B005C276B /* bgfx.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = bgfx.cpp; sourceTree = "<group>"; };
F608ABBF2828714B005C276B /* bgfx.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bgfx.h; sourceTree = "<group>"; };
F608ABC22828714B005C276B /* vuku.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vuku.h; sourceTree = "<group>"; };
F608ABC42828714B005C276B /* Geometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Geometry.cpp; sourceTree = "<group>"; };
F608ABC52828714B005C276B /* Memory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Memory.cpp; sourceTree = "<group>"; };
F612B9292B9CA92B00519EB6 /* Atlas.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Atlas.h; sourceTree = "<group>"; };
F6198B142BF1758100A57A00 /* Renderer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Renderer.cpp; sourceTree = "<group>"; };
F61AAB4728A0ADD200E2ABDB /* FontSTB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSTB.h; sourceTree = "<group>"; };
F61AAB4828A0ADD200E2ABDB /* FontSTB_SDF.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FontSTB_SDF.hpp; sourceTree = "<group>"; };
F61AAB4928A0ADD300E2ABDB /* FontSTB_SDF.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontSTB_SDF.cpp; sourceTree = "<group>"; };
F61F9BF02C6E4DD200F79137 /* Makefile.project */ = {isa = PBXFileReference; lastKnownFileType = text; path = Makefile.project; sourceTree = "<group>"; };
F625F8872BEFC4ED000A2E87 /* vuku.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = vuku.cpp; sourceTree = "<group>"; };
F62773CA29425A3F00FA748D /* FontMulti.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FontMulti.hpp; sourceTree = "<group>"; };
F62773CB29425AA700FA748D /* FontMulti.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontMulti.cpp; sourceTree = "<group>"; };
F62773CC29425AC400FA748D /* Font.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Font.hpp; sourceTree = "<group>"; };
F62773CD29425AEA00FA748D /* Font.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = "<group>"; };
F62773CE29425B2000FA748D /* Font.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Font.cpp; sourceTree = "<group>"; };
F62773CF29425CB800FA748D /* AtlasTypedSource.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasTypedSource.hpp; sourceTree = "<group>"; };
F640CF7C2AA6ACBB0011E76D /* vulkan.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = vulkan.hpp; sourceTree = "<group>"; };
F64233022BE974FD0050517F /* shader */ = {isa = PBXFileReference; lastKnownFileType = folder; path = shader; sourceTree = "<group>"; };
F64233032BE9750E0050517F /* shader */ = {isa = PBXFileReference; lastKnownFileType = folder; path = shader; sourceTree = "<group>"; };
F650BA5B289064AB006D2316 /* IconAtlas.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IconAtlas.hpp; sourceTree = "<group>"; };
F650BA5C289064AB006D2316 /* IconAtlas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IconAtlas.cpp; sourceTree = "<group>"; };
F650BA5F28906744006D2316 /* AtlasTyped.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasTyped.hpp; sourceTree = "<group>"; };
F650BA6328906E17006D2316 /* Atlas.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Atlas.hpp; sourceTree = "<group>"; };
F650BA6528906E7B006D2316 /* GlyphAtlas.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlyphAtlas.h; sourceTree = "<group>"; };
F650BA6628906EA0006D2316 /* IconAtlas.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IconAtlas.h; sourceTree = "<group>"; };
F650BA6728906F01006D2316 /* FontSTB.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FontSTB.hpp; sourceTree = "<group>"; };
F650BA6928907F14006D2316 /* AtlasCacher.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasCacher.hpp; sourceTree = "<group>"; };
F65B0E992BD6057500ED927A /* AtlasAggregate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasAggregate.hpp; sourceTree = "<group>"; };
F65B0E9A2BD6057500ED927A /* AtlasAggregate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AtlasAggregate.h; sourceTree = "<group>"; };
F65B0E9B2BD6057500ED927A /* AtlasAggregate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AtlasAggregate.cpp; sourceTree = "<group>"; };
F65B0E9C2BD605A600ED927A /* opengl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = opengl.h; sourceTree = "<group>"; };
F662BBC32BE443CB000BDDC5 /* Renderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = "<group>"; };
F662BBC42BE44590000BDDC5 /* Renderer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Renderer.hpp; sourceTree = "<group>"; };
F662BBDF2BE5DC83000BDDC5 /* Memory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Memory.h; sourceTree = "<group>"; };
F66AE433288F23D300668C66 /* FontSTB_SDF.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSTB_SDF.h; sourceTree = "<group>"; };
F66AE434288F23DB00668C66 /* FontSTB.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontSTB.cpp; sourceTree = "<group>"; };
F66AE43A288F2B6900668C66 /* AtlasAggregate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AtlasAggregate.h; sourceTree = "<group>"; };
F66AE43B288F2B6F00668C66 /* AtlasAggregate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AtlasAggregate.cpp; sourceTree = "<group>"; };
F66D9DEF29312107009D7D3D /* FontFileFromIOS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FontFileFromIOS.m; sourceTree = "<group>"; };
F68981672843FC5B0001F47E /* vku.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = vku.hpp; sourceTree = "<group>"; };
F68981682843FC5B0001F47E /* vku_framework.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = vku_framework.hpp; sourceTree = "<group>"; };
F689816A2843FC5B0001F47E /* vku.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = vku.hpp; sourceTree = "<group>"; };
F689816B2843FC5B0001F47E /* vku_framework.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = vku_framework.hpp; sourceTree = "<group>"; };
F6971F33282B1184008FBD17 /* libCore_Graphics_Render_iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCore_Graphics_Render_iOS.a; sourceTree = BUILT_PRODUCTS_DIR; };
F69B59C02BDD7D0C00280B50 /* AtlasOf.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasOf.hpp; sourceTree = "<group>"; };
F6A3CDC92933F9BE0062FEC1 /* PushOffsets.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushOffsets.h; sourceTree = "<group>"; };
F6A3CDCA293411420062FEC1 /* PushOffsets.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PushOffsets.cpp; sourceTree = "<group>"; };
F6A3CDCD29341D8E0062FEC1 /* PushOffsets.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PushOffsets.cpp; sourceTree = "<group>"; };
F6A3CDEE293461DD0062FEC1 /* PushConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushConstants.h; sourceTree = "<group>"; };
F6BF6DD329AE568B00D84632 /* AtlasAggregate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasAggregate.hpp; sourceTree = "<group>"; };
F6BF6DD429AE56CC00D84632 /* AtlasAggregate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AtlasAggregate.cpp; sourceTree = "<group>"; };
F6BF6DD729AE58B200D84632 /* AtlasAggregate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AtlasAggregate.h; sourceTree = "<group>"; };
F6BF6DD929AE5FDF00D84632 /* AtlasOf.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasOf.hpp; sourceTree = "<group>"; };
F6BF6DDA29AE607300D84632 /* AtlasLayers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AtlasLayers.h; sourceTree = "<group>"; };
F6BF6DDB29AE609800D84632 /* AtlasLayers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AtlasLayers.cpp; sourceTree = "<group>"; };
F6BF6DDE29AE668800D84632 /* AtlasAggregate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasAggregate.hpp; sourceTree = "<group>"; };
F6BF6DDF29AE669900D84632 /* AtlasLayers.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AtlasLayers.hpp; sourceTree = "<group>"; };
F6BF9BE32E3901F8002E6AF0 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
F6CA38532933A50900556E1C /* Memory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Memory.h; sourceTree = "<group>"; };
F6CA38542933A52A00556E1C /* Memory.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Memory.hpp; sourceTree = "<group>"; };
F6CA38552933A58F00556E1C /* MemoryStandard.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryStandard.cpp; sourceTree = "<group>"; };
F6CA38562933A7D400556E1C /* MemoryStandard.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MemoryStandard.hpp; sourceTree = "<group>"; };
F6CA385F2933AD8400556E1C /* Core_Graphics_Render_Tester */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Core_Graphics_Render_Tester; sourceTree = BUILT_PRODUCTS_DIR; };
F6CA38682933B09300556E1C /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
F6DC809C2BE86549008172E6 /* imgui-vulkan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "imgui-vulkan.h"; sourceTree = "<group>"; };
F6DC80A12BE8665F008172E6 /* imgui-opengl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "imgui-opengl.h"; sourceTree = "<group>"; };
F6DEACD72831C16C0001467D /* Makefile.def */ = {isa = PBXFileReference; lastKnownFileType = text; path = Makefile.def; sourceTree = "<group>"; };
F6DEACD82831C16C0001467D /* Makefile.project */ = {isa = PBXFileReference; lastKnownFileType = text; path = Makefile.project; sourceTree = "<group>"; };
F6DECA7D288EF06D00635410 /* Atlas.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Atlas.h; sourceTree = "<group>"; };
F6DECA7E288EF35500635410 /* Atlas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Atlas.cpp; sourceTree = "<group>"; };
F6DECA81288F031400635410 /* GlyphAtlas.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = GlyphAtlas.hpp; sourceTree = "<group>"; };
F6DECA82288F031400635410 /* GlyphAtlas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphAtlas.cpp; sourceTree = "<group>"; };
F6E359212DC97E5200B6ECAE /* imgui-vulkan-glfw.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "imgui-vulkan-glfw.h"; sourceTree = "<group>"; };
F6E540B02BDE9D2A00CE3A75 /* opengl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = opengl.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F608ABB128287108005C276B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F6971F2F282B1184008FBD17 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F6CA385C2933AD8400556E1C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F608ABAA28287108005C276B = {
isa = PBXGroup;
children = (
F6CA386A2933B0E600556E1C /* Frameworks */,
F6BF9BE32E3901F8002E6AF0 /* Makefile */,
F6DEACD72831C16C0001467D /* Makefile.def */,
F6DEACD82831C16C0001467D /* Makefile.project */,
F608ABB428287108005C276B /* Products */,
F6CA38672933B08A00556E1C /* tests */,
F61D7C402E38167D002A1AED /* tjp */,
);
sourceTree = "<group>";
};
F608ABB428287108005C276B /* Products */ = {
isa = PBXGroup;
children = (
F608ABB328287108005C276B /* libCore_Graphics_Render.a */,
F6971F33282B1184008FBD17 /* libCore_Graphics_Render_iOS.a */,
F6CA385F2933AD8400556E1C /* Core_Graphics_Render_Tester */,
);
name = Products;
sourceTree = "<group>";
};
F608ABBA2828711E005C276B /* core */ = {
isa = PBXGroup;
children = (
F608ABBB2828714B005C276B /* graphics */,
);
path = core;
sourceTree = "<group>";
};
F608ABBB2828714B005C276B /* graphics */ = {
isa = PBXGroup;
children = (
F61F9BF72C6E516500F79137 /* _tests */,
F66AE439288F2B3800668C66 /* atlas */,
F608ABBD2828714B005C276B /* bgfx */,
F6DC80A12BE8665F008172E6 /* imgui-opengl.h */,
F6DC809C2BE86549008172E6 /* imgui-vulkan.h */,
F6E359212DC97E5200B6ECAE /* imgui-vulkan-glfw.h */,
F608ABBC2828714B005C276B /* imgui.h */,
F66D9DEE293120F3009D7D3D /* interesting_not_for_real */,
F6CA38532933A50900556E1C /* Memory.h */,
F6CA38542933A52A00556E1C /* Memory.hpp */,
F6CA38552933A58F00556E1C /* MemoryStandard.cpp */,
F6CA38562933A7D400556E1C /* MemoryStandard.hpp */,
F6E540B02BDE9D2A00CE3A75 /* opengl.cpp */,
F65B0E9C2BD605A600ED927A /* opengl.h */,
F6198B142BF1758100A57A00 /* Renderer.cpp */,
F662BBC32BE443CB000BDDC5 /* Renderer.h */,
F662BBC42BE44590000BDDC5 /* Renderer.hpp */,
F64233032BE9750E0050517F /* shader */,
F68981662843FC5B0001F47E /* vku-new */,
F68981692843FC5B0001F47E /* vku-old */,
F608ABC02828714B005C276B /* vuku */,
F625F8872BEFC4ED000A2E87 /* vuku.cpp */,
F608ABC22828714B005C276B /* vuku.h */,
);
path = graphics;
sourceTree = "<group>";
};
F608ABBD2828714B005C276B /* bgfx */ = {
isa = PBXGroup;
children = (
F608ABBE2828714B005C276B /* bgfx.cpp */,
F608ABBF2828714B005C276B /* bgfx.h */,
);
path = bgfx;
sourceTree = "<group>";
};
F608ABC02828714B005C276B /* vuku */ = {
isa = PBXGroup;
children = (
F61F9BF92C6E51EF00F79137 /* _tests */,
F6A3CDC92933F9BE0062FEC1 /* PushOffsets.h */,
F6A3CDCD29341D8E0062FEC1 /* PushOffsets.cpp */,
F6A3CDEE293461DD0062FEC1 /* PushConstants.h */,
F662BBDF2BE5DC83000BDDC5 /* Memory.h */,
);
path = vuku;
sourceTree = "<group>";
};
F61D7C402E38167D002A1AED /* tjp */ = {
isa = PBXGroup;
children = (
F608ABBA2828711E005C276B /* core */,
);
path = tjp;
sourceTree = "<group>";
};
F61F9BF72C6E516500F79137 /* _tests */ = {
isa = PBXGroup;
children = (
F608ABC42828714B005C276B /* Geometry.cpp */,
F608ABC52828714B005C276B /* Memory.cpp */,
);
path = _tests;
sourceTree = "<group>";
};
F61F9BF92C6E51EF00F79137 /* _tests */ = {
isa = PBXGroup;
children = (
F6A3CDCA293411420062FEC1 /* PushOffsets.cpp */,
);
path = _tests;
sourceTree = "<group>";
};
F65B0E982BD6056200ED927A /* opengl */ = {
isa = PBXGroup;
children = (
F65B0E9B2BD6057500ED927A /* AtlasAggregate.cpp */,
F65B0E9A2BD6057500ED927A /* AtlasAggregate.h */,
F65B0E992BD6057500ED927A /* AtlasAggregate.hpp */,
F69B59C02BDD7D0C00280B50 /* AtlasOf.hpp */,
);
path = opengl;
sourceTree = "<group>";
};
F66AE439288F2B3800668C66 /* atlas */ = {
isa = PBXGroup;
children = (
F64233022BE974FD0050517F /* shader */,
F65B0E982BD6056200ED927A /* opengl */,
F6BF6DD829AE5FC800D84632 /* vuku */,
F6DECA7E288EF35500635410 /* Atlas.cpp */,
F6DECA7D288EF06D00635410 /* Atlas.h */,
F650BA6328906E17006D2316 /* Atlas.hpp */,
F6BF6DD329AE568B00D84632 /* AtlasAggregate.hpp */,
F6BF6DD729AE58B200D84632 /* AtlasAggregate.h */,
F6BF6DD429AE56CC00D84632 /* AtlasAggregate.cpp */,
F650BA6928907F14006D2316 /* AtlasCacher.hpp */,
F650BA5F28906744006D2316 /* AtlasTyped.hpp */,
F62773CF29425CB800FA748D /* AtlasTypedSource.hpp */,
F61AAB4928A0ADD300E2ABDB /* FontSTB_SDF.cpp */,
F66AE433288F23D300668C66 /* FontSTB_SDF.h */,
F61AAB4828A0ADD200E2ABDB /* FontSTB_SDF.hpp */,
F66AE434288F23DB00668C66 /* FontSTB.cpp */,
F61AAB4728A0ADD200E2ABDB /* FontSTB.h */,
F650BA6728906F01006D2316 /* FontSTB.hpp */,
F6DECA82288F031400635410 /* GlyphAtlas.cpp */,
F650BA6528906E7B006D2316 /* GlyphAtlas.h */,
F6DECA81288F031400635410 /* GlyphAtlas.hpp */,
F62773CD29425AEA00FA748D /* Font.h */,
F62773CC29425AC400FA748D /* Font.hpp */,
F62773CE29425B2000FA748D /* Font.cpp */,
F62773CA29425A3F00FA748D /* FontMulti.hpp */,
F62773CB29425AA700FA748D /* FontMulti.cpp */,
F650BA5C289064AB006D2316 /* IconAtlas.cpp */,
F650BA6628906EA0006D2316 /* IconAtlas.h */,
F650BA5B289064AB006D2316 /* IconAtlas.hpp */,
);
path = atlas;
sourceTree = "<group>";
};
F66D9DEE293120F3009D7D3D /* interesting_not_for_real */ = {
isa = PBXGroup;
children = (
F66D9DEF29312107009D7D3D /* FontFileFromIOS.m */,
);
path = interesting_not_for_real;
sourceTree = "<group>";
};
F68981662843FC5B0001F47E /* vku-new */ = {
isa = PBXGroup;
children = (
F640CF7C2AA6ACBB0011E76D /* vulkan.hpp */,
F68981672843FC5B0001F47E /* vku.hpp */,
F68981682843FC5B0001F47E /* vku_framework.hpp */,
);
path = "vku-new";
sourceTree = "<group>";
};
F68981692843FC5B0001F47E /* vku-old */ = {
isa = PBXGroup;
children = (
F689816A2843FC5B0001F47E /* vku.hpp */,
F689816B2843FC5B0001F47E /* vku_framework.hpp */,
);
path = "vku-old";
sourceTree = "<group>";
};
F6BF6DD829AE5FC800D84632 /* vuku */ = {
isa = PBXGroup;
children = (
F612B9292B9CA92B00519EB6 /* Atlas.h */,
F66AE43B288F2B6F00668C66 /* AtlasAggregate.cpp */,
F66AE43A288F2B6900668C66 /* AtlasAggregate.h */,
F6BF6DDE29AE668800D84632 /* AtlasAggregate.hpp */,
F6BF6DDB29AE609800D84632 /* AtlasLayers.cpp */,
F6BF6DDA29AE607300D84632 /* AtlasLayers.h */,
F6BF6DDF29AE669900D84632 /* AtlasLayers.hpp */,
F6BF6DD929AE5FDF00D84632 /* AtlasOf.hpp */,
);
path = vuku;
sourceTree = "<group>";
};
F6CA38672933B08A00556E1C /* tests */ = {
isa = PBXGroup;
children = (
F61F9BF02C6E4DD200F79137 /* Makefile.project */,
F6CA38682933B09300556E1C /* main.cpp */,
);
path = tests;
sourceTree = "<group>";
};
F6CA386A2933B0E600556E1C /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
F608ABAF28287108005C276B /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
F64035B529452048007B0A67 /* AtlasAggregate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F6971F2C282B1184008FBD17 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
F64035B429452048007B0A67 /* AtlasAggregate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
F608ABB228287108005C276B /* Core_Graphics_Render */ = {
isa = PBXNativeTarget;
buildConfigurationList = F608ABB728287108005C276B /* Build configuration list for PBXNativeTarget "Core_Graphics_Render" */;
buildPhases = (
F608ABAF28287108005C276B /* Headers */,
F608ABB028287108005C276B /* Sources */,
F608ABB128287108005C276B /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = Core_Graphics_Render;
productName = Core_Graphics;
productReference = F608ABB328287108005C276B /* libCore_Graphics_Render.a */;
productType = "com.apple.product-type.library.static";
};
F6971F2B282B1184008FBD17 /* Core_Graphics_Render_iOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = F6971F30282B1184008FBD17 /* Build configuration list for PBXNativeTarget "Core_Graphics_Render_iOS" */;
buildPhases = (
F6971F2C282B1184008FBD17 /* Headers */,
F6971F2D282B1184008FBD17 /* Sources */,
F6971F2F282B1184008FBD17 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = Core_Graphics_Render_iOS;
productName = Core_Graphics;
productReference = F6971F33282B1184008FBD17 /* libCore_Graphics_Render_iOS.a */;
productType = "com.apple.product-type.library.static";
};
F6CA385E2933AD8400556E1C /* Core_Graphics_Render_Tester */ = {
isa = PBXNativeTarget;
buildConfigurationList = F6CA38632933AD8400556E1C /* Build configuration list for PBXNativeTarget "Core_Graphics_Render_Tester" */;
buildPhases = (
F6CA385B2933AD8400556E1C /* Sources */,
F6CA385C2933AD8400556E1C /* Frameworks */,
F6CA385D2933AD8400556E1C /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = Core_Graphics_Render_Tester;
productName = Core_Graphics_Tester;
productReference = F6CA385F2933AD8400556E1C /* Core_Graphics_Render_Tester */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
F608ABAB28287108005C276B /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
DefaultBuildSystemTypeForWorkspace = Original;
LastSwiftUpdateCheck = 1400;
LastUpgradeCheck = 1330;
TargetAttributes = {
F608ABB228287108005C276B = {
CreatedOnToolsVersion = 13.3;
};
F6CA385E2933AD8400556E1C = {
CreatedOnToolsVersion = 14.0;
};
};
};
buildConfigurationList = F608ABAE28287108005C276B /* Build configuration list for PBXProject "Core_Graphics_Render" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = F608ABAA28287108005C276B;
productRefGroup = F608ABB428287108005C276B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
F608ABB228287108005C276B /* Core_Graphics_Render */,
F6971F2B282B1184008FBD17 /* Core_Graphics_Render_iOS */,
F6CA385E2933AD8400556E1C /* Core_Graphics_Render_Tester */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
F608ABB028287108005C276B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F6E540B12BDEB52300CE3A75 /* opengl.cpp in Sources */,
F66AE436288F241900668C66 /* FontSTB.cpp in Sources */,
F62773D52942610F00FA748D /* Font.cpp in Sources */,
F6BF6DDC29AE609800D84632 /* AtlasLayers.cpp in Sources */,
F6BF6DD529AE56CC00D84632 /* AtlasAggregate.cpp in Sources */,
F6E540AE2BDE9B3900CE3A75 /* AtlasAggregate.cpp in Sources */,
F62773D029425DC500FA748D /* FontMulti.cpp in Sources */,
F6CA38582933A7EE00556E1C /* MemoryStandard.cpp in Sources */,
F6A3CDCE29341E7A0062FEC1 /* PushOffsets.cpp in Sources */,
F650BA5D289064AB006D2316 /* IconAtlas.cpp in Sources */,
F66AE43D288F2BBC00668C66 /* AtlasAggregate.cpp in Sources */,
F6DECA80288EFD0700635410 /* Atlas.cpp in Sources */,
F6DECA84288F031400635410 /* GlyphAtlas.cpp in Sources */,
F61AAB4B28A0AE6600E2ABDB /* FontSTB_SDF.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F6971F2D282B1184008FBD17 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F6A3CDCF29341E7B0062FEC1 /* PushOffsets.cpp in Sources */,
F66AE435288F241900668C66 /* FontSTB.cpp in Sources */,
F6BF6DDD29AE609800D84632 /* AtlasLayers.cpp in Sources */,
F6E540B22BDEB52400CE3A75 /* opengl.cpp in Sources */,
F650BA5E289064AB006D2316 /* IconAtlas.cpp in Sources */,
F6E540AF2BDE9B3D00CE3A75 /* AtlasAggregate.cpp in Sources */,
F62773D129425DC600FA748D /* FontMulti.cpp in Sources */,
F62773D62942611000FA748D /* Font.cpp in Sources */,
F66AE43C288F2BBB00668C66 /* AtlasAggregate.cpp in Sources */,
F6CA38572933A7ED00556E1C /* MemoryStandard.cpp in Sources */,
F6DECA7F288EFD0700635410 /* Atlas.cpp in Sources */,
F6DECA83288F031400635410 /* GlyphAtlas.cpp in Sources */,
F61AAB4A28A0AE6600E2ABDB /* FontSTB_SDF.cpp in Sources */,
F6BF6DD629AE56CC00D84632 /* AtlasAggregate.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F6CA385B2933AD8400556E1C /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F6CA38692933B0B100556E1C /* main.cpp in Sources */,
F662BBE02BE5DEDD000BDDC5 /* Memory.cpp in Sources */,
F6A3CDCB293413670062FEC1 /* PushOffsets.cpp in Sources */,
F6A3CDD029341EB40062FEC1 /* PushOffsets.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
F608ABB528287108005C276B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
GLES_SILENCE_DEPRECATION,
GL_SILENCE_DEPRECATION,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../Core_IO,
../Core_Math,
../Core_Misc,
../Core_Zero,
../Core_Graphics_Render,
../Core_Graphics,
../Core_Allocator,
../Libraries/sdk/Darwin/include,
core/graphics/imgui,
);
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lCore_Zero";
SDKROOT = macosx;
USE_HEADERMAP = NO;
};
name = Debug;
};
F608ABB628287108005C276B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
GLES_SILENCE_DEPRECATION,
GL_SILENCE_DEPRECATION,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../Core_IO,
../Core_Math,
../Core_Misc,
../Core_Zero,
../Core_Graphics_Render,
../Core_Graphics,
../Core_Allocator,
../Libraries/sdk/Darwin/include,
core/graphics/imgui,
);
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "-lCore_Zero";
SDKROOT = macosx;
USE_HEADERMAP = NO;
};
name = Release;
};
F608ABB828287108005C276B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T2M28D3T75;
EXECUTABLE_PREFIX = lib;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Debug;
};
F608ABB928287108005C276B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T2M28D3T75;
EXECUTABLE_PREFIX = lib;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
F6971F31282B1184008FBD17 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T2M28D3T75;
EXECUTABLE_PREFIX = lib;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
};
name = Debug;
};
F6971F32282B1184008FBD17 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T2M28D3T75;
EXECUTABLE_PREFIX = lib;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
};
name = Release;
};
F6CA38642933AD8400556E1C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T2M28D3T75;
ENABLE_HARDENED_RUNTIME = YES;
HEADER_SEARCH_PATHS = (
"${inherited}",
../Core_Graphics,
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
F6CA38652933AD8400556E1C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T2M28D3T75;
ENABLE_HARDENED_RUNTIME = YES;
HEADER_SEARCH_PATHS = (
"${inherited}",
../Core_Graphics,
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
F608ABAE28287108005C276B /* Build configuration list for PBXProject "Core_Graphics_Render" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F608ABB528287108005C276B /* Debug */,
F608ABB628287108005C276B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F608ABB728287108005C276B /* Build configuration list for PBXNativeTarget "Core_Graphics_Render" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F608ABB828287108005C276B /* Debug */,
F608ABB928287108005C276B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F6971F30282B1184008FBD17 /* Build configuration list for PBXNativeTarget "Core_Graphics_Render_iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F6971F31282B1184008FBD17 /* Debug */,
F6971F32282B1184008FBD17 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F6CA38632933AD8400556E1C /* Build configuration list for PBXNativeTarget "Core_Graphics_Render_Tester" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F6CA38642933AD8400556E1C /* Debug */,
F6CA38652933AD8400556E1C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = F608ABAB28287108005C276B /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F6CA385E2933AD8400556E1C"
BuildableName = "Core_Graphics_Render_Tester"
BlueprintName = "Core_Graphics_Render_Tester"
ReferencedContainer = "container:Core_Graphics_Render.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
viewDebuggingEnabled = "No">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F6CA385E2933AD8400556E1C"
BuildableName = "Core_Graphics_Render_Tester"
BlueprintName = "Core_Graphics_Render_Tester"
ReferencedContainer = "container:Core_Graphics_Render.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-s"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "-b"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F6CA385E2933AD8400556E1C"
BuildableName = "Core_Graphics_Render_Tester"
BlueprintName = "Core_Graphics_Render_Tester"
ReferencedContainer = "container:Core_Graphics_Render.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

2
Makefile Normal file
View File

@@ -0,0 +1,2 @@
ROOTDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))..)
include $(ROOTDIR)/Core_Make/tjp/Make/Makefile

6
Makefile.def Executable file
View File

@@ -0,0 +1,6 @@
timprepscius.core.include := $(timprepscius.core.include) -I $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
timprepscius.core.link := $(timprepscius.core.link) -L $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/.bin/$(OBJDIR)
timprepscius.core_graphics.include := -I $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
timprepscius.core_graphics.link := -L $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/.bin/$(OBJDIR)

35
Makefile.project Executable file
View File

@@ -0,0 +1,35 @@
include $(MAKEDIR)/Makefile.base
# use: ls -d tjp/core/*/ tjp/core/*/*/ | rev | cut -c 2- | rev | sed 's/$/ \\/'
PROJECTS := \
tjp/core/graphics \
tjp/core/graphics/atlas \
tjp/core/graphics/vuku \
tjp/core/graphics/soft \
ifneq (Linux,$(SYS_NAME))
PROJECTS += \
tjp/core/graphics/imgui \
tjp/core/graphics/atlas/vuku \
tjp/core/graphics/atlas/opengl \
endif
ifneq (Darwin,$(SYS_NAME))
_FLAGS := $(_FLAGS) -DGLES_SILENCE_DEPRECATION -DGL_SILENCE_DEPRECATION
endif
#SRC_PCH := tjp/core/Precompile.pch
INCPATH := \
$(timprepscius.libraries.cpp.include) \
$(timprepscius.core.include)
LIBFILE := libCore_Graphics_Render.a
COPYTO := $(LIBRARIES_PROJECT)
include $(MAKEDIR)/Makefile.lib

1
tests/Makefile Symbolic link
View File

@@ -0,0 +1 @@
../../Make/Makefile

33
tests/Makefile.project Executable file
View File

@@ -0,0 +1,33 @@
include $(MAKEDIR)/Makefile.base
# use: ls -d core/*/ core/*/*/ | rev | cut -c 2- | rev | sed 's/$/ \\/'
PROJECTS := \
. \
../core/graphics/_tests \
../core/graphics/soft/_tests \
../core/graphics/vuku/_tests \
INCPATH := \
$(timprepscius.libraries.cpp.include) \
$(timprepscius.core.include)
LDPATH := $(timprepscius.libraries.cpp.link)
LIBS := \
-lCore_Zero \
-lCore_Misc \
-lCore_Math \
-lCore_Graphics \
-lz_
EXEFILE := Core_Graphics_Tests.exe
#COPYTO := $(ROOTDIR)/.bin
ifeq (Darwin,$(SYS_NAME))
LIBS += -lc++
endif
include $(MAKEDIR)/Makefile.bin

17
tests/main.cpp Normal file
View File

@@ -0,0 +1,17 @@
#define CATCH_CONFIG_RUNNER
#include <tjp/core/testing/catch.hpp>
#include <tjp/core/log/Log.h>
using namespace tjp;
using namespace core;
int main( int argc, char* argv[] )
{
xLogInitialize("Core_Graphics_Tests.txt");
xLogActivateStory("testing");
xLogActivateStory("debug");
int result = Catch::Session().run( argc, argv );
return result;
}

View File

@@ -0,0 +1,20 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
namespace tjp::core::graphics::memory {
struct Manager;
struct ManagerStandard;
template<typename T>
struct Discard;
} // namespace

View File

@@ -0,0 +1,158 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include <utility>
namespace tjp::core::graphics::memory {
struct Record
{
virtual ~Record() {}
} ;
template<typename T>
struct SpecializedRecord : Record
{
SpecializedRecord(T &&t_) :
t(std::move(t_))
{}
T t;
} ;
struct Manager;
template<typename T, typename U=Manager>
struct Discard
{
public:
using Type = T;
private:
T t;
using Manager_ = U;
friend Manager_;
Manager_ *manager = nullptr;
Discard(Manager_ *manager_, T &&t_) :
t(std::move(t_)),
manager(manager_)
{
}
template<typename ... Args>
Discard(Manager_ *manager_, Args && ...args) :
t(std::forward<Args>(args)...),
manager(manager_)
{
}
void discard();
public:
~Discard ()
{
discard();
}
Discard()
{
}
Discard(Discard &&rhs):
t(std::move(rhs.t)),
manager(std::move(rhs.manager))
{
}
Discard &operator =(Discard &&rhs)
{
std::swap(t, rhs.t);
std::swap(manager, rhs.manager);
return *this;
}
Discard &operator =(std::nullptr_t type)
{
Discard rhs = std::move(*this);
return *this;
}
operator T &()
{
return t;
}
T *operator ->()
{
return &t;
}
T &operator *()
{
return t;
}
operator bool()
{
return manager != nullptr;
}
bool operator !()
{
return manager == nullptr;
}
} ;
struct Manager
{
virtual ~Manager() {}
virtual void record(Record *) = 0;
virtual void onFrame() = 0;
virtual void clear() = 0;
template<typename T>
Discard<T, Manager> makeDiscard(T &&t)
{
return Discard<T>(this, std::forward<T>(t));
}
template<typename T, typename ... Args>
Discard<T, Manager> makeDiscard(Args && ...args)
{
return Discard<T>(this, std::forward<Args>(args)...);
}
// this should be protected
// not sure of syntax of friend template class
public:
template<typename T>
void discard(T &&t) {
record(
new SpecializedRecord<T>(std::move(t))
);
}
} ;
template<typename T, typename U>
void Discard<T, U>::discard()
{
if (manager)
{
manager->discard(std::move(t));
manager = nullptr;
}
}
}

View File

@@ -0,0 +1,54 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#include "MemoryStandard.hpp"
namespace tjp::core::graphics::memory {
ManagerStandard::ManagerStandard()
{
currentFrame = 0;
frames.resize(3);
}
ManagerStandard::~ManagerStandard()
{
clear();
}
void ManagerStandard::record(Record *discard)
{
auto lock = lock_of(mutex);
frames[currentFrame].push_back(discard);
}
void ManagerStandard::onFrame()
{
auto lock = lock_of(mutex);
currentFrame = (currentFrame+1) % frames.size();
for (auto &record: frames[currentFrame])
delete record;
frames[currentFrame].clear();
}
void ManagerStandard::clear()
{
for (auto &frame: frames)
{
for (auto &record: frame)
delete record;
frame.clear();
}
}
}

View File

@@ -0,0 +1,39 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include "Memory.hpp"
#include <tjp/core/containers/Vector.h>
#include <tjp/core/threads/Lock.hpp>
namespace tjp::core::graphics::memory {
struct ManagerStandard : Manager
{
typedef Manager Super;
Mutex mutex;
using Records = Vector<Record *>;
using Frames = Vector<Records>;
Frames frames;
size_t currentFrame;
void record(Record *) override;
ManagerStandard();
virtual ~ManagerStandard();
void onFrame() override;
void clear() override;
} ;
}

View File

@@ -0,0 +1,27 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#include "Renderer.hpp"
#include <tjp/core/math/Vector2.inl>
#include <tjp/core/file/Path.h>
namespace tjp::core::graphics {
String Renderer::getShaderPath(const String &file)
{
return core::file::joinPaths({resourcesPath, shaderPath, file + shaderPostfix});
}
void Renderer::recalculatePixel()
{
pixel = ppi / extents.asType<float>();
}
} // namespace

View File

@@ -0,0 +1,16 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
namespace tjp::core::graphics {
struct Renderer;
} // namespace

View File

@@ -0,0 +1,38 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include <tjp/core/types/Types.h>
#include <tjp/core/math/Vector2.hpp>
#include <tjp/core/math/Vector2.hpp>
#include <tjp/core/string/String.hpp>
#include "Memory.hpp"
namespace tjp::core::graphics {
struct Renderer
{
String resourcesPath, documentsPath, cachePath, shaderPath, shaderPostfix;
math::Vector2f ppi;
math::Vector2i extents;
math::Vector2f pixel;
memory::Manager *memory;
void recalculatePixel();
String getShaderPath(const String &fileName);
} ;
} // namespace

View File

@@ -0,0 +1,18 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#include <tjp/core/graphics/Geometry.hpp>
namespace tjp::core::graphics {
void test ()
{
auto s = geometry::sphere<float, u16>(10, 10, 1.0f, true);
}
} // namespace

View File

@@ -0,0 +1,99 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#include <tjp/core/graphics/MemoryStandard.hpp>
#include <catch2/catch.hpp>
namespace tjp::core::graphics::memory {
namespace {
struct Object
{
int num;
} ;
struct VkMemoryTest;
typedef Discard<Object, VkMemoryTest> DiscardObject;
struct VkMemoryTest {
size_t called_ = 0;
std::vector<Object> objects;
void called()
{
called_ ++;
}
void discard(Object &&o)
{
called();
objects.emplace_back(std::move(o));
}
DiscardObject makeDiscard(Object &&o)
{
return DiscardObject(this, std::move(o));
}
} ;
SCENARIO("tjp::core::graphics::vuku::Memory")
{
GIVEN("a memory")
{
VkMemoryTest memory;
WHEN("create object")
{
auto a = memory.makeDiscard(Object{1});
THEN("make a new one with same variable")
{
a = memory.makeDiscard(Object{2});
THEN("the old one is discarded")
{
REQUIRE(memory.called_ == 1);
REQUIRE(memory.objects.back().num == 1);
}
}
}
}
GIVEN("a memory")
{
VkMemoryTest memory;
WHEN("create object")
{
{
auto a = memory.makeDiscard(Object{1});
{
a = memory.makeDiscard(Object{2});
REQUIRE(memory.called_ == 1);
REQUIRE(memory.objects.back().num == 1);
a = memory.makeDiscard(Object{3});
REQUIRE(memory.called_ == 2);
REQUIRE(memory.objects.back().num == 2);
}
}
REQUIRE(memory.called_ == 3);
REQUIRE(memory.objects.back().num == 3);
}
}
}
} // namespace
} // namespace

View File

@@ -0,0 +1,91 @@
#include "Atlas.hpp"
#include <tjp/core/iterators/range.hpp>
#include <tjp/core/string/starts_with.hpp>
#include <tjp/core/math/Real.h>
#include <tjp/core/math/Algorithm.hpp>
#include <tjp/core/debug/Debug.h>
#include <tjp/core/math/Vector2.inl>
#include <tjp/core/math/Real.inl>
#include <tjp/core/algorithm/map_erase.hpp>
#include <tjp/core/assert/handle_assert.hpp>
#include <tjp/core/algorithm/small_copy.hpp>
#include <tjp/core/iterators/safe_next.hpp>
namespace tjp::core::graphics::atlas {
Symbol::Symbol(size_t size):
data(size)
{
}
Symbol::~Symbol()
{
if (parent)
parent->releaseSymbol(this);
}
Atlas::Atlas()
{
}
void Atlas::releaseSymbol(Symbol *symbol)
{
auto lock = lock_of(mutex);
map_erase(symbols, symbol->index);
availableSymbolsIndices.push_back(symbol->index);
}
Index Atlas::getAvailableSymbolIndex ()
{
debug_assert(mutex.locked_by_caller());
Index result;
if (!availableSymbolsIndices.empty())
{
result = availableSymbolsIndices.back();
availableSymbolsIndices.pop_back();
}
else
{
in++;
result = nextSymbolIndex++;
}
return result;
}
void Atlas::putSymbol(const StrongPtr<Symbol> &symbol)
{
debug_assert(mutex.locked_by_caller());
auto index = getAvailableSymbolIndex();
symbol->parent = strong_this(this);
in++;
symbol->index = index;
auto symbol_ = weak(symbol);
symbols[index] = symbol;
}
bool Atlas::recompute()
{
if (!out.update(in))
return false;
return true;
}
Atlas::~Atlas()
{
}
} // namespace

View File

@@ -0,0 +1,16 @@
#pragma once
#include <tjp/core/resource_version/GlobalResourceVersion.h>
#include <tjp/core/types/Types.h>
namespace tjp::core::graphics::atlas {
typedef u16 Index;
using Version = core::GlobalResourceVersion;
struct Symbol;
struct Atlas;
} // namespace

View File

@@ -0,0 +1,59 @@
#pragma once
#include "Atlas.h"
#include <tjp/core/containers/Vector.h>
#include <tjp/core/containers/Map.h>
#include <tjp/core/math/Vector2.hpp>
#include <tjp/core/ptr/Ptr.hpp>
#include <tjp/core/threads/Lock.hpp>
#include <tjp/core/resource_version/GlobalResourceVersion.hpp>
namespace tjp::core::graphics::atlas {
typedef u16 Index;
using Version = core::GlobalResourceVersion;
struct Atlas;
struct Symbol
{
Symbol(size_t size);
virtual ~Symbol();
StrongPtr<Atlas> parent;
Index index;
Vector<u8> data;
Version in, out;
bool realized = false;
};
struct Atlas : StrongThis<Atlas>
{
// should make this into a plain mutex, but requires some work
RecursiveMutex mutex;
size_t pixelSize = 0;
math::Vector2i symbolDimensions;
Map<Index, WeakPtr<Symbol>> symbols;
Index nextSymbolIndex = 0;
Vector<Index> availableSymbolsIndices;
Index getAvailableSymbolIndex ();
void putSymbol(const StrongPtr<Symbol> &);
void releaseSymbol(Symbol *);
Version in, out;
virtual bool recompute();
Atlas();
virtual ~Atlas ();
} ;
} // namespace

View File

@@ -0,0 +1,106 @@
#include "AtlasAggregate.hpp"
#include <tjp/core/iterators/range.hpp>
#include <tjp/core/string/starts_with.hpp>
#include <tjp/core/math/Real.h>
#include <tjp/core/math/Algorithm.hpp>
#include <tjp/core/debug/Debug.h>
#include <tjp/core/math/Vector2.inl>
#include <tjp/core/math/Real.inl>
#include <tjp/core/algorithm/map_erase.hpp>
#include <tjp/core/assert/handle_assert.hpp>
#include <tjp/core/algorithm/small_copy.hpp>
#include <tjp/core/iterators/safe_next.hpp>
#include <tjp/core/log/Log.h>
#include <tjp/core/log/LogOf.h>
namespace tjp::core::graphics::atlas {
AtlasAggregate::AtlasAggregate()
{
}
bool AtlasAggregate::recompute()
{
if (!Super::recompute())
return false;
sLogDebug("core::graphics::atlas", "recomputing");
auto lock = lock_of(mutex);
auto totalMatrixSize = nextSymbolIndex;
auto rowSize = std::ceil(std::sqrt(totalMatrixSize));
auto numRows = std::ceil(totalMatrixSize / rowSize);
matrixDimensions = {
int(rowSize),
int(numRows)
} ;
aggregateDimensions = math::multiply(matrixDimensions, symbolDimensions);
aggregate.resize(aggregateDimensions[0] * aggregateDimensions[1] * pixelSize);
auto symbolIndexOf = [&](int x, int y) {
return y * symbolDimensions.x() + x;
} ;
auto aggregateIndexOf = [&](Index index, int x, int y) {
auto numRows = (index / matrixDimensions.x()) * symbolDimensions.y() + y;
auto rowIncrement = numRows * aggregateDimensions.x();
auto columnIncrement = (index % matrixDimensions.x()) * symbolDimensions.x() + x;
return
rowIncrement +
columnIncrement;
};
for (auto i : safe_next(symbols))
{
auto &symbol_ = i->second;
auto symbol = strong(symbol_);
if (!symbol)
continue;
// In the future if I make the mutex non recursive, I'll need to erase the pointers
// in thhis loop
// if (!symbol)
// {
// symbols.erase(i);
// continue;
// }
auto index = symbol->index;
for (auto x = 0; x < symbolDimensions.x(); ++x)
{
for (auto y = 0; y < symbolDimensions.y(); ++y)
{
auto ip = symbolIndexOf(x, y);
auto ap = aggregateIndexOf(index, x, y);
auto *to = (char *)&aggregate[ap * pixelSize];
auto *from = (char *)&symbol->data[ip * pixelSize];
small_copy(to, from, pixelSize);
symbol->realized = true;
}
}
}
sLogDebug("core::graphics::atlas", "recomputed");
return true;
}
AtlasAggregate::~AtlasAggregate()
{
}
} // namespace

View File

@@ -0,0 +1,10 @@
#pragma once
#include "Atlas.h"
namespace tjp::core::graphics::atlas {
struct AtlasAggregate;
} // namespace

View File

@@ -0,0 +1,26 @@
#pragma once
#include "Atlas.hpp"
namespace tjp::core::graphics::atlas {
struct AtlasAggregate : Atlas
{
using Super = Atlas;
math::Vector2i matrixDimensions;
math::Vector2i aggregateDimensions;
Vector<u8> aggregate;
virtual bool recompute() override;
AtlasAggregate();
virtual ~AtlasAggregate ();
math::Vector2f getMatrixDimensions() {
return matrixDimensions.asType<float>();
}
} ;
} // namespace

View File

@@ -0,0 +1,53 @@
#pragma once
#include "Atlas.h"
#include <tjp/core/containers/Vector.h>
#include <tjp/core/containers/Map.h>
#include <tjp/core/math/Vector2.hpp>
#include <tjp/core/ptr/Ptr.hpp>
#include <tjp/core/threads/Lock.hpp>
#include <tjp/core/resource_version/GlobalResourceVersion.hpp>
namespace tjp::core::graphics::atlas {
typedef u16 Index;
using Version = core::GlobalResourceVersion;
struct Atlas;
template<typename T>
struct AtlasCacher : T
{
typedef T Super;
typedef typename Super::Key Key;
typedef typename Super::Value Value;
Vector<StrongPtr<Value>> caches[2];
int current=0, prev=1;
template<typename ... Args>
AtlasCacher(Args&& ... args) :
Super(std::forward<Args>(args)...)
{
}
StrongPtr<Value> get(const Key &key) override
{
auto p = Super::get(key);
caches[current].push_back(p);
return p;
}
void prune ()
{
std::swap(current, prev);
caches[current].clear();
}
} ;
} // namespace

View File

@@ -0,0 +1,98 @@
#pragma once
#include "Atlas.hpp"
#include "Font.hpp"
#include <tjp/core/containers/Function.h>
#include <tjp/core/string/String.h>
#include <tjp/core/algorithm/map_erase.hpp>
namespace tjp::core::graphics::atlas {
template<typename Key>
struct AtlasTypedSymbol : Symbol
{
typedef Symbol Super;
Function<void(Key &)> release;
AtlasTypedSymbol(size_t size) :
Super(size)
{}
~AtlasTypedSymbol()
{
if (release)
release(key);
}
Key key;
} ;
template<typename T, typename K, typename V, typename G>
struct AtlasTyped : T
{
typedef T Super;
typedef K Key;
typedef V Value;
typedef G Generator;
Map<Key, WeakPtr<Value>> map;
virtual void release(const Key &key)
{
auto lock = lock_of(this->mutex);
map_erase(map, key);
}
virtual StrongPtr<Value> get(const Key &key)
{
auto lock = lock_of(this->mutex);
auto &symbol_ = map[key];
if (auto symbol = strong(symbol_))
return symbol;
auto symbol = generate(key);
if (!symbol)
return source->defaultValue();
debug_assert(symbol);
symbol->release = [this](Key &key) {
release(key);
};
symbol->key = key;
symbol_ = weak(symbol);
this->putSymbol(symbol);
return symbol;
}
StrongPtr<Value> generate(const Key &key)
{
return source->generate(key);
}
StrongPtr<Generator> source;
virtual void add(const StrongPtr<Generator> &source_)
{
source = source_;
this->symbolDimensions = source->symbolDimensions;
this->pixelSize = source->pixelSize;
}
Version sourceVersion;
bool recompute() override
{
if (sourceVersion.update(source->version))
this->in++;
return Super::recompute();
}
} ;
} // namespace

View File

@@ -0,0 +1,18 @@
#pragma once
#include "Atlas.h"
#include <tjp/core/math/Vector2.hpp>
#include <tjp/core/resource_version/GlobalResourceVersion.hpp>
namespace tjp::core::graphics::atlas {
struct AtlasTypedSource
{
math::Vector2i symbolDimensions;
u8 pixelSize;
Version version;
} ;
} // namespace

View File

@@ -0,0 +1,9 @@
#include "Font.hpp"
namespace tjp::core::graphics::atlas {
Font::~Font ()
{
}
} // namespace

View File

@@ -0,0 +1,11 @@
#pragma once
#include <tjp/core/types/Types.h>
namespace tjp::core::graphics::atlas {
typedef u64 FontID;
struct Font;
} // namespace

View File

@@ -0,0 +1,24 @@
#pragma once
#include "Font.h"
#include "GlyphAtlas.h"
#include "AtlasTypedSource.hpp"
#include <tjp/core/ptr/Ptr.hpp>
namespace tjp::core::graphics::atlas {
struct Font : AtlasTypedSource
{
virtual ~Font ();
virtual StrongPtr<GlyphSymbol> generate(const Character &character) = 0;
virtual StrongPtr<GlyphSymbol> defaultValue() = 0;
protected:
float ascent, descent;
} ;
} // namespace

View File

@@ -0,0 +1,53 @@
#include "FontMulti.hpp"
#include <tjp/core/log/Log.h>
#include <tjp/core/log/LogOf.h>
namespace tjp::core::graphics::atlas {
FontMulti::FontMulti ()
{
}
FontMulti::~FontMulti ()
{
}
void FontMulti::add(const StrongPtr<Font> &font)
{
fonts.push_back(font);
symbolDimensions = font->symbolDimensions;
pixelSize = font->pixelSize;
// ascent = font->ascent;
// descent = font->descent;
version++;
}
StrongPtr<GlyphSymbol> FontMulti::generate(const Character &character)
{
sLogDebug("core::graphics::atlas::font", "multi requested " << logVar(character));
for (auto &font: fonts)
{
auto glyph = font->generate(character);
version.update(font->version);
if (glyph)
return glyph;
}
return nullptr;
}
StrongPtr<GlyphSymbol> FontMulti::defaultValue()
{
return fonts.front()->defaultValue();
}
} // namespace

View File

@@ -0,0 +1,21 @@
#pragma once
#include "Font.hpp"
#include <tjp/core/containers/Vector.hpp>
namespace tjp::core::graphics::atlas {
struct FontMulti : Font
{
FontMulti ();
virtual ~FontMulti ();
void add(const StrongPtr<Font> &font);
Vector<StrongPtr<Font>> fonts;
StrongPtr<GlyphSymbol> generate(const Character &character) override;
StrongPtr<GlyphSymbol> defaultValue() override;
} ;
} // namespace

View File

@@ -0,0 +1,106 @@
#include "FontSTB.hpp"
#include "GlyphAtlas.hpp"
#include <imgui/imstb_truetype.h>
#include <tjp/core/file/File.h>
#include <tjp/core/debug/Debug.h>
namespace tjp::core::graphics::atlas {
struct FontSTB::Internal {
Vector<char> file;
stbtt_fontinfo font;
int size;
float scale;
int ascent, descent, lineGap;
int symbolSize;
} ;
FontSTB::FontSTB(const String &name)
{
i = strong<Internal>();
i->file = core::file::readFile(name);
i->size = 64;
stbtt_InitFont(&i->font, (const unsigned char *)i->file.data(), 0);
i->scale = stbtt_ScaleForPixelHeight(&i->font, i->size);
stbtt_GetFontVMetrics(&i->font, &i->ascent, &i->descent, &i->lineGap);
symbolDimensions = { i->size, i->size };
i->symbolSize = symbolDimensions[0] * symbolDimensions[1];
pixelSize = sizeof(Pixel);
ascent = i->scale * i->ascent;
descent = i->scale * i->descent;
}
StrongPtr<GlyphSymbol> FontSTB::generate(const Character &character)
{
int w, h, ox, oy;
auto bitmap = stbtt_GetCodepointBitmap(&i->font, 0, i->scale, (int)character, &w, &h, &ox, &oy);
if (!bitmap)
return nullptr;
debug_assert(w < symbolDimensions[0]);
debug_assert(h < symbolDimensions[1]);
auto bitmapIndexOf = [&](int x, int y) {
return y * w + x;
} ;
auto symbolIndexOf = [&](int x, int y) {
return y * symbolDimensions.x() + x;
};
auto symbol = strong<GlyphSymbol>(i->symbolSize * sizeof(Pixel));
symbol->data.resize(i->symbolSize);
auto *pixels = (Pixel *)symbol->data.data();
for (auto x=0; x<w; ++x)
for (auto y=0; y<h; ++y)
pixels[symbolIndexOf(x, y)] = bitmap[bitmapIndexOf(x, y)];
stbtt_FreeBitmap(bitmap, nullptr);
symbol->extents = {
float(w) / symbolDimensions[0],
float(h) / symbolDimensions[1]
};
symbol->offset = {
float(ox) / symbolDimensions[0],
float(oy) / symbolDimensions[1]
} ;
symbol->uv = {
float(w) / symbolDimensions[0],
float(h) / symbolDimensions[1]
} ;
int advance, lsb;
stbtt_GetCodepointHMetrics(&i->font, character, &advance, &lsb);
symbol->advance = i->scale * advance / symbolDimensions[0];
symbol->ascent = ascent / symbolDimensions[1];
return symbol;
}
StrongPtr<GlyphSymbol> FontSTB::defaultValue()
{
if (!default_)
{
default_ = strong<GlyphSymbol>(i->symbolSize * sizeof(Pixel));
default_->data.resize(i->symbolSize);
}
return default_;
}
} // namespace

View File

@@ -0,0 +1,9 @@
#pragma once
#include "GlyphAtlas.h"
namespace tjp::core::graphics::atlas {
struct FontSTB;
} // namespace

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Font.hpp"
#include "FontSTB.h"
#include <tjp/core/string/String.h>
namespace tjp::core::graphics::atlas {
struct FontSTB : Font
{
typedef u8 Pixel;
struct Internal;
StrongPtr<Internal> i;
FontSTB(const String &name);
StrongPtr<GlyphSymbol> generate(const Character &character) override;
StrongPtr<GlyphSymbol> default_;
StrongPtr<GlyphSymbol> defaultValue() override;
} ;
} // namespace

View File

@@ -0,0 +1,146 @@
#include "FontSTB_SDF.hpp"
#include "GlyphAtlas.hpp"
#include <imgui/imstb_truetype.h>
#include <tjp/core/file/File.h>
#include <tjp/core/debug/Debug.h>
#include <tjp/core/log/Log.h>
#include <tjp/core/log/LogOf.h>
namespace tjp::core::graphics::atlas {
STBTT_DEF unsigned char * stbtt_GetCodepointSDF_CheckZero(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
{
auto glyphIndex = stbtt_FindGlyphIndex(info, codepoint);
if (glyphIndex == 0)
return nullptr;
return stbtt_GetGlyphSDF(info, scale, glyphIndex, padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff);
}
struct FontSTB_SDF::Internal {
Vector<char> file;
stbtt_fontinfo font;
int size;
float scale;
int padding;
int ascent, descent, lineGap;
int symbolSize;
} ;
FontSTB_SDF::FontSTB_SDF(const String &name)
{
i = strong<Internal>();
i->file = core::file::readFile(name);
i->size = 64;
i->padding = 8;
stbtt_InitFont(&i->font, (const unsigned char *)i->file.data(), 0);
i->scale = stbtt_ScaleForPixelHeight(&i->font, i->size - i->padding);
stbtt_GetFontVMetrics(&i->font, &i->ascent, &i->descent, &i->lineGap);
symbolDimensions = { i->size, i->size };
i->symbolSize = symbolDimensions[0] * symbolDimensions[1];
pixelSize = sizeof(Pixel);
ascent = i->scale * i->ascent;
descent = i->scale * i->descent;
}
StrongPtr<GlyphSymbol> FontSTB_SDF::generate(const Character &character)
{
sLogDebug("core::graphics::atlas::font", "requested " << logVar(character));
int w, h, ox, oy;
int padding = i->padding - 2;
unsigned char onedge_value = 128;
float pixel_dist_scale = 16;
auto bitmap = stbtt_GetCodepointSDF_CheckZero(
&i->font, i->scale,
(int)character,
padding, onedge_value,
pixel_dist_scale,
&w, &h, &ox, &oy
);
if (!bitmap)
{
sLogDebug("core::graphics::atlas::font", "No bitmap for " << logVar(character));
return nullptr;
}
auto symbol = strong<GlyphSymbol>(i->symbolSize * sizeof(Pixel));
symbol->data.resize(i->symbolSize);
int advance, lsb;
stbtt_GetCodepointHMetrics(&i->font, character, &advance, &lsb);
symbol->advance = i->scale * advance / symbolDimensions[0];
symbol->ascent = ascent / symbolDimensions[1];
debug_assert(w < symbolDimensions[0]);
debug_assert(h < symbolDimensions[1]);
auto bitmapIndexOf = [&](int x, int y) {
return y * w + x;
} ;
auto symbolIndexOf = [&](int x, int y) {
return y * symbolDimensions.x() + x;
};
auto w_ = std::min(w, i->size);
auto h_ = std::min(h, i->size);
auto *pixels = (Pixel *)symbol->data.data();
for (auto x=0; x<w_; ++x)
for (auto y=0; y<h_; ++y)
pixels[symbolIndexOf(x, y)] = bitmap[bitmapIndexOf(x, y)];
stbtt_FreeSDF(bitmap, nullptr);
symbol->extents = {
float(w) / symbolDimensions[0],
float(h) / symbolDimensions[1]
};
symbol->offset = {
float(ox) / symbolDimensions[0],
float(oy) / symbolDimensions[1]
} ;
symbol->uv = {
float(w) / symbolDimensions[0],
float(h) / symbolDimensions[1]
} ;
return symbol;
}
StrongPtr<GlyphSymbol> FontSTB_SDF::defaultValue()
{
if (!default_)
{
auto symbol = strong<GlyphSymbol>(i->symbolSize * sizeof(Pixel));
symbol->data.resize(i->symbolSize);
int advance, lsb;
stbtt_GetCodepointHMetrics(&i->font, ' ', &advance, &lsb);
symbol->advance = i->scale * advance / symbolDimensions[0];
symbol->ascent = ascent / symbolDimensions[1];
default_ = symbol;
// default_ = strong<GlyphSymbol>(i->symbolSize * sizeof(Pixel));
// default_->data.resize(i->symbolSize);
}
return default_;
}
} // namespace

View File

@@ -0,0 +1,9 @@
#pragma once
#include "GlyphAtlas.h"
namespace tjp::core::graphics::atlas {
struct FontSTB_SDF;
} // namespace

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Font.hpp"
#include "FontSTB_SDF.h"
#include <tjp/core/string/String.h>
namespace tjp::core::graphics::atlas {
struct FontSTB_SDF : Font
{
typedef u8 Pixel;
struct Internal;
StrongPtr<Internal> i;
FontSTB_SDF(const String &name);
StrongPtr<GlyphSymbol> generate(const Character &character) override;
StrongPtr<GlyphSymbol> default_;
StrongPtr<GlyphSymbol> defaultValue() override;
} ;
} // namespace

View File

@@ -0,0 +1,38 @@
#include "GlyphAtlas.hpp"
#include <tjp/core/iterators/range.hpp>
#include <tjp/core/string/starts_with.hpp>
#include <tjp/core/math/Real.h>
#include <tjp/core/math/Algorithm.hpp>
#include <tjp/core/debug/Debug.h>
#include <tjp/core/math/Vector2.inl>
#include <tjp/core/math/Real.inl>
#include <utfcpp/utf8.h>
#include <tjp/core/algorithm/map_erase.hpp>
#include <tjp/core/assert/handle_assert.hpp>
namespace tjp::core::graphics::atlas {
GlyphSymbol::GlyphSymbol(size_t size) :
Super(size)
{
}
StrongPtr<Text> GlyphAtlas::getText(const String &text)
{
auto utf16text = utf8::utf8to16(text);
auto renderable = strong<Text>();
for (auto &c: utf16text)
renderable->symbols.push_back(get(c));
renderable->text = text;
return renderable;
}
} // namespace

View File

@@ -0,0 +1,19 @@
#pragma once
#include <tjp/core/types/Types.h>
namespace tjp::core::graphics::atlas {
typedef size_t Character;
struct GlyphSymbol;
typedef u64 FontID;
struct Font;
struct Text;
struct GlyphAtlas;
} // namespace

View File

@@ -0,0 +1,41 @@
#pragma once
#include "GlyphAtlas.h"
#include "AtlasTyped.hpp"
#include "AtlasAggregate.hpp"
#include <tjp/core/string/String.h>
namespace tjp::core::graphics::atlas {
typedef size_t Character;
struct GlyphSymbol : AtlasTypedSymbol<Character>
{
typedef AtlasTypedSymbol<Character> Super;
GlyphSymbol(size_t size);
math::Vector2f extents;
math::Vector2f offset;
math::Vector2f uv;
float advance;
float ascent;
};
struct Text
{
String text;
Vector<StrongPtr<GlyphSymbol>> symbols;
} ;
struct GlyphAtlas : AtlasTyped<AtlasAggregate, Character, GlyphSymbol, Font>
{
typedef Atlas Super;
StrongPtr<Text> getText(const String &text);
} ;
} // namespace

View File

@@ -0,0 +1,72 @@
#include "IconAtlas.hpp"
#include <tjp/core/iterators/range.hpp>
#include <tjp/core/string/starts_with.hpp>
#include <tjp/core/math/Real.h>
#include <tjp/core/math/Algorithm.hpp>
#include <tjp/core/debug/Debug.h>
#include <tjp/core/math/Vector2.inl>
#include <tjp/core/math/Real.inl>
#include <utfcpp/utf8.h>
#include <tjp/core/algorithm/map_erase.hpp>
#include <tjp/core/assert/handle_assert.hpp>
#include <tjp/core/file/File.h>
#include <tjp/core/string/Str.hpp>
#include <stb/stb_image.h>
namespace tjp::core::graphics::atlas {
IconSource::IconSource (const String &resourcesPath_, const math::Vector2i &symbolDimensions_, size_t pixelSize_) :
resourcesPath(resourcesPath_),
symbolDimensions(symbolDimensions_),
pixelSize(pixelSize_)
{
}
IconSource::~IconSource ()
{
}
StrongPtr<IconSymbol> IconSource::generate(const IconName &name)
{
auto symbol = strong<IconSymbol>(symbolDimensions.x() * symbolDimensions.y() * pixelSize);
String resolution = "-128x128";
auto fileName = resourcesPath + "/images/" + name.toString() + resolution;
fileName += ".png";
if (!file::fileExists(fileName))
{
fileName = resourcesPath + "/images/none-128x128.png";
if (!file::fileExists(fileName))
return symbol;
}
int x, y, n;
auto pixels = stbi_load(fileName.c_str(), &x, &y, &n, 4);
symbol->data.assign(pixels, pixels + (x * y * n));
stbi_image_free(pixels);
return symbol;
}
StrongPtr<IconSource::IconSymbol> IconSource::defaultValue()
{
if (!default_)
{
default_ = strong<IconSymbol>(symbolDimensions.x() * symbolDimensions.y() * pixelSize);
}
return default_;
}
} // namespace

View File

@@ -0,0 +1,15 @@
#pragma once
#include <tjp/core/string/String.h>
#include <tjp/core/string/Str.h>
namespace tjp::core::graphics::atlas {
using IconName = Str;
struct IconSource;
struct IconAtlas;
} // namespace

View File

@@ -0,0 +1,39 @@
#pragma once
#include "IconAtlas.h"
#include "AtlasTyped.hpp"
#include "AtlasAggregate.hpp"
#include <tjp/core/string/String.h>
#include <tjp/core/string/Str.h>
namespace tjp::core::graphics::atlas {
using IconName = Str;
using IconSymbol = AtlasTypedSymbol<IconName>;
struct IconSource
{
IconSource (const String &resourcesPath_, const math::Vector2i &symbolDimensions, size_t pixelSize);
virtual ~IconSource ();
using IconSymbol = atlas::IconSymbol;
String resourcesPath;
StrongPtr<IconSymbol> generate(const IconName &);
StrongPtr<IconSymbol> default_;
StrongPtr<IconSymbol> defaultValue();
math::Vector2i symbolDimensions;
size_t pixelSize;
} ;
struct IconAtlas : AtlasTyped<AtlasAggregate, IconName, IconSymbol, IconSource>
{
typedef AtlasTyped<AtlasAggregate, IconName, IconSymbol, IconSource> Super;
} ;
} // namespace

View File

@@ -0,0 +1,129 @@
#include "AtlasAggregate.hpp"
#include "../AtlasAggregate.hpp"
#include <tjp/core/debug/Debug.h>
#include <tjp/core/log/Log.h>
#include <tjp/core/log/LogOf.h>
#include <tjp/core/math/Math+IO.h>
namespace tjp::core::graphics::atlas::opengl {
AtlasAggregate::AtlasAggregate(const StrongPtr<atlas::AtlasAggregate> &atlas_, graphics::RendererOpenGL *renderer_) :
atlas(atlas_),
renderer(renderer_)
{
}
AtlasAggregate::~AtlasAggregate()
{
}
bool AtlasAggregate::recompute()
{
if (!atlas->recompute())
return false;
if (atlas->aggregate.empty())
return false;
sLogDebug("core::graphics::atlas", "vuku recomputing " << logVar(atlas->aggregate.size()));
sLogDebug("core::graphics::atlas",
logVar(atlas->aggregateDimensions)
<< logVar(atlas->matrixDimensions)
<< logVar(atlas->aggregate.size()));
if (!texture)
{
texture = renderer->memory->makeDiscard<graphics::opengl::Texture>(
graphics::opengl::glGenTexture(), GL_TEXTURE_2D
);
texture->bind();
// Set texture parameters
glValidate(glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glValidate(glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
{
texture->bind();
}
if (renderer->isOpenGLES)
{
Vector<u8> temp;
const auto *data = atlas->aggregate.data();
if (renderer->isOpenGLES && atlas->pixelSize == 1)
{
temp.resize(atlas->aggregate.size() * 4);
auto *p = temp.data();
for (auto &v : atlas->aggregate)
{
*p++ = v;
*p++ = v;
*p++ = v;
*p++ = v;
}
data = temp.data();
}
// Upload texture data
glValidate(
glTexImage2D,
GL_TEXTURE_2D, 0,
GL_RGBA,
(u32)atlas->aggregateDimensions[0],
(u32)atlas->aggregateDimensions[1],
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
data
);
}
else
{
// Upload texture data
glValidate(glTexImage2D,
GL_TEXTURE_2D, 0,
atlas->pixelSize == 1 ?
GL_RED :
GL_RGBA,
(u32)atlas->aggregateDimensions[0],
(u32)atlas->aggregateDimensions[1],
0,
atlas->pixelSize == 1 ?
GL_RED :
GL_RGBA,
GL_UNSIGNED_BYTE,
atlas->aggregate.data()
);
}
texture->unbind();
return true;
}
void AtlasAggregate::bind()
{
texture->bind();
}
void AtlasAggregate::unbind()
{
texture->unbind();
}
} // namespace

View File

@@ -0,0 +1,7 @@
#pragma once
namespace tjp::core::graphics::atlas::opengl {
struct AtlasAggregate;
} // namespace

View File

@@ -0,0 +1,27 @@
#pragma once
#include "../AtlasAggregate.h"
#include "../../opengl.h"
#include <tjp/core/ptr/Ptr.h>
namespace tjp::core::graphics::atlas::opengl {
struct AtlasAggregate
{
AtlasAggregate(const StrongPtr<atlas::AtlasAggregate> &atlas, RendererOpenGL *renderer);
~AtlasAggregate();
StrongPtr<atlas::AtlasAggregate> atlas;
graphics::RendererOpenGL *renderer;
GLDiscardTexture texture;
bool recompute();
void bind();
void unbind();
};
} // namespace

View File

@@ -0,0 +1,22 @@
#pragma once
#include "../../opengl.h"
#include <tjp/core/ptr/Ptr.h>
namespace tjp::core::graphics::atlas::opengl {
template<typename T, typename U>
struct AtlasOf : T
{
typedef T Super;
AtlasOf(const StrongPtr<U> &atlas_, RendererOpenGL *renderer_) :
Super(atlas_, renderer_),
atlas(atlas_)
{}
StrongPtr<U> atlas;
} ;
} // namespace

View File

@@ -0,0 +1,15 @@
#ifndef CROWN_ATLAS_SHADER_EXTENSIONS_H
#define CROWN_ATLAS_SHADER_EXTENSIONS_H
//#extension GL_EXT_shader_explicit_arithmetic_types_int16 : enable
#extension GL_ARB_shading_language_420pack : enable
//#extension GL_ARB_separate_shader_objects : enable
//#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
//#extension GL_EXT_shader_explicit_arithmetic_types_int16 : enable
//#extension GL_EXT_debug_printf : enable
#endif

View File

@@ -0,0 +1,34 @@
#ifndef _ATLAS_TEXTURE_PIXEL_H_
#define _ATLAS_TEXTURE_PIXEL_H_
#include "atlas_types.h"
#include "atlas_texture_uv.h"
//vec4 texture_pixel(in TextureAtlas s, TextureAtlasUV uv);
//vec4 texture_pixel_no_border(in TextureAtlas s, TextureAtlasUV uv);
vec2 inside_clamp(vec2 uv)
{
return clamp(uv, 0.01, 0.99);
}
vec4 pixel_direct(in TextureAtlas s, TextureAtlasIndex textureIndex, vec2 uv, TextureAtlasExtents textureAtlasExtents)
{
uv = inside_clamp(uv);
// TODO: change to atlas_texture_uv(textureIndex, uv, textureAtlasExtents);
TextureAtlasMatrix textureMatrix = generateTextureMatrix(textureIndex, textureAtlasExtents);
return texture_pixel(s, generateTextureCoord(textureMatrix, uv));
}
vec4 pixel_direct_no_border(in TextureAtlas s, TextureAtlasIndex textureIndex, vec2 uv, TextureAtlasExtents textureAtlasExtents)
{
uv = inside_clamp(uv);
TextureAtlasMatrix textureMatrix = generateTextureMatrix(textureIndex, textureAtlasExtents);
return texture_pixel_no_border(s, generateTextureCoord(textureMatrix, uv));
}
#endif

View File

@@ -0,0 +1,45 @@
#ifndef _ATLAS_TEXTURE_BLOOM_H_
#define _ATLAS_TEXTURE_BLOOM_H_
#include "atlas_types.h"
#include "bloom.h"
vec4 bloom(vec3 rgb, vec3 background, float distance, float outlineWidth, float outlineGradientWidth);
vec4 texture_pixel(in TextureAtlas s, TextureAtlasUV uv, vec3 outline)
{
vec4 pixel = texture(s, uv);
return
bloom(
pixel.rgb,
outline,
pixel.a,
0.05,
0.05
);
}
vec3 bloom_borderColor = vec3(1,0,0);
vec4 texture_pixel(in TextureAtlas s, TextureAtlasUV uv)
{
return texture_pixel(s, uv, bloom_borderColor);
}
vec4 texture_pixel_no_border(in TextureAtlas s, TextureAtlasUV uv)
{
vec4 pixel = texture(s, uv);
return
bloom(
pixel.rgb,
pixel.rgb,
pixel.a,
0.05,
0.05
);
}
#endif

View File

@@ -0,0 +1,17 @@
#ifndef _ATLAS_TEXTURE_PASSTHROUGH_H_
#define _ATLAS_TEXTURE_PASSTHROUGH_H_
#include "atlas_types.h"
vec4 texture_pixel(in TextureAtlas s, TextureAtlasUV uv)
{
return texture(s, uv);
}
vec4 texture_pixel_no_border(in TextureAtlas s, TextureAtlasUV uv)
{
return texture(s, uv);
}
#endif

View File

@@ -0,0 +1,67 @@
#ifndef _ATLAS_TEXTURE_UV_H_
#define _ATLAS_TEXTURE_UV_H_
#include "atlas_types.h"
#if defined(USE_ATLAS_AGGREGATE)
TextureAtlasMatrix generateTextureMatrix (TextureAtlasIndex glyph_, TextureAtlasExtents glyphMatrix)
{
if (glyph_ < TextureAtlasIndex(0))
return vec4(0,0,0,0);
int glyph = int(glyph_);
vec2 glyphMatrixPosition = vec2(
glyph % int(glyphMatrix[0]),
glyph / int(glyphMatrix[0])
);
vec2 uvTL = glyphMatrixPosition / glyphMatrix;
return vec4(uvTL[0], uvTL[1], 1.0/glyphMatrix.x, 1.0/glyphMatrix.y);
}
TextureAtlasUV generateTextureCoord(TextureAtlasMatrix matrix, TextureAtlasUV uv)
{
return matrix.xy + uv * matrix.zw;
}
TextureAtlasUV atlas_texture_uv (TextureAtlasIndex glyph_, vec2 uv, TextureAtlasExtents glyphMatrix)
{
int glyph = int(glyph_);
int glyphMatrixi0 = int(glyphMatrix[0]);
vec2 glyphMatrixPosition = vec2(
glyph % glyphMatrixi0,
glyph / glyphMatrixi0
);
vec2 uvTL = glyphMatrixPosition / glyphMatrix;
vec2 uvD = vec2(1,1) / glyphMatrix;
return uv * uvD + uvTL;
}
#elif defined(USE_ATLAS_LAYERS)
TextureAtlasMatrix generateTextureMatrix (TextureAtlasIndex glyph, TextureAtlasExtents glyphMatrix)
{
return TextureAtlasMatrix(glyph);
}
TextureAtlasUV generateTextureCoord(TextureAtlasMatrix matrix, vec2 uv)
{
return vec3(uv.x, uv.y, matrix);
}
TextureAtlasUV atlas_texture_uv (TextureAtlasIndex glyph, vec2 uv, TextureAtlasExtents glyphMatrix)
{
return TextureAtlasUV(uv.x, uv.y, glyph);
}
#else
#pragma error
#endif
#endif

View File

@@ -0,0 +1,18 @@
#ifndef _ATLAS_SHADER_TYPES_
#define _ATLAS_SHADER_TYPES_
#include "base/types.h"
#define VULKAN_VEC2F vec2
#define VULKAN_VEC3F vec3
#define VULKAN_VEC4F vec4
#include "atlas_types_cross.h"
#define TextureAtlasIndex TextureAtlasIndex_VULKAN
#define TextureAtlas TextureAtlas_VULKAN
#define TextureAtlasUV TextureAtlasUV_VULKAN
#define TextureAtlasExtents TextureAtlasExtents_VULKAN
#define TextureAtlasMatrix TextureAtlasMatrix_VULKAN
#endif

View File

@@ -0,0 +1,25 @@
#ifndef _ATLAS_SHADER_TYPES_CROSS_
#define _ATLAS_SHADER_TYPES_CROSS_
#define USE_ATLAS_AGGREGATE
#if defined(USE_ATLAS_AGGREGATE)
#define TextureAtlasIndex_VULKAN r32
#define TextureAtlas_VULKAN sampler2D
#define TextureAtlasUV_VULKAN VULKAN_VEC2F
#define TextureAtlasExtents_VULKAN VULKAN_VEC2F
#define TextureAtlasMatrix_VULKAN VULKAN_VEC4F
#elif defined(USE_ATLAS_LAYERS)
#define TextureAtlasIndex_VULKAN s32
#define TextureAtlas_VULKAN sampler2DArray
#define TextureAtlasUV_VULKAN VULKAN_VEC3F
#define TextureAtlasExtents_VULKAN s32
#define TextureAtlasMatrix_VULKAN s32
#else
#pragma error
#endif
#endif

View File

@@ -0,0 +1 @@
../../shader

View File

@@ -0,0 +1,7 @@
#ifndef _ATLAS_BLOOM_H_
#define _ATLAS_BLOOM_H_
//#include "bloom_alpha.h"
#include "bloom_sdf.h"
#endif

View File

@@ -0,0 +1,50 @@
vec4 bloom_sample(sampler2D textureSampler, vec4 matrix, vec2 uv)
{
uv = clamp(uv, 0.0, 1.0);
// if (textureCoordInvalid(uv))
// return vec4(0,0,0,0);
return texture(textureSampler, generateTextureCoord(matrix, uv));
}
vec4 bloom(sampler2D textureSampler, int textureIndex, vec2 uv, vec3 bloomColor, float cycle, vec4 colorMultiplier)
{
TextureAtlasMatrix textureMatrix = generateTextureMatrix(textureIndex, p.textureAtlasExtents);
vec4 pixel = bloom_sample(textureSampler, textureMatrix, uv);
if (pixel.a > 0.1)
return colorMultiplier * pixel;
vec2 textureOffset = 2 * vec2(0.01, 0.02);
const int iterations = 4;
float a = 0.0;
for(int i = -iterations; i <= iterations; ++i)
{
if (i == 0)
continue;
for(int j = -iterations; j <= iterations; ++j)
{
if (j == 0)
continue;
// eventually should multiply by a matrix
vec2 offset = vec2(textureOffset.x * i, textureOffset.y * j);
a += 2 * bloom_sample(textureSampler, textureMatrix, uv + offset).a / abs(i*j);
}
}
a = clamp(a,0,1);
return vec4(bloomColor.rgb, cycle * a);
}
vec4 bloom(sampler2D textureSampler, int textureIndex, vec2 uv, vec4 bloomColor)
{
return bloom(textureSampler, textureIndex, uv, bloomColor.rgb, bloomColor.a, vec4(1));
}

View File

@@ -0,0 +1,7 @@
#ifndef SHADER_BLOOM_CONSTANTS
#define SHADER_BLOOM_CONSTANTS
//#include "bloom_constants_alpha.h"
#include "bloom_constants_sdf.h"
#endif

View File

@@ -0,0 +1,2 @@
const float bloom_texture_m = 1.5;
const float bloom_offset_m = 1.5;

View File

@@ -0,0 +1,2 @@
const float bloom_texture_m = 1.0;
const float bloom_offset_m = 1.2;

View File

@@ -0,0 +1,66 @@
#include "atlas_types.h"
#include "atlas_texture_uv.h"
vec4 bloom_sample(TextureAtlas textureSampler, TextureAtlasMatrix matrix, vec2 uv)
{
uv = clamp(uv, 0.0, 1.0);
// if (textureCoordInvalid(uv))
// {
// return vec4(0,0,0,0);
//// vec2 uvb = clamp(uv, 0, 1);
//// vec4 pixel = texture(textureSampler, generateTextureCoord(matrix, uvb));
//// pixel.a -= distance(uv, uvb);
//
//// return pixel;
// }
return texture(textureSampler, generateTextureCoord(matrix, uv));
}
vec4 bloom(vec3 rgb, vec3 background, float distance, float outlineWidth, float outlineGradientWidth, float outlineOpacity)
{
float smoothWidth = fwidth(distance);
float outside = 0.5 - smoothWidth;
float inside = 0.5 + smoothWidth;
// smoothstep 0 when x < a, 1 when x > b
float alpha = smoothstep(outside, inside, distance);
float outsideOutline = outside - outlineWidth;
float insideOutline = outsideOutline + outlineGradientWidth;
float alphaOutline = smoothstep(outsideOutline, insideOutline, distance);
alphaOutline = outlineOpacity * alphaOutline;
// the color of the pixel should be the RGB if it's > inside, but BACKGROUND if < outside
rgb = mix(background, rgb, alpha);
alpha = max(alpha, alphaOutline);
return vec4(rgb, alpha);
}
vec4 bloom(vec3 rgb, vec3 background, float distance, float outlineWidth, float outlineGradientWidth)
{
return bloom(rgb, background, distance, outlineWidth, outlineGradientWidth, 1.0);
}
vec4 bloom(TextureAtlas textureSampler, TextureAtlasIndex textureIndex, vec2 uv, vec3 bloomColor, float cycle, vec4 colorMultiplier)
{
TextureAtlasMatrix textureMatrix = generateTextureMatrix(textureIndex, p.textureAtlasExtents);
vec4 pixel = bloom_sample(textureSampler, textureMatrix, uv);
vec3 rgb = colorMultiplier.rgb * pixel.rgb;
float outlineWidth = 0.4;
float outlineGradientWidth = 0.05;
return bloom(rgb, bloomColor, pixel.a, outlineWidth, outlineGradientWidth, cycle);
}
vec4 bloom(TextureAtlas textureSampler, TextureAtlasIndex textureIndex, vec2 uv, vec4 bloomColor)
{
return bloom(textureSampler, textureIndex, uv, bloomColor.rgb, bloomColor.a, vec4(1));
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <tjp/core/types/Types.h>
#include <tjp/core/system/System.h>
#include <tjp/core/math/Vector2.h>
#define VULKAN_VEC2F core::math::Vector2f
#include "../shader/atlas_types_cross.h"
namespace tjp::core::graphics::atlas::vuku {
typedef TextureAtlasIndex_VULKAN AtlasIndex;
typedef TextureAtlasExtents_VULKAN AtlasExtents;
} // namespace

View File

@@ -0,0 +1,83 @@
#include "AtlasAggregate.hpp"
#include "../AtlasAggregate.hpp"
#include <tjp/core/debug/Debug.h>
#include <tjp/core/log/Log.h>
#include <tjp/core/log/LogOf.h>
#include <tjp/core/math/Math+IO.h>
namespace tjp::core::graphics::atlas::vuku {
AtlasAggregate::AtlasAggregate(const StrongPtr<atlas::AtlasAggregate> &atlas_, graphics::RendererVuku *renderer_) :
atlas(atlas_),
renderer(renderer_)
{
auto device = renderer->framework->device();
vku::SamplerMaker sm{};
sm.magFilter(vk::Filter::eLinear);
sm.minFilter(vk::Filter::eLinear);
sampler = sm.createUnique(device);
}
bool AtlasAggregate::recompute()
{
if (!atlas->recompute())
return false;
if (atlas->aggregate.empty())
return false;
sLogDebug("core::graphics::atlas", "vuku recomputing " << logVar(atlas->aggregate.size()));
auto &memoryProperties = renderer->framework->memprops();
auto device = renderer->framework->device();
auto pool = renderer->window->commandPool();
auto queue = renderer->framework->graphicsQueue();
sLogDebug("core::graphics::atlas",
logVar(atlas->aggregateDimensions)
<< logVar(atlas->matrixDimensions)
<< logVar(atlas->aggregate.size()));
if (!texture ||
(texture->info().extent.width != (u32)atlas->aggregateDimensions[0]) ||
(texture->info().extent.height != (u32)atlas->aggregateDimensions[1]))
{
texture = renderer->memory->makeDiscard(
vku::TextureImage2D {
device,
memoryProperties,
(u32)atlas->aggregateDimensions[0],
(u32)atlas->aggregateDimensions[1],
1,
atlas->pixelSize == 1 ?
vk::Format::eR8Unorm :
vk::Format::eR8G8B8A8Unorm
}
);
}
texture->upload(
device,
(u8 *)atlas->aggregate.data(),
atlas->aggregate.size(),
pool,
memoryProperties,
queue
);
return true;
}
vk::ImageView AtlasAggregate::getImageView()
{
return texture->imageView();
}
} // namespace

View File

@@ -0,0 +1,7 @@
#pragma once
namespace tjp::core::graphics::atlas::vuku {
struct AtlasAggregate;
} // namespace

View File

@@ -0,0 +1,26 @@
#pragma once
#include "../AtlasAggregate.h"
#include "../../vuku.h"
#include <tjp/core/ptr/Ptr.h>
namespace tjp::core::graphics::atlas::vuku {
struct AtlasAggregate
{
AtlasAggregate(const StrongPtr<atlas::AtlasAggregate> &atlas, RendererVuku *renderer);
StrongPtr<atlas::AtlasAggregate> atlas;
graphics::RendererVuku *renderer;
VkDiscard<vku::TextureImage2D> texture;
vk::UniqueSampler sampler;
bool recompute();
vk::ImageView getImageView();
};
} // namespace

View File

@@ -0,0 +1,139 @@
#include "AtlasLayers.hpp"
#include "../Atlas.hpp"
#include <tjp/core/debug/Debug.h>
#include <tjp/core/log/Log.h>
#include <tjp/core/log/LogOf.h>
#include <tjp/core/math/Math+IO.h>
namespace tjp::core::graphics::atlas::vuku {
AtlasLayers::AtlasLayers(const StrongPtr<atlas::Atlas> &atlas_, graphics::RendererVuku *renderer_) :
atlas(atlas_),
renderer(renderer_)
{
auto device = renderer->framework->device();
vku::SamplerMaker sm{};
sm.magFilter(vk::Filter::eLinear);
sm.minFilter(vk::Filter::eLinear);
sampler = sm.createUnique(device);
}
bool AtlasLayers::recompute()
{
if (!atlas->recompute())
return false;
Vector<StrongPtr<Symbol>> symbols;
symbols.reserve(atlas->symbols.size());
Index numSymbolSlots = 0;
for (auto &[key, symbol_]: atlas->symbols)
{
if (auto symbol = strong(symbol_))
{
symbols.push_back(symbol);
numSymbolSlots = std::max(numSymbolSlots, (u16)(symbol->index+1));
}
}
auto &memoryProperties = renderer->framework->memprops();
auto device = renderer->framework->device();
auto pool = renderer->window->commandPool();
auto queue = renderer->framework->graphicsQueue();
auto newNumImages = (numSymbolSlots + 15) & ~0x0F;
if (newNumImages == 0)
newNumImages = 1;
debug_assert(newNumImages == ((numSymbolSlots + 15) / 16 * 16));
sLogDebug("debug", logVar(numSymbolSlots) << logVar(atlas->symbols.size()) << logVar(newNumImages) << logVar(numImages));
if (newNumImages != numImages)
{
numImages = newNumImages;
constexpr bool hostImage = false;
vk::ImageCreateInfo info;
info.flags = {};
// info.flags = {vk::ImageCreateFlagBits::eCubeCompatible};
info.imageType = vk::ImageType::e2D;
info.format = vk::Format::eR8G8B8A8Unorm;
info.extent = vk::Extent3D{ (u32)atlas->symbolDimensions.x(), (u32)atlas->symbolDimensions.y(), 1U };
info.mipLevels = 1;
info.arrayLayers = newNumImages;
info.samples = vk::SampleCountFlagBits::e1;
info.tiling = hostImage ? vk::ImageTiling::eLinear : vk::ImageTiling::eOptimal;
info.usage = vk::ImageUsageFlagBits::eColorAttachment|vk::ImageUsageFlagBits::eSampled|vk::ImageUsageFlagBits::eTransferSrc|vk::ImageUsageFlagBits::eTransferDst;
info.sharingMode = vk::SharingMode::eExclusive;
info.queueFamilyIndexCount = 0;
info.pQueueFamilyIndices = nullptr;
info.initialLayout = hostImage ? vk::ImageLayout::ePreinitialized : vk::ImageLayout::eUndefined;
vk::ImageViewType viewType = vk::ImageViewType::e2DArray;
vk::ImageAspectFlags aspectMask = vk::ImageAspectFlagBits::eColor;
image = renderer->memory->makeDiscard(
vku::GenericImage(device, memoryProperties, info, viewType, aspectMask, hostImage)
);
}
auto symbolDimensions = atlas->symbolDimensions;
auto symbolSize = symbolDimensions.x() * symbolDimensions.y() * atlas->pixelSize;
vku::GenericBuffer stagingBuffer(device, memoryProperties, (vk::BufferUsageFlags)vk::BufferUsageFlagBits::eTransferSrc, (vk::DeviceSize)symbolSize * numSymbolSlots, vk::MemoryPropertyFlagBits::eHostVisible);
char *ptr = (char *)stagingBuffer.map(device);
for (auto &symbol: symbols)
{
auto symbolOffset = (size_t)(symbol->index * symbolSize);
memcpy(ptr + symbolOffset, symbol->data.data(), symbol->data.size());
}
stagingBuffer.unmap(device);
vk::Buffer buf = stagingBuffer.buffer();
vku::executeImmediately(device, pool, queue, [&](vk::CommandBuffer cb) {
for (auto &symbol: symbols)
{
image->copy(
cb, buf, 0,
symbol->index, symbolDimensions.x(), symbolDimensions.y(),
1, symbolSize * symbol->index
);
}
image->setLayout(cb, vk::ImageLayout::eShaderReadOnlyOptimal);
});
//
// texture->upload(
// device,
// (u8 *)atlas->aggregate.data(),
// atlas->aggregate.size(),
// pool,
// memoryProperties,
// queue
// );
//
return true;
}
vk::ImageView AtlasLayers::getImageView()
{
return image->imageView();
}
} // namespace

View File

@@ -0,0 +1,7 @@
#pragma once
namespace tjp::core::graphics::atlas::vuku {
struct AtlasLayers;
} // namespace

View File

@@ -0,0 +1,27 @@
#pragma once
#include "../AtlasAggregate.h"
#include "../../vuku.h"
#include <tjp/core/ptr/Ptr.h>
namespace tjp::core::graphics::atlas::vuku {
struct AtlasLayers
{
AtlasLayers(const StrongPtr<atlas::Atlas> &atlas, RendererVuku *renderer);
StrongPtr<atlas::Atlas> atlas;
graphics::RendererVuku *renderer;
VkDiscard<vku::GenericImage> image;
vk::UniqueSampler sampler;
size_t numImages = 0;
bool recompute();
vk::ImageView getImageView();
};
} // namespace

View File

@@ -0,0 +1,22 @@
#pragma once
#include "../../vuku.h"
#include <tjp/core/ptr/Ptr.h>
namespace tjp::core::graphics::atlas::vuku {
template<typename T, typename U>
struct AtlasOf : T
{
typedef T Super;
AtlasOf(const StrongPtr<U> &atlas_, RendererVuku *renderer_) :
Super(atlas_, renderer_),
atlas(atlas_)
{}
StrongPtr<U> atlas;
} ;
} // namespace

View File

@@ -0,0 +1,64 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#include "bgfx.h"
#include <cstring>
namespace tjp {
namespace core {
namespace graphics {
RendererBgfx::RendererBgfx(const char *resourcesPath_, void *view, int width, int height)
{
resourcesPath = resourcesPath_;
m_view = view;
m_width = width;
m_height = height;
m_debug = BGFX_DEBUG_TEXT;
m_reset = BGFX_RESET_VSYNC;
m_type = bgfx::RendererType::Metal;
m_pciId = 0;
bgfx::renderFrame();
bgfx::Init init;
init.type = bgfx::RendererType::Count;
init.vendorId = 0;
init.resolution.width = m_width;
init.resolution.height = m_height;
init.resolution.reset = m_reset;
init.platformData.nwh = m_view;
bgfx::init(init);
// Enable debug text.
bgfx::setDebug(m_debug);
// Set view 0 clear state.
bgfx::setViewClear(0
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0x000000ff
, 1.0f
, 0
);
}
const bgfx::Memory* RendererBgfx::toMem(const std::vector<char> &memory)
{
const bgfx::Memory* mem = bgfx::alloc((uint32_t)memory.size()+1);
memcpy(mem->data, memory.data(), memory.size());
mem->data[memory.size()] = 0;
return mem;
}
}
}
}

View File

@@ -0,0 +1,49 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include <tjp/core/system/DisableWarningsPush.h>
#include "bgfx/platform.h"
#include "bx/bx.h"
#include "bx/timer.h"
#include <tjp/core/system/DisableWarningsPop.h>
#include <string>
#include <vector>
namespace tjp {
namespace core {
namespace graphics {
struct RendererBgfx
{
int m_width;
int m_height;
uint32_t m_debug;
uint32_t m_reset;
bgfx::RendererType::Enum m_type;
uint16_t m_pciId;
void *m_view;
std::string resourcesPath;
RendererBgfx(const char *resourcesPath, void *m_layer, int width, int height);
const bgfx::Memory* toMem(const std::vector<char> &memory);
} ;
}
}
}

View File

@@ -0,0 +1,125 @@
//-----------------------------------------------------------------------------
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
//-----------------------------------------------------------------------------
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
//-----------------------------------------------------------------------------
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
//-----------------------------------------------------------------------------
#pragma once
//---- Define assertion handler. Defaults to calling assert().
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
//---- Disable all of Dear ImGui or don't implement standard windows/tools.
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowStackToolWindow() will be empty (this was called IMGUI_DISABLE_METRICS_WINDOW before 1.88).
//---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
//---- Include imgui_user.h at the end of imgui.h as a convenience
//#define IMGUI_INCLUDE_IMGUI_USER_H
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
//#define IMGUI_USE_BGRA_PACKED_COLOR
//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
//#define IMGUI_USE_WCHAR32
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
//#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if enabled
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
//---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
// Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h.
//#define IMGUI_USE_STB_SPRINTF
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
//#define IMGUI_ENABLE_FREETYPE
//---- Use stb_truetype to build and rasterize the font atlas (default)
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
//#define IMGUI_ENABLE_STB_TRUETYPE
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
/*
#define IM_VEC2_CLASS_EXTRA \
constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \
operator MyVec2() const { return MyVec2(x,y); }
#define IM_VEC4_CLASS_EXTRA \
constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \
operator MyVec4() const { return MyVec4(x,y,z,w); }
*/
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
//#define ImDrawIdx unsigned int
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
//struct ImDrawList;
//struct ImDrawCmd;
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
//#define ImDrawCallback MyImDrawCallback
//---- Debug Tools: Macro to break in Debugger
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
//#define IM_DEBUG_BREAK IM_ASSERT(0)
//#define IM_DEBUG_BREAK __debugbreak()
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
// This adds a small runtime cost which is why it is not enabled by default.
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
//---- Debug Tools: Enable slower asserts
//#define IMGUI_DEBUG_PARANOID
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
/*
namespace ImGui
{
void MyFunction(const char* name, const MyMatrix44& v);
}
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,662 @@
// dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
// (Requires: GLFW 3.1+)
// Implemented features:
// [X] Platform: Clipboard support.
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2022-04-30: Inputs: Fixed ImGui_ImplGlfw_TranslateUntranslatedKey() for lower case letters on OSX.
// 2022-03-23: Inputs: Fixed a regression in 1.87 which resulted in keyboard modifiers events being reported incorrectly on Linux/X11.
// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after initializing backend.
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
// 2022-01-17: Inputs: always update key mods next and before key event (not in NewFrame) to fix input queue with very low framerates.
// 2022-01-12: *BREAKING CHANGE*: Now using glfwSetCursorPosCallback(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetCursorPosCallback() and forward it to the backend via ImGui_ImplGlfw_CursorPosCallback().
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
// 2022-01-05: Inputs: Converting GLFW untranslated keycodes back to translated keycodes (in the ImGui_ImplGlfw_KeyCallback() function) in order to match the behavior of every other backend, and facilitate the use of GLFW with lettered-shortcuts API.
// 2021-08-17: *BREAKING CHANGE*: Now using glfwSetWindowFocusCallback() to calling io.AddFocusEvent(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() and forward it to the backend via ImGui_ImplGlfw_WindowFocusCallback().
// 2021-07-29: *BREAKING CHANGE*: Now using glfwSetCursorEnterCallback(). MousePos is correctly reported when the host platform window is hovered but not focused. If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() callback and forward it to the backend via ImGui_ImplGlfw_CursorEnterCallback().
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
// 2020-01-17: Inputs: Disable error callback while assigning mouse cursors because some X11 setup don't have them and it generates errors.
// 2019-12-05: Inputs: Added support for new mouse cursors added in GLFW 3.4+ (resizing cursors, not allowed cursor).
// 2019-10-18: Misc: Previously installed user callbacks are now restored on shutdown.
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
// 2018-11-07: Inputs: When installing our GLFW callbacks, we save user's previously installed ones - if any - and chain call them.
// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
// 2018-06-08: Misc: Extracted imgui_impl_glfw.cpp/.h away from the old combined GLFW+OpenGL/Vulkan examples.
// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value, passed to glfwSetCursor()).
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
// 2018-01-25: Inputs: Added gamepad support if ImGuiConfigFlags_NavEnableGamepad is set.
// 2018-01-25: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
#include "imgui.h"
#include "imgui_impl_glfw.h"
// Clang warnings with -Weverything
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
#if __has_warning("-Wzero-as-null-pointer-constant")
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#endif
// GLFW
#include <GLFW/glfw3.h>
#ifdef _WIN32
#undef APIENTRY
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h> // for glfwGetWin32Window
#endif
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
#else
#define GLFW_HAS_NEW_CURSORS (0)
#endif
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetGamepadState() new api
#define GLFW_HAS_GET_KEY_NAME (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwGetKeyName()
// GLFW data
enum GlfwClientApi
{
GlfwClientApi_Unknown,
GlfwClientApi_OpenGL,
GlfwClientApi_Vulkan
};
struct ImGui_ImplGlfw_Data
{
GLFWwindow* Window;
GlfwClientApi ClientApi;
double Time;
GLFWwindow* MouseWindow;
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
ImVec2 LastValidMousePos;
bool InstalledCallbacks;
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
GLFWwindowfocusfun PrevUserCallbackWindowFocus;
GLFWcursorposfun PrevUserCallbackCursorPos;
GLFWcursorenterfun PrevUserCallbackCursorEnter;
GLFWmousebuttonfun PrevUserCallbackMousebutton;
GLFWscrollfun PrevUserCallbackScroll;
GLFWkeyfun PrevUserCallbackKey;
GLFWcharfun PrevUserCallbackChar;
GLFWmonitorfun PrevUserCallbackMonitor;
ImGui_ImplGlfw_Data() { memset((void*)this, 0, sizeof(*this)); }
};
// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
// FIXME: multi-context support is not well tested and probably dysfunctional in this backend.
// - Because glfwPollEvents() process all windows and some events may be called outside of it, you will need to register your own callbacks
// (passing install_callbacks=false in ImGui_ImplGlfw_InitXXX functions), set the current dear imgui context and then call our callbacks.
// - Otherwise we may need to store a GLFWWindow* -> ImGuiContext* map and handle this in the backend, adding a little bit of extra complexity to it.
// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context.
static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData()
{
return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : NULL;
}
// Functions
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
{
return glfwGetClipboardString((GLFWwindow*)user_data);
}
static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
{
glfwSetClipboardString((GLFWwindow*)user_data, text);
}
static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
{
switch (key)
{
case GLFW_KEY_TAB: return ImGuiKey_Tab;
case GLFW_KEY_LEFT: return ImGuiKey_LeftArrow;
case GLFW_KEY_RIGHT: return ImGuiKey_RightArrow;
case GLFW_KEY_UP: return ImGuiKey_UpArrow;
case GLFW_KEY_DOWN: return ImGuiKey_DownArrow;
case GLFW_KEY_PAGE_UP: return ImGuiKey_PageUp;
case GLFW_KEY_PAGE_DOWN: return ImGuiKey_PageDown;
case GLFW_KEY_HOME: return ImGuiKey_Home;
case GLFW_KEY_END: return ImGuiKey_End;
case GLFW_KEY_INSERT: return ImGuiKey_Insert;
case GLFW_KEY_DELETE: return ImGuiKey_Delete;
case GLFW_KEY_BACKSPACE: return ImGuiKey_Backspace;
case GLFW_KEY_SPACE: return ImGuiKey_Space;
case GLFW_KEY_ENTER: return ImGuiKey_Enter;
case GLFW_KEY_ESCAPE: return ImGuiKey_Escape;
case GLFW_KEY_APOSTROPHE: return ImGuiKey_Apostrophe;
case GLFW_KEY_COMMA: return ImGuiKey_Comma;
case GLFW_KEY_MINUS: return ImGuiKey_Minus;
case GLFW_KEY_PERIOD: return ImGuiKey_Period;
case GLFW_KEY_SLASH: return ImGuiKey_Slash;
case GLFW_KEY_SEMICOLON: return ImGuiKey_Semicolon;
case GLFW_KEY_EQUAL: return ImGuiKey_Equal;
case GLFW_KEY_LEFT_BRACKET: return ImGuiKey_LeftBracket;
case GLFW_KEY_BACKSLASH: return ImGuiKey_Backslash;
case GLFW_KEY_RIGHT_BRACKET: return ImGuiKey_RightBracket;
case GLFW_KEY_GRAVE_ACCENT: return ImGuiKey_GraveAccent;
case GLFW_KEY_CAPS_LOCK: return ImGuiKey_CapsLock;
case GLFW_KEY_SCROLL_LOCK: return ImGuiKey_ScrollLock;
case GLFW_KEY_NUM_LOCK: return ImGuiKey_NumLock;
case GLFW_KEY_PRINT_SCREEN: return ImGuiKey_PrintScreen;
case GLFW_KEY_PAUSE: return ImGuiKey_Pause;
case GLFW_KEY_KP_0: return ImGuiKey_Keypad0;
case GLFW_KEY_KP_1: return ImGuiKey_Keypad1;
case GLFW_KEY_KP_2: return ImGuiKey_Keypad2;
case GLFW_KEY_KP_3: return ImGuiKey_Keypad3;
case GLFW_KEY_KP_4: return ImGuiKey_Keypad4;
case GLFW_KEY_KP_5: return ImGuiKey_Keypad5;
case GLFW_KEY_KP_6: return ImGuiKey_Keypad6;
case GLFW_KEY_KP_7: return ImGuiKey_Keypad7;
case GLFW_KEY_KP_8: return ImGuiKey_Keypad8;
case GLFW_KEY_KP_9: return ImGuiKey_Keypad9;
case GLFW_KEY_KP_DECIMAL: return ImGuiKey_KeypadDecimal;
case GLFW_KEY_KP_DIVIDE: return ImGuiKey_KeypadDivide;
case GLFW_KEY_KP_MULTIPLY: return ImGuiKey_KeypadMultiply;
case GLFW_KEY_KP_SUBTRACT: return ImGuiKey_KeypadSubtract;
case GLFW_KEY_KP_ADD: return ImGuiKey_KeypadAdd;
case GLFW_KEY_KP_ENTER: return ImGuiKey_KeypadEnter;
case GLFW_KEY_KP_EQUAL: return ImGuiKey_KeypadEqual;
case GLFW_KEY_LEFT_SHIFT: return ImGuiKey_LeftShift;
case GLFW_KEY_LEFT_CONTROL: return ImGuiKey_LeftCtrl;
case GLFW_KEY_LEFT_ALT: return ImGuiKey_LeftAlt;
case GLFW_KEY_LEFT_SUPER: return ImGuiKey_LeftSuper;
case GLFW_KEY_RIGHT_SHIFT: return ImGuiKey_RightShift;
case GLFW_KEY_RIGHT_CONTROL: return ImGuiKey_RightCtrl;
case GLFW_KEY_RIGHT_ALT: return ImGuiKey_RightAlt;
case GLFW_KEY_RIGHT_SUPER: return ImGuiKey_RightSuper;
case GLFW_KEY_MENU: return ImGuiKey_Menu;
case GLFW_KEY_0: return ImGuiKey_0;
case GLFW_KEY_1: return ImGuiKey_1;
case GLFW_KEY_2: return ImGuiKey_2;
case GLFW_KEY_3: return ImGuiKey_3;
case GLFW_KEY_4: return ImGuiKey_4;
case GLFW_KEY_5: return ImGuiKey_5;
case GLFW_KEY_6: return ImGuiKey_6;
case GLFW_KEY_7: return ImGuiKey_7;
case GLFW_KEY_8: return ImGuiKey_8;
case GLFW_KEY_9: return ImGuiKey_9;
case GLFW_KEY_A: return ImGuiKey_A;
case GLFW_KEY_B: return ImGuiKey_B;
case GLFW_KEY_C: return ImGuiKey_C;
case GLFW_KEY_D: return ImGuiKey_D;
case GLFW_KEY_E: return ImGuiKey_E;
case GLFW_KEY_F: return ImGuiKey_F;
case GLFW_KEY_G: return ImGuiKey_G;
case GLFW_KEY_H: return ImGuiKey_H;
case GLFW_KEY_I: return ImGuiKey_I;
case GLFW_KEY_J: return ImGuiKey_J;
case GLFW_KEY_K: return ImGuiKey_K;
case GLFW_KEY_L: return ImGuiKey_L;
case GLFW_KEY_M: return ImGuiKey_M;
case GLFW_KEY_N: return ImGuiKey_N;
case GLFW_KEY_O: return ImGuiKey_O;
case GLFW_KEY_P: return ImGuiKey_P;
case GLFW_KEY_Q: return ImGuiKey_Q;
case GLFW_KEY_R: return ImGuiKey_R;
case GLFW_KEY_S: return ImGuiKey_S;
case GLFW_KEY_T: return ImGuiKey_T;
case GLFW_KEY_U: return ImGuiKey_U;
case GLFW_KEY_V: return ImGuiKey_V;
case GLFW_KEY_W: return ImGuiKey_W;
case GLFW_KEY_X: return ImGuiKey_X;
case GLFW_KEY_Y: return ImGuiKey_Y;
case GLFW_KEY_Z: return ImGuiKey_Z;
case GLFW_KEY_F1: return ImGuiKey_F1;
case GLFW_KEY_F2: return ImGuiKey_F2;
case GLFW_KEY_F3: return ImGuiKey_F3;
case GLFW_KEY_F4: return ImGuiKey_F4;
case GLFW_KEY_F5: return ImGuiKey_F5;
case GLFW_KEY_F6: return ImGuiKey_F6;
case GLFW_KEY_F7: return ImGuiKey_F7;
case GLFW_KEY_F8: return ImGuiKey_F8;
case GLFW_KEY_F9: return ImGuiKey_F9;
case GLFW_KEY_F10: return ImGuiKey_F10;
case GLFW_KEY_F11: return ImGuiKey_F11;
case GLFW_KEY_F12: return ImGuiKey_F12;
default: return ImGuiKey_None;
}
}
static int ImGui_ImplGlfw_KeyToModifier(int key)
{
if (key == GLFW_KEY_LEFT_CONTROL || key == GLFW_KEY_RIGHT_CONTROL)
return GLFW_MOD_CONTROL;
if (key == GLFW_KEY_LEFT_SHIFT || key == GLFW_KEY_RIGHT_SHIFT)
return GLFW_MOD_SHIFT;
if (key == GLFW_KEY_LEFT_ALT || key == GLFW_KEY_RIGHT_ALT)
return GLFW_MOD_ALT;
if (key == GLFW_KEY_LEFT_SUPER || key == GLFW_KEY_RIGHT_SUPER)
return GLFW_MOD_SUPER;
return 0;
}
static void ImGui_ImplGlfw_UpdateKeyModifiers(int mods)
{
ImGuiIO& io = ImGui::GetIO();
io.AddKeyEvent(ImGuiKey_ModCtrl, (mods & GLFW_MOD_CONTROL) != 0);
io.AddKeyEvent(ImGuiKey_ModShift, (mods & GLFW_MOD_SHIFT) != 0);
io.AddKeyEvent(ImGuiKey_ModAlt, (mods & GLFW_MOD_ALT) != 0);
io.AddKeyEvent(ImGuiKey_ModSuper, (mods & GLFW_MOD_SUPER) != 0);
}
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (bd->PrevUserCallbackMousebutton != NULL && window == bd->Window)
bd->PrevUserCallbackMousebutton(window, button, action, mods);
ImGui_ImplGlfw_UpdateKeyModifiers(mods);
ImGuiIO& io = ImGui::GetIO();
if (button >= 0 && button < ImGuiMouseButton_COUNT)
io.AddMouseButtonEvent(button, action == GLFW_PRESS);
}
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (bd->PrevUserCallbackScroll != NULL && window == bd->Window)
bd->PrevUserCallbackScroll(window, xoffset, yoffset);
ImGuiIO& io = ImGui::GetIO();
io.AddMouseWheelEvent((float)xoffset, (float)yoffset);
}
static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
{
#if GLFW_HAS_GET_KEY_NAME && !defined(__EMSCRIPTEN__)
// GLFW 3.1+ attempts to "untranslate" keys, which goes the opposite of what every other framework does, making using lettered shortcuts difficult.
// (It had reasons to do so: namely GLFW is/was more likely to be used for WASD-type game controls rather than lettered shortcuts, but IHMO the 3.1 change could have been done differently)
// See https://github.com/glfw/glfw/issues/1502 for details.
// Adding a workaround to undo this (so our keys are translated->untranslated->translated, likely a lossy process).
// This won't cover edge cases but this is at least going to cover common cases.
if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_EQUAL)
return key;
const char* key_name = glfwGetKeyName(key, scancode);
if (key_name && key_name[0] != 0 && key_name[1] == 0)
{
const char char_names[] = "`-=[]\\,;\'./";
const int char_keys[] = { GLFW_KEY_GRAVE_ACCENT, GLFW_KEY_MINUS, GLFW_KEY_EQUAL, GLFW_KEY_LEFT_BRACKET, GLFW_KEY_RIGHT_BRACKET, GLFW_KEY_BACKSLASH, GLFW_KEY_COMMA, GLFW_KEY_SEMICOLON, GLFW_KEY_APOSTROPHE, GLFW_KEY_PERIOD, GLFW_KEY_SLASH, 0 };
IM_ASSERT(IM_ARRAYSIZE(char_names) == IM_ARRAYSIZE(char_keys));
if (key_name[0] >= '0' && key_name[0] <= '9') { key = GLFW_KEY_0 + (key_name[0] - '0'); }
else if (key_name[0] >= 'A' && key_name[0] <= 'Z') { key = GLFW_KEY_A + (key_name[0] - 'A'); }
else if (key_name[0] >= 'a' && key_name[0] <= 'z') { key = GLFW_KEY_A + (key_name[0] - 'a'); }
else if (const char* p = strchr(char_names, key_name[0])) { key = char_keys[p - char_names]; }
}
// if (action == GLFW_PRESS) printf("key %d scancode %d name '%s'\n", key, scancode, key_name);
#else
IM_UNUSED(scancode);
#endif
return key;
}
void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int keycode, int scancode, int action, int mods)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (bd->PrevUserCallbackKey != NULL && window == bd->Window)
bd->PrevUserCallbackKey(window, keycode, scancode, action, mods);
if (action != GLFW_PRESS && action != GLFW_RELEASE)
return;
// Workaround: X11 does not include current pressed/released modifier key in 'mods' flags. https://github.com/glfw/glfw/issues/1630
if (int keycode_to_mod = ImGui_ImplGlfw_KeyToModifier(keycode))
mods = (action == GLFW_PRESS) ? (mods | keycode_to_mod) : (mods & ~keycode_to_mod);
ImGui_ImplGlfw_UpdateKeyModifiers(mods);
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
ImGuiIO& io = ImGui::GetIO();
ImGuiKey imgui_key = ImGui_ImplGlfw_KeyToImGuiKey(keycode);
io.AddKeyEvent(imgui_key, (action == GLFW_PRESS));
io.SetKeyEventNativeData(imgui_key, keycode, scancode); // To support legacy indexing (<1.87 user code)
}
void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (bd->PrevUserCallbackWindowFocus != NULL && window == bd->Window)
bd->PrevUserCallbackWindowFocus(window, focused);
ImGuiIO& io = ImGui::GetIO();
io.AddFocusEvent(focused != 0);
}
void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (bd->PrevUserCallbackCursorPos != NULL && window == bd->Window)
bd->PrevUserCallbackCursorPos(window, x, y);
ImGuiIO& io = ImGui::GetIO();
io.AddMousePosEvent((float)x, (float)y);
bd->LastValidMousePos = ImVec2((float)x, (float)y);
}
// Workaround: X11 seems to send spurious Leave/Enter events which would make us lose our position,
// so we back it up and restore on Leave/Enter (see https://github.com/ocornut/imgui/issues/4984)
void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (bd->PrevUserCallbackCursorEnter != NULL && window == bd->Window)
bd->PrevUserCallbackCursorEnter(window, entered);
ImGuiIO& io = ImGui::GetIO();
if (entered)
{
bd->MouseWindow = window;
io.AddMousePosEvent(bd->LastValidMousePos.x, bd->LastValidMousePos.y);
}
else if (!entered && bd->MouseWindow == window)
{
bd->LastValidMousePos = io.MousePos;
bd->MouseWindow = NULL;
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
}
}
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (bd->PrevUserCallbackChar != NULL && window == bd->Window)
bd->PrevUserCallbackChar(window, c);
ImGuiIO& io = ImGui::GetIO();
io.AddInputCharacter(c);
}
void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
{
// Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too.
}
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
IM_ASSERT(bd->InstalledCallbacks == false && "Callbacks already installed!");
IM_ASSERT(bd->Window == window);
bd->PrevUserCallbackWindowFocus = glfwSetWindowFocusCallback(window, ImGui_ImplGlfw_WindowFocusCallback);
bd->PrevUserCallbackCursorEnter = glfwSetCursorEnterCallback(window, ImGui_ImplGlfw_CursorEnterCallback);
bd->PrevUserCallbackCursorPos = glfwSetCursorPosCallback(window, ImGui_ImplGlfw_CursorPosCallback);
bd->PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
bd->PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
bd->PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
bd->PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
bd->PrevUserCallbackMonitor = glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
bd->InstalledCallbacks = true;
}
void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
IM_ASSERT(bd->InstalledCallbacks == true && "Callbacks not installed!");
IM_ASSERT(bd->Window == window);
glfwSetWindowFocusCallback(window, bd->PrevUserCallbackWindowFocus);
glfwSetCursorEnterCallback(window, bd->PrevUserCallbackCursorEnter);
glfwSetCursorPosCallback(window, bd->PrevUserCallbackCursorPos);
glfwSetMouseButtonCallback(window, bd->PrevUserCallbackMousebutton);
glfwSetScrollCallback(window, bd->PrevUserCallbackScroll);
glfwSetKeyCallback(window, bd->PrevUserCallbackKey);
glfwSetCharCallback(window, bd->PrevUserCallbackChar);
glfwSetMonitorCallback(bd->PrevUserCallbackMonitor);
bd->InstalledCallbacks = false;
bd->PrevUserCallbackWindowFocus = NULL;
bd->PrevUserCallbackCursorEnter = NULL;
bd->PrevUserCallbackCursorPos = NULL;
bd->PrevUserCallbackMousebutton = NULL;
bd->PrevUserCallbackScroll = NULL;
bd->PrevUserCallbackKey = NULL;
bd->PrevUserCallbackChar = NULL;
bd->PrevUserCallbackMonitor = NULL;
}
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
{
ImGuiIO& io = ImGui::GetIO();
IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
// Setup backend capabilities flags
ImGui_ImplGlfw_Data* bd = IM_NEW(ImGui_ImplGlfw_Data)();
io.BackendPlatformUserData = (void*)bd;
io.BackendPlatformName = "imgui_impl_glfw";
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
bd->Window = window;
bd->Time = 0.0;
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
io.ClipboardUserData = bd->Window;
// Set platform dependent data in viewport
#if defined(_WIN32)
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)glfwGetWin32Window(bd->Window);
#endif
// Create mouse cursors
// (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist,
// GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting.
// Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.)
GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL);
bd->MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
#if GLFW_HAS_NEW_CURSORS
bd->MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR);
#else
bd->MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
#endif
glfwSetErrorCallback(prev_error_callback);
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
if (install_callbacks)
ImGui_ImplGlfw_InstallCallbacks(window);
bd->ClientApi = client_api;
return true;
}
bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks)
{
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL);
}
bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
{
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan);
}
bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks)
{
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Unknown);
}
void ImGui_ImplGlfw_Shutdown()
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO();
if (bd->InstalledCallbacks)
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
glfwDestroyCursor(bd->MouseCursors[cursor_n]);
io.BackendPlatformName = NULL;
io.BackendPlatformUserData = NULL;
IM_DELETE(bd);
}
static void ImGui_ImplGlfw_UpdateMouseData()
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGuiIO& io = ImGui::GetIO();
#ifdef __EMSCRIPTEN__
const bool is_app_focused = true;
#else
const bool is_app_focused = glfwGetWindowAttrib(bd->Window, GLFW_FOCUSED) != 0;
#endif
if (is_app_focused)
{
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
if (io.WantSetMousePos)
glfwSetCursorPos(bd->Window, (double)io.MousePos.x, (double)io.MousePos.y);
// (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured)
if (is_app_focused && bd->MouseWindow == NULL)
{
double mouse_x, mouse_y;
glfwGetCursorPos(bd->Window, &mouse_x, &mouse_y);
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
}
}
}
static void ImGui_ImplGlfw_UpdateMouseCursor()
{
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(bd->Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
return;
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
{
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
glfwSetInputMode(bd->Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
}
else
{
// Show OS mouse cursor
// FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
glfwSetCursor(bd->Window, bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow]);
glfwSetInputMode(bd->Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
}
// Update gamepad inputs
static inline float Saturate(float v) { return v < 0.0f ? 0.0f : v > 1.0f ? 1.0f : v; }
static void ImGui_ImplGlfw_UpdateGamepads()
{
ImGuiIO& io = ImGui::GetIO();
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
return;
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
#if GLFW_HAS_GAMEPAD_API
GLFWgamepadstate gamepad;
if (!glfwGetGamepadState(GLFW_JOYSTICK_1, &gamepad))
return;
#define MAP_BUTTON(KEY_NO, BUTTON_NO, _UNUSED) do { io.AddKeyEvent(KEY_NO, gamepad.buttons[BUTTON_NO] != 0); } while (0)
#define MAP_ANALOG(KEY_NO, AXIS_NO, _UNUSED, V0, V1) do { float v = gamepad.axes[AXIS_NO]; v = (v - V0) / (V1 - V0); io.AddKeyAnalogEvent(KEY_NO, v > 0.10f, Saturate(v)); } while (0)
#else
int axes_count = 0, buttons_count = 0;
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
if (axes_count == 0 || buttons_count == 0)
return;
#define MAP_BUTTON(KEY_NO, _UNUSED, BUTTON_NO) do { io.AddKeyEvent(KEY_NO, (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS)); } while (0)
#define MAP_ANALOG(KEY_NO, _UNUSED, AXIS_NO, V0, V1) do { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); io.AddKeyAnalogEvent(KEY_NO, v > 0.10f, Saturate(v)); } while (0)
#endif
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
MAP_BUTTON(ImGuiKey_GamepadStart, GLFW_GAMEPAD_BUTTON_START, 7);
MAP_BUTTON(ImGuiKey_GamepadBack, GLFW_GAMEPAD_BUTTON_BACK, 6);
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, GLFW_GAMEPAD_BUTTON_X, 2); // Xbox X, PS Square
MAP_BUTTON(ImGuiKey_GamepadFaceRight, GLFW_GAMEPAD_BUTTON_B, 1); // Xbox B, PS Circle
MAP_BUTTON(ImGuiKey_GamepadFaceUp, GLFW_GAMEPAD_BUTTON_Y, 3); // Xbox Y, PS Triangle
MAP_BUTTON(ImGuiKey_GamepadFaceDown, GLFW_GAMEPAD_BUTTON_A, 0); // Xbox A, PS Cross
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, GLFW_GAMEPAD_BUTTON_DPAD_LEFT, 13);
MAP_BUTTON(ImGuiKey_GamepadDpadRight, GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, 11);
MAP_BUTTON(ImGuiKey_GamepadDpadUp, GLFW_GAMEPAD_BUTTON_DPAD_UP, 10);
MAP_BUTTON(ImGuiKey_GamepadDpadDown, GLFW_GAMEPAD_BUTTON_DPAD_DOWN, 12);
MAP_BUTTON(ImGuiKey_GamepadL1, GLFW_GAMEPAD_BUTTON_LEFT_BUMPER, 4);
MAP_BUTTON(ImGuiKey_GamepadR1, GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER, 5);
MAP_ANALOG(ImGuiKey_GamepadL2, GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, 4, -0.75f, +1.0f);
MAP_ANALOG(ImGuiKey_GamepadR2, GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, 5, -0.75f, +1.0f);
MAP_BUTTON(ImGuiKey_GamepadL3, GLFW_GAMEPAD_BUTTON_LEFT_THUMB, 8);
MAP_BUTTON(ImGuiKey_GamepadR3, GLFW_GAMEPAD_BUTTON_RIGHT_THUMB, 9);
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, GLFW_GAMEPAD_AXIS_LEFT_X, 0, -0.25f, -1.0f);
MAP_ANALOG(ImGuiKey_GamepadLStickRight, GLFW_GAMEPAD_AXIS_LEFT_X, 0, +0.25f, +1.0f);
MAP_ANALOG(ImGuiKey_GamepadLStickUp, GLFW_GAMEPAD_AXIS_LEFT_Y, 1, -0.25f, -1.0f);
MAP_ANALOG(ImGuiKey_GamepadLStickDown, GLFW_GAMEPAD_AXIS_LEFT_Y, 1, +0.25f, +1.0f);
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, GLFW_GAMEPAD_AXIS_RIGHT_X, 2, -0.25f, -1.0f);
MAP_ANALOG(ImGuiKey_GamepadRStickRight, GLFW_GAMEPAD_AXIS_RIGHT_X, 2, +0.25f, +1.0f);
MAP_ANALOG(ImGuiKey_GamepadRStickUp, GLFW_GAMEPAD_AXIS_RIGHT_Y, 3, -0.25f, -1.0f);
MAP_ANALOG(ImGuiKey_GamepadRStickDown, GLFW_GAMEPAD_AXIS_RIGHT_Y, 3, +0.25f, +1.0f);
#undef MAP_BUTTON
#undef MAP_ANALOG
}
void ImGui_ImplGlfw_NewFrame()
{
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplGlfw_InitForXXX()?");
// Setup display size (every frame to accommodate for window resizing)
int w, h;
int display_w, display_h;
glfwGetWindowSize(bd->Window, &w, &h);
glfwGetFramebufferSize(bd->Window, &display_w, &display_h);
io.DisplaySize = ImVec2((float)w, (float)h);
if (w > 0 && h > 0)
io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
// Setup time step
double current_time = glfwGetTime();
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
bd->Time = current_time;
ImGui_ImplGlfw_UpdateMouseData();
ImGui_ImplGlfw_UpdateMouseCursor();
// Update game controllers (if enabled and available)
ImGui_ImplGlfw_UpdateGamepads();
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@@ -0,0 +1,46 @@
// dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
// Implemented features:
// [X] Platform: Clipboard support.
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs
// About GLSL version:
// The 'glsl_version' initialization parameter defaults to "#version 150" if NULL.
// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure!
#pragma once
#include "imgui.h" // IMGUI_IMPL_API
struct GLFWwindow;
struct GLFWmonitor;
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
// GLFW callbacks (installer)
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
IMGUI_IMPL_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
// GLFW callbacks (individual callbacks to call if you didn't install callbacks)
IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); // Since 1.84
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); // Since 1.84
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y); // Since 1.87
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
// dear imgui: Renderer Backend for Vulkan
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
// Implemented features:
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
// See imgui_impl_vulkan.cpp file for details.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
// You will use those if you want to use this rendering backend in your engine/app.
// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
// Read comments in imgui_impl_vulkan.h.
#pragma once
#include "imgui.h" // IMGUI_IMPL_API
// [Configuration] in order to use a custom Vulkan function loader:
// (1) You'll need to disable default Vulkan function prototypes.
// We provide a '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' convenience configuration flag.
// In order to make sure this is visible from the imgui_impl_vulkan.cpp compilation unit:
// - Add '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' in your imconfig.h file
// - Or as a compilation flag in your build system
// - Or uncomment here (not recommended because you'd be modifying imgui sources!)
// - Do not simply add it in a .cpp file!
// (2) Call ImGui_ImplVulkan_LoadFunctions() before ImGui_ImplVulkan_Init() with your custom function.
// If you have no idea what this is, leave it alone!
//#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES
// Vulkan includes
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
#define VK_NO_PROTOTYPES
#endif
#include <vulkan/vulkan.h>
// Initialization data, for ImGui_ImplVulkan_Init()
// [Please zero-clear before use!]
struct ImGui_ImplVulkan_InitInfo
{
VkInstance Instance;
VkPhysicalDevice PhysicalDevice;
VkDevice Device;
uint32_t QueueFamily;
VkQueue Queue;
VkPipelineCache PipelineCache;
VkDescriptorPool DescriptorPool;
uint32_t Subpass;
uint32_t MinImageCount; // >= 2
uint32_t ImageCount; // >= MinImageCount
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT (0 -> default to VK_SAMPLE_COUNT_1_BIT)
const VkAllocationCallbacks* Allocator;
void (*CheckVkResultFn)(VkResult err);
};
// Called by user code
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
// Register a texture (VkDescriptorSet == ImTextureID)
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem, please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
IMGUI_IMPL_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout);
// Optional: load Vulkan functions with a custom function loader
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = NULL);
//-------------------------------------------------------------------------
// Internal / Miscellaneous Vulkan Helpers
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.)
//-------------------------------------------------------------------------
// You probably do NOT need to use or care about those functions.
// Those functions only exist because:
// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
// 2) the upcoming multi-viewport feature will need them internally.
// Generally we avoid exposing any kind of superfluous high-level helpers in the backends,
// but it is too much code to duplicate everywhere so we exceptionally expose them.
//
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
//-------------------------------------------------------------------------
struct ImGui_ImplVulkanH_Frame;
struct ImGui_ImplVulkanH_Window;
// Helpers
IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
// Helper structure to hold the data needed by one rendering frame
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
// [Please zero-clear before use!]
struct ImGui_ImplVulkanH_Frame
{
VkCommandPool CommandPool;
VkCommandBuffer CommandBuffer;
VkFence Fence;
VkImage Backbuffer;
VkImageView BackbufferView;
VkFramebuffer Framebuffer;
};
struct ImGui_ImplVulkanH_FrameSemaphores
{
VkSemaphore ImageAcquiredSemaphore;
VkSemaphore RenderCompleteSemaphore;
};
// Helper structure to hold the data needed by one rendering context into one OS window
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
struct ImGui_ImplVulkanH_Window
{
int Width;
int Height;
VkSwapchainKHR Swapchain;
VkSurfaceKHR Surface;
VkSurfaceFormatKHR SurfaceFormat;
VkPresentModeKHR PresentMode;
VkRenderPass RenderPass;
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
bool ClearEnable;
VkClearValue ClearValue;
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
ImGui_ImplVulkanH_Frame* Frames;
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
ImGui_ImplVulkanH_Window()
{
memset((void*)this, 0, sizeof(*this));
PresentMode = (VkPresentModeKHR)~0; // Ensure we get an error if user doesn't set this.
ClearEnable = true;
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,206 @@
#include "imgui_internal.h"
using namespace ImGui;
void ImGui_RenderMultiline(ImVector<char> &d, const char *buffer, float maxWidth_)
{
int size = 1;
{
auto *c = buffer;
while (*c++ != 0)
++size;
}
d.resize(size*2);
ImGuiContext& g = *GImGui;
ImFont* font = g.Font;
auto *out = d.Data;
auto *in = buffer;
auto *space = out, *newline = out;
char NEW_LINE = '\n';
int bufferSize = 3;
float maxWidth = maxWidth_ - bufferSize;
float width = 0, widthSinceSpace = 0;
while (*in != 0)
{
auto c = *in++;
auto w =
((int)c < font->IndexAdvanceX.Size ?
font->IndexAdvanceX.Data[c] :
font->FallbackAdvanceX);
width += w;
widthSinceSpace += w;
if (c == ' ')
{
space = out;
widthSinceSpace = 0;
}
else
if (c == '\n')
{
space = newline = out;
width = widthSinceSpace = 0;
}
if (width > maxWidth)
{
if (space != newline)
{
*space = NEW_LINE;
width = widthSinceSpace + w;
widthSinceSpace = w;
newline = space;
if (space == out)
{
out++;
continue;
}
}
else
{
*out++ = NEW_LINE;
width = w;
widthSinceSpace = 0;
newline = out;
space = out;
}
}
*out++ = c;
}
*out++ = 0;
}
// Based on stb_to_utf8() from github.com/nothings/stb/
inline int ImGui_W2C(char* buf, int buf_size, unsigned int c)
{
if (c < 0x80)
{
buf[0] = (char)c;
return 1;
}
if (c < 0x800)
{
if (buf_size < 2) return 0;
buf[0] = (char)(0xc0 + (c >> 6));
buf[1] = (char)(0x80 + (c & 0x3f));
return 2;
}
if (c < 0x10000)
{
if (buf_size < 3) return 0;
buf[0] = (char)(0xe0 + (c >> 12));
buf[1] = (char)(0x80 + ((c >> 6) & 0x3f));
buf[2] = (char)(0x80 + ((c ) & 0x3f));
return 3;
}
if (c <= 0x10FFFF)
{
if (buf_size < 4) return 0;
buf[0] = (char)(0xf0 + (c >> 18));
buf[1] = (char)(0x80 + ((c >> 12) & 0x3f));
buf[2] = (char)(0x80 + ((c >> 6) & 0x3f));
buf[3] = (char)(0x80 + ((c ) & 0x3f));
return 4;
}
// Invalid code point, the max unicode is 0x10FFFF
return 0;
}
void ImGui_RenderMultiline(ImVector<char> &d, ImVector<ImWchar> &r, int &rSize, ImVector<ImWchar> &w, float maxWidth_)
{
ImGuiContext& g = *GImGui;
ImFont* font = g.Font;
r.resize(w.size()*2);
d.resize(r.size()*4);
rSize = 0;
auto *outC = d.Data;
auto *outW = r.Data;
auto *in = w.Data;
auto *spaceC = outC, *newlineC = outC;
auto *spaceW = outW, *newlineW = outW;
char NEW_LINE = '\n';
int bufferSize = 3;
float maxWidth = maxWidth_ - bufferSize;
float width = 0, widthSinceSpace = 0;
while (*in != 0)
{
auto c = *in++;
auto w =
((int)c < font->IndexAdvanceX.Size ?
font->IndexAdvanceX.Data[c] :
font->FallbackAdvanceX);
width += w;
widthSinceSpace += w;
if (c == ' ')
{
spaceC = outC; spaceW = outW;
widthSinceSpace = 0;
}
else
if (c == '\n')
{
spaceC = newlineC = outC;
spaceW = newlineW = outW;
width = widthSinceSpace = 0;
}
if (width > maxWidth)
{
if (spaceC != newlineC)
{
*spaceC = NEW_LINE; *spaceW = NEW_LINE;
width = widthSinceSpace + w;
widthSinceSpace = w;
newlineC = spaceC; newlineW = spaceW;
if (spaceC == outC)
{
outC++; outW++;
rSize++;
continue;
}
}
else
{
*outC++ = NEW_LINE; *outW++ = NEW_LINE;
rSize++;
width = w;
widthSinceSpace = 0;
newlineC = outC; newlineW = outW;
spaceC = outC; spaceW = outW;
}
}
*outW++ = c;
rSize++;
outC += ImGui_W2C(outC, 10, c);
}
*outC++ = 0; *outW++ = 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,627 @@
// [DEAR IMGUI]
// This is a slightly modified version of stb_rect_pack.h 1.01.
// Grep for [DEAR IMGUI] to find the changes.
//
// stb_rect_pack.h - v1.01 - public domain - rectangle packing
// Sean Barrett 2014
//
// Useful for e.g. packing rectangular textures into an atlas.
// Does not do rotation.
//
// Before #including,
//
// #define STB_RECT_PACK_IMPLEMENTATION
//
// in the file that you want to have the implementation.
//
// Not necessarily the awesomest packing method, but better than
// the totally naive one in stb_truetype (which is primarily what
// this is meant to replace).
//
// Has only had a few tests run, may have issues.
//
// More docs to come.
//
// No memory allocations; uses qsort() and assert() from stdlib.
// Can override those by defining STBRP_SORT and STBRP_ASSERT.
//
// This library currently uses the Skyline Bottom-Left algorithm.
//
// Please note: better rectangle packers are welcome! Please
// implement them to the same API, but with a different init
// function.
//
// Credits
//
// Library
// Sean Barrett
// Minor features
// Martins Mozeiko
// github:IntellectualKitty
//
// Bugfixes / warning fixes
// Jeremy Jaussaud
// Fabian Giesen
//
// Version history:
//
// 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
// 0.99 (2019-02-07) warning fixes
// 0.11 (2017-03-03) return packing success/fail result
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
// 0.09 (2016-08-27) fix compiler warnings
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
// 0.05: added STBRP_ASSERT to allow replacing assert
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
// 0.01: initial release
//
// LICENSE
//
// See end of file for license information.
//////////////////////////////////////////////////////////////////////////////
//
// INCLUDE SECTION
//
#ifndef STB_INCLUDE_STB_RECT_PACK_H
#define STB_INCLUDE_STB_RECT_PACK_H
#define STB_RECT_PACK_VERSION 1
#ifdef STBRP_STATIC
#define STBRP_DEF static
#else
#define STBRP_DEF extern
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct stbrp_context stbrp_context;
typedef struct stbrp_node stbrp_node;
typedef struct stbrp_rect stbrp_rect;
typedef int stbrp_coord;
#define STBRP__MAXVAL 0x7fffffff
// Mostly for internal use, but this is the maximum supported coordinate value.
STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
// Assign packed locations to rectangles. The rectangles are of type
// 'stbrp_rect' defined below, stored in the array 'rects', and there
// are 'num_rects' many of them.
//
// Rectangles which are successfully packed have the 'was_packed' flag
// set to a non-zero value and 'x' and 'y' store the minimum location
// on each axis (i.e. bottom-left in cartesian coordinates, top-left
// if you imagine y increasing downwards). Rectangles which do not fit
// have the 'was_packed' flag set to 0.
//
// You should not try to access the 'rects' array from another thread
// while this function is running, as the function temporarily reorders
// the array while it executes.
//
// To pack into another rectangle, you need to call stbrp_init_target
// again. To continue packing into the same rectangle, you can call
// this function again. Calling this multiple times with multiple rect
// arrays will probably produce worse packing results than calling it
// a single time with the full rectangle array, but the option is
// available.
//
// The function returns 1 if all of the rectangles were successfully
// packed and 0 otherwise.
struct stbrp_rect
{
// reserved for your use:
int id;
// input:
stbrp_coord w, h;
// output:
stbrp_coord x, y;
int was_packed; // non-zero if valid packing
}; // 16 bytes, nominally
STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
// Initialize a rectangle packer to:
// pack a rectangle that is 'width' by 'height' in dimensions
// using temporary storage provided by the array 'nodes', which is 'num_nodes' long
//
// You must call this function every time you start packing into a new target.
//
// There is no "shutdown" function. The 'nodes' memory must stay valid for
// the following stbrp_pack_rects() call (or calls), but can be freed after
// the call (or calls) finish.
//
// Note: to guarantee best results, either:
// 1. make sure 'num_nodes' >= 'width'
// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
//
// If you don't do either of the above things, widths will be quantized to multiples
// of small integers to guarantee the algorithm doesn't run out of temporary storage.
//
// If you do #2, then the non-quantized algorithm will be used, but the algorithm
// may run out of temporary storage and be unable to pack some rectangles.
STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
// Optionally call this function after init but before doing any packing to
// change the handling of the out-of-temp-memory scenario, described above.
// If you call init again, this will be reset to the default (false).
STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
// Optionally select which packing heuristic the library should use. Different
// heuristics will produce better/worse results for different data sets.
// If you call init again, this will be reset to the default.
enum
{
STBRP_HEURISTIC_Skyline_default=0,
STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
STBRP_HEURISTIC_Skyline_BF_sortHeight
};
//////////////////////////////////////////////////////////////////////////////
//
// the details of the following structures don't matter to you, but they must
// be visible so you can handle the memory allocations for them
struct stbrp_node
{
stbrp_coord x,y;
stbrp_node *next;
};
struct stbrp_context
{
int width;
int height;
int align;
int init_mode;
int heuristic;
int num_nodes;
stbrp_node *active_head;
stbrp_node *free_head;
stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
};
#ifdef __cplusplus
}
#endif
#endif
//////////////////////////////////////////////////////////////////////////////
//
// IMPLEMENTATION SECTION
//
#ifdef STB_RECT_PACK_IMPLEMENTATION
#ifndef STBRP_SORT
#include <stdlib.h>
#define STBRP_SORT qsort
#endif
#ifndef STBRP_ASSERT
#include <assert.h>
#define STBRP_ASSERT assert
#endif
#ifdef _MSC_VER
#define STBRP__NOTUSED(v) (void)(v)
#define STBRP__CDECL __cdecl
#else
#define STBRP__NOTUSED(v) (void)sizeof(v)
#define STBRP__CDECL
#endif
enum
{
STBRP__INIT_skyline = 1
};
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
{
switch (context->init_mode) {
case STBRP__INIT_skyline:
STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
context->heuristic = heuristic;
break;
default:
STBRP_ASSERT(0);
}
}
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
{
if (allow_out_of_mem)
// if it's ok to run out of memory, then don't bother aligning them;
// this gives better packing, but may fail due to OOM (even though
// the rectangles easily fit). @TODO a smarter approach would be to only
// quantize once we've hit OOM, then we could get rid of this parameter.
context->align = 1;
else {
// if it's not ok to run out of memory, then quantize the widths
// so that num_nodes is always enough nodes.
//
// I.e. num_nodes * align >= width
// align >= width / num_nodes
// align = ceil(width/num_nodes)
context->align = (context->width + context->num_nodes-1) / context->num_nodes;
}
}
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
{
int i;
for (i=0; i < num_nodes-1; ++i)
nodes[i].next = &nodes[i+1];
nodes[i].next = NULL;
context->init_mode = STBRP__INIT_skyline;
context->heuristic = STBRP_HEURISTIC_Skyline_default;
context->free_head = &nodes[0];
context->active_head = &context->extra[0];
context->width = width;
context->height = height;
context->num_nodes = num_nodes;
stbrp_setup_allow_out_of_mem(context, 0);
// node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
context->extra[0].x = 0;
context->extra[0].y = 0;
context->extra[0].next = &context->extra[1];
context->extra[1].x = (stbrp_coord) width;
context->extra[1].y = (1<<30);
context->extra[1].next = NULL;
}
// find minimum y position if it starts at x1
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
{
stbrp_node *node = first;
int x1 = x0 + width;
int min_y, visited_width, waste_area;
STBRP__NOTUSED(c);
STBRP_ASSERT(first->x <= x0);
#if 0
// skip in case we're past the node
while (node->next->x <= x0)
++node;
#else
STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
#endif
STBRP_ASSERT(node->x <= x0);
min_y = 0;
waste_area = 0;
visited_width = 0;
while (node->x < x1) {
if (node->y > min_y) {
// raise min_y higher.
// we've accounted for all waste up to min_y,
// but we'll now add more waste for everything we've visted
waste_area += visited_width * (node->y - min_y);
min_y = node->y;
// the first time through, visited_width might be reduced
if (node->x < x0)
visited_width += node->next->x - x0;
else
visited_width += node->next->x - node->x;
} else {
// add waste area
int under_width = node->next->x - node->x;
if (under_width + visited_width > width)
under_width = width - visited_width;
waste_area += under_width * (min_y - node->y);
visited_width += under_width;
}
node = node->next;
}
*pwaste = waste_area;
return min_y;
}
typedef struct
{
int x,y;
stbrp_node **prev_link;
} stbrp__findresult;
static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
{
int best_waste = (1<<30), best_x, best_y = (1 << 30);
stbrp__findresult fr;
stbrp_node **prev, *node, *tail, **best = NULL;
// align to multiple of c->align
width = (width + c->align - 1);
width -= width % c->align;
STBRP_ASSERT(width % c->align == 0);
// if it can't possibly fit, bail immediately
if (width > c->width || height > c->height) {
fr.prev_link = NULL;
fr.x = fr.y = 0;
return fr;
}
node = c->active_head;
prev = &c->active_head;
while (node->x + width <= c->width) {
int y,waste;
y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
// bottom left
if (y < best_y) {
best_y = y;
best = prev;
}
} else {
// best-fit
if (y + height <= c->height) {
// can only use it if it first vertically
if (y < best_y || (y == best_y && waste < best_waste)) {
best_y = y;
best_waste = waste;
best = prev;
}
}
}
prev = &node->next;
node = node->next;
}
best_x = (best == NULL) ? 0 : (*best)->x;
// if doing best-fit (BF), we also have to try aligning right edge to each node position
//
// e.g, if fitting
//
// ____________________
// |____________________|
//
// into
//
// | |
// | ____________|
// |____________|
//
// then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
//
// This makes BF take about 2x the time
if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
tail = c->active_head;
node = c->active_head;
prev = &c->active_head;
// find first node that's admissible
while (tail->x < width)
tail = tail->next;
while (tail) {
int xpos = tail->x - width;
int y,waste;
STBRP_ASSERT(xpos >= 0);
// find the left position that matches this
while (node->next->x <= xpos) {
prev = &node->next;
node = node->next;
}
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
if (y + height <= c->height) {
if (y <= best_y) {
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
best_x = xpos;
//STBRP_ASSERT(y <= best_y); [DEAR IMGUI]
best_y = y;
best_waste = waste;
best = prev;
}
}
}
tail = tail->next;
}
}
fr.prev_link = best;
fr.x = best_x;
fr.y = best_y;
return fr;
}
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
{
// find best position according to heuristic
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
stbrp_node *node, *cur;
// bail if:
// 1. it failed
// 2. the best node doesn't fit (we don't always check this)
// 3. we're out of memory
if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
res.prev_link = NULL;
return res;
}
// on success, create new node
node = context->free_head;
node->x = (stbrp_coord) res.x;
node->y = (stbrp_coord) (res.y + height);
context->free_head = node->next;
// insert the new node into the right starting point, and
// let 'cur' point to the remaining nodes needing to be
// stiched back in
cur = *res.prev_link;
if (cur->x < res.x) {
// preserve the existing one, so start testing with the next one
stbrp_node *next = cur->next;
cur->next = node;
cur = next;
} else {
*res.prev_link = node;
}
// from here, traverse cur and free the nodes, until we get to one
// that shouldn't be freed
while (cur->next && cur->next->x <= res.x + width) {
stbrp_node *next = cur->next;
// move the current node to the free list
cur->next = context->free_head;
context->free_head = cur;
cur = next;
}
// stitch the list back in
node->next = cur;
if (cur->x < res.x + width)
cur->x = (stbrp_coord) (res.x + width);
#ifdef _DEBUG
cur = context->active_head;
while (cur->x < context->width) {
STBRP_ASSERT(cur->x < cur->next->x);
cur = cur->next;
}
STBRP_ASSERT(cur->next == NULL);
{
int count=0;
cur = context->active_head;
while (cur) {
cur = cur->next;
++count;
}
cur = context->free_head;
while (cur) {
cur = cur->next;
++count;
}
STBRP_ASSERT(count == context->num_nodes+2);
}
#endif
return res;
}
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
const stbrp_rect *q = (const stbrp_rect *) b;
if (p->h > q->h)
return -1;
if (p->h < q->h)
return 1;
return (p->w > q->w) ? -1 : (p->w < q->w);
}
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
const stbrp_rect *q = (const stbrp_rect *) b;
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
}
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
{
int i, all_rects_packed = 1;
// we use the 'was_packed' field internally to allow sorting/unsorting
for (i=0; i < num_rects; ++i) {
rects[i].was_packed = i;
}
// sort according to heuristic
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
for (i=0; i < num_rects; ++i) {
if (rects[i].w == 0 || rects[i].h == 0) {
rects[i].x = rects[i].y = 0; // empty rect needs no space
} else {
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
if (fr.prev_link) {
rects[i].x = (stbrp_coord) fr.x;
rects[i].y = (stbrp_coord) fr.y;
} else {
rects[i].x = rects[i].y = STBRP__MAXVAL;
}
}
}
// unsort
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
// set was_packed flags and all_rects_packed status
for (i=0; i < num_rects; ++i) {
rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
if (!rects[i].was_packed)
all_rects_packed = 0;
}
// return the all_rects_packed status
return all_rects_packed;
}
#endif
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
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.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
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 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.
------------------------------------------------------------------------------
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include "imgui.h"
#include <imgui/imgui_impl_opengl3.h>
namespace tjp::core::graphics {}

View File

@@ -0,0 +1,14 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include "imgui.h"
#include <imgui/imgui_impl_glfw.h>
namespace tjp::core::graphics {}

View File

@@ -0,0 +1,14 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include "imgui.h"
#include <imgui/imgui_impl_vulkan.h>
namespace tjp::core::graphics {}

14
tjp/core/graphics/imgui.h Normal file
View File

@@ -0,0 +1,14 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include <imgui/imgui.h>
#include <imgui/imgui_internal.h>
namespace tjp::core::graphics {}

View File

@@ -0,0 +1,132 @@
typedef struct FontHeader {
int32_t fVersion;
uint16_t fNumTables;
uint16_t fSearchRange;
uint16_t fEntrySelector;
uint16_t fRangeShift;
}FontHeader;
typedef struct TableEntry {
uint32_t fTag;
uint32_t fCheckSum;
uint32_t fOffset;
uint32_t fLength;
}TableEntry;
static uint32_t CalcTableCheckSum(const uint32_t *table, uint32_t numberOfBytesInTable) {
uint32_t sum = 0;
uint32_t nLongs = (numberOfBytesInTable + 3) / 4;
while (nLongs-- > 0) {
sum += CFSwapInt32HostToBig(*table++);
}
return sum;
}
static uint32_t CalcTableDataRefCheckSum(CFDataRef dataRef) {
const uint32_t *dataBuff = (const uint32_t *)CFDataGetBytePtr(dataRef);
uint32_t dataLength = (uint32_t)CFDataGetLength(dataRef);
return CalcTableCheckSum(dataBuff, dataLength);
}
//Reference:
//http://skia.googlecode.com/svn-history/r1473/trunk/src/ports/SkFontHost_mac_coretext.cpp
- (NSData *)fontDataForCGFont:(CGFontRef)cgFont{
if (!cgFont) {
return nil;
}
CFRetain(cgFont);
CFArrayRef tags = CGFontCopyTableTags(cgFont);
int tableCount = CFArrayGetCount(tags);
size_t *tableSizes = malloc(sizeof(size_t) * tableCount);
memset(tableSizes, 0, sizeof(size_t) * tableCount);
BOOL containsCFFTable = NO;
size_t totalSize = sizeof(FontHeader) + sizeof(TableEntry) * tableCount;
for (int index = 0; index < tableCount; ++index) {
//get size
size_t tableSize = 0;
uint32_t aTag = (uint32_t)CFArrayGetValueAtIndex(tags, index);
if (aTag == 'CFF ' && !containsCFFTable) {
containsCFFTable = YES;
}
CFDataRef tableDataRef = CGFontCopyTableForTag(cgFont, aTag);
if (tableDataRef != NULL) {
tableSize = CFDataGetLength(tableDataRef);
CFRelease(tableDataRef);
}
totalSize += (tableSize + 3) & ~3;
tableSizes[index] = tableSize;
}
unsigned char *stream = malloc(totalSize);
memset(stream, 0, totalSize);
char* dataStart = (char*)stream;
char* dataPtr = dataStart;
// compute font header entries
uint16_t entrySelector = 0;
uint16_t searchRange = 1;
while (searchRange < tableCount >> 1) {
entrySelector++;
searchRange <<= 1;
}
searchRange <<= 4;
uint16_t rangeShift = (tableCount << 4) - searchRange;
// write font header (also called sfnt header, offset subtable)
FontHeader* offsetTable = (FontHeader*)dataPtr;
//OpenType Font contains CFF Table use 'OTTO' as version, and with .otf extension
//otherwise 0001 0000
offsetTable->fVersion = containsCFFTable ? 'OTTO' : CFSwapInt16HostToBig(1);
offsetTable->fNumTables = CFSwapInt16HostToBig((uint16_t)tableCount);
offsetTable->fSearchRange = CFSwapInt16HostToBig((uint16_t)searchRange);
offsetTable->fEntrySelector = CFSwapInt16HostToBig((uint16_t)entrySelector);
offsetTable->fRangeShift = CFSwapInt16HostToBig((uint16_t)rangeShift);
dataPtr += sizeof(FontHeader);
// write tables
TableEntry* entry = (TableEntry*)dataPtr;
dataPtr += sizeof(TableEntry) * tableCount;
for (int index = 0; index < tableCount; ++index) {
uint32_t aTag = (uint32_t)CFArrayGetValueAtIndex(tags, index);
CFDataRef tableDataRef = CGFontCopyTableForTag(cgFont, aTag);
size_t tableSize = CFDataGetLength(tableDataRef);
memcpy(dataPtr, CFDataGetBytePtr(tableDataRef), tableSize);
entry->fTag = CFSwapInt32HostToBig((uint32_t)aTag);
entry->fCheckSum = CFSwapInt32HostToBig(CalcTableCheckSum((uint32_t *)dataPtr, tableSize));
uint32_t offset = dataPtr - dataStart;
entry->fOffset = CFSwapInt32HostToBig((uint32_t)offset);
entry->fLength = CFSwapInt32HostToBig((uint32_t)tableSize);
dataPtr += (tableSize + 3) & ~3;
++entry;
CFRelease(tableDataRef);
}
CFRelease(cgFont);
free(tableSizes);
NSData *fontData = [NSData dataWithBytesNoCopy:stream
length:totalSize
freeWhenDone:YES];
return fontData;
}

View File

@@ -0,0 +1,262 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#include "opengl.h"
#include <tjp/core/log/Log.h>
#include <tjp/core/log/LogOf.h>
#include <tjp/core/assert/debug_assert.h>
#include <tjp/core/system/System.h>
#include <tjp/core/exception/Exception.hpp>
#include <tjp/core/file/File.h>
namespace tjp::core::graphics {
void RendererOpenGL::clear(const math::Vector4f &clearColor)
{
glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
auto error = glGetError();
if (error != GL_NO_ERROR)
{
throw Exception { "Failed to clear" };
}
}
void RendererOpenGL::destroyWindow()
{
}
void RendererOpenGL::prepare(const RenderStateOpenGL &state_) {
if (state.depthTest != state_.depthTest) {
state.depthTest = state_.depthTest;
if (state.depthTest) {
glValidate(glEnable, GL_DEPTH_TEST);
} else {
glValidate(glDisable, GL_DEPTH_TEST);
}
}
if (state.depthFunc != state_.depthFunc) {
state.depthFunc = state_.depthFunc;
glValidate(glDepthFunc, state.depthFunc);
}
if (state.depthWrite != state_.depthWrite) {
state.depthWrite = state_.depthWrite;
glValidate(glDepthMask, state.depthWrite);
}
if (state.cullFace != state_.cullFace) {
state.cullFace = state_.cullFace;
if (state.cullFace) {
glValidate(glEnable, GL_CULL_FACE);
} else {
glValidate(glDisable, GL_CULL_FACE);
}
}
}
void RendererOpenGL::initState()
{
if (state.depthTest) {
glValidate(glEnable, GL_DEPTH_TEST);
} else {
glValidate(glDisable, GL_DEPTH_TEST);
}
glValidate(glDepthFunc, state.depthFunc);
glValidate(glDepthMask, state.depthWrite);
if (state.cullFace) {
glValidate(glEnable, GL_CULL_FACE);
} else {
glValidate(glDisable, GL_CULL_FACE);
}
glValidate(glCullFace, GL_BACK);
glValidate(glEnable, GL_BLEND);
glValidate(glBlendFunc, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#if defined(USING_OPENGL)
glValidate(glEnable, GL_PROGRAM_POINT_SIZE);
// glValidate(glProvokingVertex, GL_FIRST_VERTEX_CONVENTION);
#endif
}
GLuint RendererOpenGL::createShader(const String &vertexShaderPath, const String &fragmentShaderPath)
{
auto vertexShaderSource = file::readFile(vertexShaderPath);
auto fragmentShaderSource = file::readFile(fragmentShaderPath);
const char *shaderSource[1];
String shaderSource_;
shaderSource_ = String(vertexShaderSource.begin(), vertexShaderSource.end());
shaderSource[0] = shaderSource_.c_str();
// sLogRelease("errors", logVar(shaderSource_) << shaderSource_);
// Create vertex shader object and compile it
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, shaderSource, nullptr);
glCompileShader(vertexShader);
// Check for compilation errors
int success;
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success) {
char infoLog[512];
GLsizei length;
glGetShaderInfoLog(vertexShader, 512, &length, infoLog);
String infoLog_(infoLog, infoLog + length);
sLogError("errors", logVar(vertexShaderPath) << infoLog_);
debug_assert(false);
throw Exception { String("Vertex shader compilation failed: ") + infoLog_ };
}
// Create fragment shader object and compile it
shaderSource_ = String(fragmentShaderSource.begin(), fragmentShaderSource.end());
shaderSource[0] = shaderSource_.c_str();
// sLogRelease("errors", logVar(shaderSource_) << shaderSource_);
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, shaderSource, nullptr);
glCompileShader(fragmentShader);
// Check for compilation errors
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success) {
char infoLog[512];
GLsizei length;
glGetShaderInfoLog(fragmentShader, 512, &length, infoLog);
String infoLog_(infoLog, infoLog + length);
sLogRelease("errors", logVar(fragmentShaderPath) << infoLog_);
debug_assert(false);
throw Exception { String("Fragment shader compilation failed: ") + infoLog_ };
}
// Create shader program, attach shaders, and link program
GLuint shaderProgram = glCreateProgram();
glAttachShader(shaderProgram, vertexShader);
glAttachShader(shaderProgram, fragmentShader);
glLinkProgram(shaderProgram);
// Check for linking errors
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
if (!success)
{
char infoLog[512];
GLsizei length;
glGetProgramInfoLog(shaderProgram, 512, &length, infoLog);
String infoLog_(infoLog, infoLog + length);
sLogError("errors", logVar(vertexShaderPath) << logVar(fragmentShaderPath) << infoLog_);
debug_assert(false);
throw Exception { String("Shader linking failed: ") + infoLog_ };
}
// Delete the shader objects once they are linked into the program
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
return shaderProgram;
}
namespace opengl {
const char* getGLErrorString(GLenum error)
{
switch (error)
{
case GL_NO_ERROR:
return "No error";
case GL_INVALID_ENUM:
return "Invalid enum";
case GL_INVALID_VALUE:
return "Invalid value";
case GL_INVALID_OPERATION:
return "Invalid operation";
// case GL_STACK_OVERFLOW:
// return "Stack overflow";
// case GL_STACK_UNDERFLOW:
// return "Stack underflow";
case GL_OUT_OF_MEMORY:
return "Out of memory";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "Invalid framebuffer operation";
default:
return "Unknown error";
}
}
void checkError(const char *message)
{
auto error = glGetError();
if (error != GL_NO_ERROR)
{
auto errorString = String(message) + ": " + (const char *)gluErrorString(error);
debug_assert(false);
throw Exception { errorString };
}
}
void enableDebugging() {
// glEnable(GL_DEBUG_OUTPUT);
// glDebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) {
// sLogRelease("errors", "OpenGL Error: " << message);
// }, nullptr);
}
Texture::~Texture()
{
if (v) {
sLogDebug("opengl", logVar(v));
glValidate(glDeleteTextures, 1, &v);
}
}
VAO::~VAO()
{
if (v) {
sLogDebug("opengl", logVar(v));
glValidate(glDeleteVertexArrays, 1, &v);
}
}
Buffer::~Buffer()
{
if (v) {
sLogDebug("opengl", logVar(v) << logVar(size) << logVar(target) << logVar(capacity));
glValidate(glDeleteBuffers, 1, &v);
}
}
Program::~Program()
{
if (v) {
sLogDebug("opengl", logVar(v));
glValidate(glDeleteProgram, v);
}
}
} // namespace
} // namespace

446
tjp/core/graphics/opengl.h Normal file
View File

@@ -0,0 +1,446 @@
//
// vuku.h
// Core
//
// Created by Timothy Prepscius on 9/8/20.
// Copyright © 2020 Timothy Prepscius. All rights reserved.
//
#pragma once
#include "Renderer.hpp"
#include "Memory.hpp"
#include <tjp/core/types/Types.h>
#include <tjp/core/math/Vector2.hpp>
#include <tjp/core/math/Vector3.h>
#include <tjp/core/math/Vector4.hpp>
#include <tjp/core/system/System.h>
#include <tjp/core/containers/Vector.h>
#include <tjp/core/assert/debug_assert.h>
#include <tjp/core/containers/Tuple.h>
#include <tjp/core/string/String.hpp>
#if defined(SYS_IOS)
#define USING_OPENGL_ES
#define GL_SILENCE_DEPRECATION
#define GLES_SILENCE_DEPRECATION
#include <OpenGLES/ES3/gl.h>
#define gluErrorString getGLErrorString
#define GL_TEXTURE_1D GL_TEXTURE_2D
#define glTexImage1D glTexImage2D
#define GL_TEXTURE_1D_DIM(x) x, 1
#elif defined(SYS_ANDROID)
#define USING_OPENGL_ES
#define GL_SILENCE_DEPRECATION
#define GLES_SILENCE_DEPRECATION
#include <GLES3/gl3.h>
#define gluErrorString getGLErrorString
#define GL_TEXTURE_1D GL_TEXTURE_2D
#define glTexImage1D glTexImage2D
#define GL_TEXTURE_1D_DIM(x) x, 1
#else
#define USING_OPENGL
#define GL_SILENCE_DEPRECATION
#include <OpenGL/gl3.h>
#define gluErrorString getGLErrorString
// #include <OpenGL/glu.h>
#define GL_TEXTURE_1D_DIM(x) x
#endif
namespace tjp::core::graphics {
struct RenderStateOpenGL
{
GLboolean depthTest = true;
GLenum depthFunc = GL_LEQUAL;
GLboolean depthWrite = GL_TRUE;
GLboolean cullFace = GL_TRUE;
} ;
struct RendererOpenGL : Renderer
{
bool isOpenGLES = false;
RenderStateOpenGL state;
void *window = nullptr;
void prepare(const RenderStateOpenGL & = {});
void initState();
void clear(const math::Vector4f &clearColor);
void destroyWindow();
GLuint createShader(const String &vertexShaderSource, const String &fragmentShaderSource);
void *ext = nullptr;
} ;
// -----------
//
namespace opengl {
void enableDebugging();
void checkError(const char *message);
#define glCheckError(m) tjp::core::graphics::opengl::checkError(m)
#define glValidate(m, ...) m(__VA_ARGS__); glCheckError(#m);
//template<typename F>
//auto generator_(F &&f) { return f(); }
//#define glGenerate(m) core::graphics::opengl::generator_([]() { GLuint v; glValidate(m, 1, &v); return v; })
#define glGenerate(m) []() { GLuint v; glValidate(m, 1, &v); return v; }()
inline
GLuint glGenTexture() { GLuint v; glValidate(glGenTextures, 1, &v); return v; }
inline
GLuint glGenBuffer() { GLuint v; glValidate(glGenBuffers, 1, &v); return v; }
inline
GLuint glGenVertexArray() { GLuint v; glValidate(glGenVertexArrays, 1, &v); return v; }
using SizeAndType = Tuple<GLuint, GLuint>;
template<typename T>
auto shader_type_of() {
return 0;
}
template<>
inline
auto shader_type_of<float>() {
return GL_FLOAT;
}
template<>
inline
auto shader_type_of<uint16_t>() {
return GL_UNSIGNED_SHORT;
}
template<>
inline
auto shader_type_of<int16_t>() {
return GL_SHORT;
}
template<>
inline
auto shader_type_of<uint32_t>() {
return GL_UNSIGNED_INT;
}
template<>
inline
auto shader_type_of<int32_t>() {
return GL_INT;
}
template<typename T>
auto shader_size_type_of() {
// static_assert(false);
}
template<>
inline
auto shader_size_type_of<float>() {
return SizeAndType { 1, GL_FLOAT };
}
template<>
inline
auto shader_size_type_of<math::Vector2f_>() {
return SizeAndType { 2, GL_FLOAT };
}
template<>
inline
auto shader_size_type_of<math::Vector3f_>() {
return SizeAndType { 3, GL_FLOAT };
}
template<>
inline
auto shader_size_type_of<math::Vector4f>() {
return SizeAndType { 4, GL_FLOAT };
}
template<>
inline
auto shader_size_type_of<uint16_t>() {
return SizeAndType { 1, GL_UNSIGNED_SHORT };
}
template<>
inline
auto shader_size_type_of<int16_t>() {
return SizeAndType { 1, GL_SHORT };
}
template<>
inline
auto shader_size_type_of<uint32_t>() {
return SizeAndType { 1, GL_UNSIGNED_INT };
}
template<>
inline
auto shader_size_type_of<int32_t>() {
return SizeAndType { 1, GL_INT };
}
//template<>
//inline
//auto shader_size_type_of<int64_t>() {
// return SizeAndType { 1, GL_SIGNED_LONG };
//}
constexpr auto class_stride(size_t size, size_t align)
{
return (size + align - 1) / align * align;
}
#define SHADER_TYPE_OFFSET_OPENGL(clazz, field) \
tjp::core::graphics::opengl::shader_size_type_of<std::remove_reference<decltype(clazz::field)>::type>(), \
false, \
tjp::core::graphics::opengl::class_stride(sizeof(clazz), alignof(clazz)), \
offsetof(clazz, field)
inline
void addVertexAttribute(int &location, SizeAndType sizeType, bool normalized, GLuint stride, GLuint offset)
{
auto &[size, type] = sizeType;
glValidate(glVertexAttribPointer, location, size, type, normalized, stride, (void *)(size_t)offset);
glValidate(glEnableVertexAttribArray, location);
location++;
}
inline
void addVertexAttribute(GLuint shader, const char *name, SizeAndType sizeType, bool normalized, GLuint stride, GLuint offset)
{
auto location = glValidate(glGetAttribLocation, shader, name);
addVertexAttribute(location, sizeType, normalized, stride, offset);
}
struct Texture
{
using Self = Texture;
Texture(const Self &) = delete;
Texture(Self &&t) {
*this = std::move(t);
}
Texture(GLuint v_, GLenum target_) : v(v_), target(target_) {}
Texture() {};
~Texture();
GLuint v = 0;
GLenum target = 0;
operator GLuint &() { return v; }
GLuint &operator *() { return v; }
auto &operator =(GLuint v_) { return v = v_; }
Self &operator =(Self &&rhs) {
std::swap(v, rhs.v);
std::swap(target, rhs.target);
return *this;
}
void bind()
{
glValidate(glBindTexture, target, v);
}
void unbind()
{
glValidate(glBindTexture, target, 0);
}
} ;
struct VAO
{
using Self = VAO;
VAO(const Self &) = delete;
VAO(Self &&t) {
*this = std::move(t);
}
VAO(GLuint v_) : v(v_) {}
VAO() {};
~VAO();
GLuint v = 0;
operator GLuint &() { return v; }
GLuint &operator *() { return v; }
auto &operator =(GLuint v_) { return v = v_; }
Self &operator =(Self &&rhs) {
std::swap(v, rhs.v);
return *this;
}
void bind()
{
glValidate(glBindVertexArray, v);
}
void unbind()
{
glValidate(glBindVertexArray, 0);
}
} ;
struct Buffer
{
using Self = Buffer;
Buffer(const Self &) = delete;
Buffer(Self &&t) {
*this = std::move(t);
}
Buffer(GLuint v_, GLenum target_, GLenum type_=0) : v(v_), target(target_), type(type_) {}
Buffer() {}
~Buffer();
GLsizei capacity = 0;
GLsizei size = 0;
GLenum target = 0;
GLenum type = 0;
GLuint v = 0;
operator GLuint &() { return v; }
GLuint &operator *() { return v; }
auto &operator =(GLuint v_) { return v = v_; }
Self &operator =(Self &&t) {
std::swap(v, t.v);
std::swap(capacity, t.capacity);
std::swap(size, t.size);
std::swap(type, t.type);
std::swap(target, t.target);
return *this;
}
void bind()
{
glValidate(glBindBuffer, target, v);
}
void unbind()
{
glValidate(glBindBuffer, target, 0);
}
void bindBase(GLsizei offset)
{
glValidate(glBindBufferBase, target, 0, v);
}
template<typename V>
void update_nobind(GLenum mode, const V &data)
{
if (sizeof(data) > capacity)
{
glValidate(glBufferData, target, sizeof(data), &data, mode);
capacity = sizeof(data);
}
else
{
glValidate(glBufferSubData, target, 0, sizeof(data), &data);
}
size = sizeof(data);
}
template<typename V>
void update(GLenum mode, const V &data)
{
bind();
update_nobind(mode, data);
unbind();
}
template<typename V>
void update_nobind(GLenum mode, const Vector<V> &data)
{
debug_assert(type == 0 || type == shader_type_of<V>());
if (data.size() > capacity)
{
glValidate(glBufferData, target,data.size() * sizeof(data[0]), data.data(), mode);
capacity = (GLsizei)data.size();
}
else
{
glValidate(glBufferSubData, target, 0, data.size() * sizeof(data[0]), data.data());
}
size = (GLsizei)data.size();
}
template<typename V>
void update(GLenum mode, const Vector<V> &data)
{
bind();
update_nobind(mode, data);
unbind();
}
} ;
struct Program
{
using Self = Program;
Program(const Self &) = delete;
Program(Self &&t) {
*this = std::move(t);
}
Program(GLuint v_) : v(v_) {}
Program() {}
~Program();
GLuint v = 0;
operator GLuint &() { return v; }
GLuint &operator *() { return v; }
auto &operator =(GLuint v_) { return v = v_; }
Self &operator =(Self &&rhs) {
std::swap(v, rhs.v);
return *this;
}
void bind()
{
glValidate(glUseProgram, v);
}
void unbind()
{
glValidate(glUseProgram, 0);
}
} ;
} // namespace
template<typename T>
using GLDiscard = memory::Discard<T>;
using GLDiscardProgram = GLDiscard<opengl::Program>;
using GLDiscardTexture = GLDiscard<opengl::Texture>;
using GLDiscardVAO = GLDiscard<opengl::VAO>;
using GLDiscardBuffer = GLDiscard<opengl::Buffer>;
} // namespace

60
tjp/core/graphics/shader/base.h Executable file
View File

@@ -0,0 +1,60 @@
#ifndef TIMPREPSCIUS_CORE_GRAPHICS_SHADER_BASE_H
#define TIMPREPSCIUS_CORE_GRAPHICS_SHADER_BASE_H
#include "types.h"
#if defined(USE_OPENGLES)
precision highp float;
#define IN_LOCATION(x) layout (location = x)
#define X_OUT_LOCATION(x)
#define X_IN_LOCATION(x)
#define USE_GL_POSITION(x)
#define USE_GL_POSITION_SIZE(x, y)
#define USE_GL_COLOR(x) out vec4 x;
#define SAMPLER_1D sampler2D
#define TEXTURE_1D(s,v) texture(s, vec2(v, 0))
#define TEXTURE_BINDING(x)
#define PUSH_CONSTANTS layout(std140)
#define FIX_VULKAN_Y(x) x.y = -x.y;
#elif defined(USE_VULKAN)
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
#define IN_LOCATION(x) layout (location = x)
#define X_OUT_LOCATION(x) layout (location = x)
#define X_IN_LOCATION(x) layout (location = x)
#define USE_GL_POSITION(x) out gl_PerVertex { vec4 x; };
#define USE_GL_POSITION_SIZE(x, y) out gl_PerVertex { vec4 x; float y; };
#define USE_GL_COLOR(x) layout (location = 0) out vec4 x;
#define SAMPLER_1D sampler1D
#define TEXTURE_1D(s,v) texture(s, v)
#define TEXTURE_BINDING(x) layout (binding = x)
#define PUSH_CONSTANTS layout(push_constant)
#define FIX_VULKAN_Y(x)
#elif defined(USE_OPENGL)
#define IN_LOCATION(x) layout (location = x)
#define X_OUT_LOCATION(x)
#define X_IN_LOCATION(x)
#define USE_GL_POSITION(x) out gl_PerVertex { vec4 x; };
#define USE_GL_POSITION_SIZE(x, y) out gl_PerVertex { vec4 x; float y; };
// #define USE_GL_POSITION_SIZE(x, y)
#define USE_GL_COLOR(x) layout (location = 0) out vec4 x;
#define SAMPLER_1D sampler1D
#define TEXTURE_1D(s,v) texture(s, v)
#define TEXTURE_BINDING(x)
#define PUSH_CONSTANTS layout(std140)
#define FIX_VULKAN_Y(x) x.y = -x.y;
#else
#error engine not defined
#endif
#endif

View File

@@ -0,0 +1,9 @@
#ifndef TIMPREPSCIUS_CORE_GRAPHICS_SHADER_CONSTANTS_H
#define TIMPREPSCIUS_CORE_GRAPHICS_SHADER_CONSTANTS_H
#define M_PI 3.1415926535897932384626433832795
#define M_2_PI (2.0 * M_PI)
#define M_PI_2 (M_PI / 2.0)
#endif

View File

@@ -0,0 +1,24 @@
#ifndef TIMPREPSCIUS_CORE_GRAPHICS_SHADER_NOISE_VEC2_0_H
#define TIMPREPSCIUS_CORE_GRAPHICS_SHADER_NOISE_VEC2_0_H
float noise_vec2_0_pn(in vec3 n) {
return fract(sin(dot(n, vec3(12.9898, 4.1414, 2.0132))) * 43758.5453);
}
float noise_vec2_0(vec2 p_) {
vec2 p = 1000.0 * p_;
vec2 i = floor(p);
vec2 f = fract(p);
// Hash
float a = noise_vec2_0_pn(vec3(i, 0.0));
float b = noise_vec2_0_pn(vec3(i + vec2(1.0, 0.0), 0.0));
float c = noise_vec2_0_pn(vec3(i + vec2(0.0, 1.0), 0.0));
float d = noise_vec2_0_pn(vec3(i + vec2(1.0, 1.0), 0.0));
// Interpolation
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}
#endif

135
tjp/core/graphics/shader/time.h Executable file
View File

@@ -0,0 +1,135 @@
#ifndef TIMPREPSCIUS_CORE_GRAPHICS_SHADER_TIME_H
#define TIMPREPSCIUS_CORE_GRAPHICS_SHADER_TIME_H
#include "constants.h"
//#define USE_TIME_FLOAT
//#define USE_TIME_INT64
#define USE_TIME_VEC2
#if defined(USE_TIME_INT64)
#define long_time int64_t
#define short_time float
#define cycle_time float
#define time_span_t vec2
#elif defined(USE_TIME_FLOAT)
#define long_time float
#define short_time float
#define cycle_time float
#define time_span_t vec2
#elif defined(USE_TIME_VEC2)
#define long_time vec2
#define short_time float
#define cycle_time float
#define time_span_t vec2
#endif
#if defined(USE_TIME_INT64)
#define FIXED_POINT_SHIFT 16
// short_time time_div(long_time l, long_time r)
// {
// time_type shift = (l << FIXED_POINT_SHIFT);
// // Perform division and return the result
// time_type result = (l * shift) / r;
//
// return time_real(result) / time_real(shift);
// }
short_time short_duration(long_time l, long_time r)
{
long_time dt = l - r;
return short_time(dt) / 1000.0;
}
bool time_is_zero(long_time t)
{
return t == 0;
}
#elif defined(USE_TIME_FLOAT)
short_time time_cycle_offset(cycle_time t, cycle_time time)
{
return max(t - time, 0.0);
}
short_time time_cycle_point(cycle_time t, time_span_t time_span)
{
return time_cycle_offset(t, time_span.x) / (time_span.y - time_span.x);
}
bool time_is_zero(long_time t)
{
return t == 0;
}
#elif defined(USE_TIME_VEC2)
#define LONG_TIME_HIGH = 10000.0
#define LONG_TIME_LOW = 0.0001
short_time time_cycle_offset(cycle_time t, cycle_time time)
{
const float MAX_VALUE = 3600.0; // 1 hour
float normal = max(t - time, 0.0);
float wrapped = (MAX_VALUE - time) + t;
return min(normal, wrapped);
}
short_time time_cycle_point(cycle_time t, time_span_t s)
{
return time_cycle_offset(t, s.x) / (s.y - s.x);
}
bool time_is_zero(long_time t)
{
return t == vec2(0,0);
}
#endif
int time_cycle_iteration(cycle_time t, short_time d)
{
return int(t / d);
}
short_time time_cycle(cycle_time t, short_time d)
{
return 0.5 * sin(t * d * M_2_PI - M_PI_2) + 0.5;
}
short_time time_cycle_range(cycle_time t, short_time d, short_time r)
{
return time_cycle(t, d) * r;
}
short_time time_cycle_range(cycle_time t, short_time d)
{
return time_cycle(t, d);
}
short_time time_cycle_range(cycle_time t, short_time d, const short_time l, const short_time r)
{
short_time dr = r - l;
return time_cycle(t, dr) + l;
}
short_time time_cycle_range_with(short_time t, const short_time l, const short_time r)
{
short_time dr = r - l;
return t * dr + l;
}
#endif

Some files were not shown because too many files have changed in this diff Show More