summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp304
1 files changed, 179 insertions, 125 deletions
diff --git a/main.cpp b/main.cpp
index 10e74ec..83d3dcb 100644
--- a/main.cpp
+++ b/main.cpp
@@ -18,11 +18,7 @@
#include "imgui/imgui.h"
#include "imgui/backends/imgui_impl_sdl.h"
#include "imgui/backends/imgui_impl_opengl3.h"
-#if WINDOWS
#include <SDL.h>
-#else
-#include <SDL2/SDL.h>
-#endif
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <SDL_opengles2.h>
#else
@@ -94,12 +90,6 @@ static uint32 RandomGlobalIncrement = 0;
#include "effects_gl_shader.cpp"
#include "effects.cpp"
#include "effects_constructors.cpp"
-#if 0
-#include "keyframes.cpp"
-#include "layer.cpp"
-#include "bitmap_calls.cpp"
-#endif
-
static void
Main_RenderUI(ImGuiIO io, ImVec4 clear_color, SDL_Window *window)
@@ -178,114 +168,26 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI,
ImGui::DockSpaceOverViewport();
+#if DEBUG
if (Debug.ToggleWindow) {
ImGui::ShowDemoWindow();
ImGui_DebugMemoryViewer(Memory, State);
ImGui_DebugUndoTree(Memory, State);
}
-
- if (State->Initializing == 3) {
- Source_UICreateButton(File, State, Memory, Sorted.CompArray, Sorted.LayerArray);
- block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 0);
- Layer->IsSelected = true;
- // Layer->Block_Effect_Index[0] = Effect_Init(State, Memory, 0, Layer->Block_Effect_Count);
- // Layer->Block_Effect_Count = 1;
- }
- // if (State->Initializing == 2) {
- // block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex);
- // Precomp_UICreateButton(File, State, Memory, MainComp, *Sorted.CompArray, Sorted.LayerArray);
- // }
-#if 0
- // Layera->x.IsToggled = true;
- // Layera->y.IsToggled = true;
- // block_layer *Layerb = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 1);
- // Layerb->x.IsToggled = true;
- // Layerb->y.IsToggled = true;
- // block_layer *Layerc = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 0);
- // Layerc->x.IsToggled = true;
- // Layerc->y.IsToggled = true;
- // Layer_Select(Memory, State, 0);
- // Layer_Select(Memory, State, 1);
- // Layer_Select(Memory, State, 2);
- }
- if (State->Initializing == 2) {
- // block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex);
- // Precomp_UICreateButton(File, State, Memory, MainComp, *Sorted.CompArray, Sorted.LayerArray);
- // Layer_DeselectAll(Memory, State, File->Layer_Count);
-
- block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 0);
- block_layer *Layer2 = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 1);
- block_layer *Layer3 = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, 2);
- Layer_Select(Memory, State, 0);
- // History_Entry_Commit(Memory, "Add keyframe");
- property_channel *Property = &Layer->x;
- Layer->scale.CurrentValue = 0.3;
- Layer2->scale.CurrentValue = 0.3;
- Layer3->scale.CurrentValue = 0.3;
- /*
- State->UpdateFrame = true;
- {
- bezier_point Point = { 1, {1, 0, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- {
- bezier_point Point = { 1, {10, 300, -3, 0, 3, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- {
- bezier_point Point = { 1, {20, 300, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- History_Entry_End(Memory);
- Property = &Layer->y;
- {
- bezier_point Point = { 1, {10, 50, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- {
- bezier_point Point = { 1, {0, -800, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- {
- bezier_point Point = { 1, {20, 400, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- Property = &Layer->rotation;
- {
- bezier_point Point = { 1, {0, 0, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- {
- bezier_point Point = { 1, {20, -360, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- {
- bezier_point Point = { 1, {40, 360, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- Property = &Layer->opacity;
- {
- bezier_point Point = { 1, {0, 1, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- {
- bezier_point Point = { 1, {35, 0, -5, 0, 5, 0}, interpolation_type_bezier, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
- }
- History_Entry_End(Memory);
- */
- }
#endif
+ ImGui_Popups(File, State, UI, Memory, io);
ImGui_Viewport(File, State, UI, Memory, io, textureID, Sorted.CompArray, Sorted.LayerArray);
ImGui_Timeline(File, State, Memory, UI, io, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyInfo, Sorted.PropertyArray);
ImGui_File(File, State, Memory, io, Sorted.CompArray, Sorted.LayerArray);
ImGui_PropertiesPanel(File, State, UI, Memory, io);
ImGui_ColorPanel(File, State, UI, Memory, io);
- ImGui_EffectsPanel(File, State, Memory, UI, io);
+ // ImGui_EffectsPanel(File, State, Memory, UI, io);
#if STABLE
- ImGui_SD_Prompt(File, State, UI, Memory, io, Sorted.CompArray, Sorted.LayerArray);
- ImGui_SD_Thumbnail(File, State, UI, Memory, io, Sorted.CompArray, Sorted.LayerArray, Sorted.SourceArray, Sorted.TempSourceCount);
+ if (State->StableEnabled) {
+ ImGui_SD_Prompt(File, State, UI, Memory, io, Sorted.CompArray, Sorted.LayerArray);
+ ImGui_SD_Thumbnail(File, State, UI, Memory, io, Sorted.CompArray, Sorted.LayerArray, Sorted.SourceArray, Sorted.TempSourceCount);
+ }
#endif
ImGui_Menu(File, State, UI, Memory, io);
@@ -444,7 +346,7 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io
uint64 ScratchSize = Width * Height * BytesPerPixel;
RenderAddress = Memory_PushScratch(Memory, ScratchSize);
- // Memory_Copy((uint8 *)RenderAddress, (uint8 *)BitmapAddress, ScratchSize);
+ Memory_Copy((uint8 *)RenderAddress, (uint8 *)BitmapAddress, ScratchSize);
if (State->Interact_Active == interact_type_brush && State->Brush.LayerToPaint_Index == Index_Physical) {
// TODO(fox): Do all these extra precomputes really make a difference in the renderer?
@@ -460,7 +362,7 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io
Assert(Width);
Assert(Height);
transform_info T = Transform_Calculate(State, Memory, File, Layer, Comp, Width, Height, BytesPerPixel);
- T.SourceBuffer = BitmapAddress;
+ T.SourceBuffer = RenderAddress;
rectangle RenderRegion = {0, 0, Comp->Width, Comp->Height};
Render_Main((void *)&T, CompBuffer, render_type_main, RenderRegion);
@@ -472,6 +374,173 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io
return CompBuffer;
}
+static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n"
+"Pos=0,0\n"
+"Size=2133,1333\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Debug##Default]\n"
+"Pos=122,442\n"
+"Size=400,400\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Viewport]\n"
+"Pos=443,34\n"
+"Size=1165,738\n"
+"Collapsed=0\n"
+"DockId=0x00000010,0\n"
+"\n"
+"[Window][###Properties]\n"
+"Pos=0,34\n"
+"Size=441,738\n"
+"Collapsed=0\n"
+"DockId=0x0000000B,0\n"
+"\n"
+"[Window][Timeline]\n"
+"Pos=0,774\n"
+"Size=2133,559\n"
+"Collapsed=0\n"
+"DockId=0x0000000A,0\n"
+"\n"
+"[Window][Dear ImGui Demo]\n"
+"Pos=1610,34\n"
+"Size=523,267\n"
+"Collapsed=0\n"
+"DockId=0x00000011,1\n"
+"\n"
+"[Window][Files]\n"
+"Pos=1610,303\n"
+"Size=523,469\n"
+"Collapsed=0\n"
+"DockId=0x00000007,0\n"
+"\n"
+"[Window][Effects list]\n"
+"Pos=2677,1047\n"
+"Size=523,192\n"
+"Collapsed=0\n"
+"DockId=0x00000008,0\n"
+"\n"
+"[Window][Graph editor]\n"
+"Pos=0,949\n"
+"Size=3200,526\n"
+"Collapsed=0\n"
+"DockId=0x00000009,0\n"
+"\n"
+"[Window][undotree]\n"
+"Pos=2114,80\n"
+"Size=256,565\n"
+"Collapsed=0\n"
+"\n"
+"[Window][memoryviewer]\n"
+"Pos=50,273\n"
+"Size=800,200\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Example: Custom rendering]\n"
+"Pos=758,789\n"
+"Size=485,414\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Memory viewer]\n"
+"Pos=1610,303\n"
+"Size=523,469\n"
+"Collapsed=0\n"
+"DockId=0x00000007,1\n"
+"\n"
+"[Window][Graph info]\n"
+"Pos=2838,1265\n"
+"Size=235,353\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Properties]\n"
+"Pos=0,34\n"
+"Size=495,1056\n"
+"Collapsed=0\n"
+"DockId=0x0000000F,0\n"
+"\n"
+"[Window][Colors]\n"
+"Pos=1610,34\n"
+"Size=523,267\n"
+"Collapsed=0\n"
+"DockId=0x00000011,0\n"
+"\n"
+"[Window][Menu]\n"
+"Pos=0,0\n"
+"Size=2133,32\n"
+"Collapsed=0\n"
+"DockId=0x0000000D,0\n"
+"\n"
+"[Window][Stable Diffusion]\n"
+"Pos=2206,684\n"
+"Size=421,462\n"
+"Collapsed=0\n"
+"\n"
+"[Window][SD prompt input]\n"
+"Pos=2677,473\n"
+"Size=523,541\n"
+"Collapsed=0\n"
+"DockId=0x00000007,2\n"
+"\n"
+"[Window][Example: Console]\n"
+"Pos=747,851\n"
+"Size=520,600\n"
+"Collapsed=0\n"
+"\n"
+"[Window][SD gallery]\n"
+"Pos=0,718\n"
+"Size=441,557\n"
+"Collapsed=0\n"
+"DockId=0x0000000C,0\n"
+"\n"
+"[Window][Save as]\n"
+"Pos=300,800\n"
+"Size=300,300\n"
+"Collapsed=0\n"
+"\n"
+"[Table][0x861D378E,3]\n"
+"Column 0 Weight=1.0000\n"
+"Column 1 Weight=1.0000\n"
+"Column 2 Weight=1.0000\n"
+"\n"
+"[Table][0x1F146634,3]\n"
+"RefScale=13\n"
+"Column 0 Width=63\n"
+"Column 1 Width=63\n"
+"Column 2 Width=63\n"
+"\n"
+"[Table][0x64418101,3]\n"
+"RefScale=13\n"
+"Column 0 Width=63\n"
+"Column 1 Width=63\n"
+"Column 2 Width=63\n"
+"\n"
+"[Table][0xC9935533,3]\n"
+"Column 0 Weight=1.0000\n"
+"Column 1 Weight=1.0000\n"
+"Column 2 Weight=1.0000\n"
+"\n"
+"[Docking][Data]\n"
+"DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,0 Size=2133,1333 Split=Y Selected=0x13926F0B\n"
+" DockNode ID=0x0000000D Parent=0x8B93E3BD SizeRef=3200,32 HiddenTabBar=1 Selected=0xA57AB2C6\n"
+" DockNode ID=0x0000000E Parent=0x8B93E3BD SizeRef=3200,1299 Split=Y\n"
+" DockNode ID=0x00000001 Parent=0x0000000E SizeRef=3200,1205 Split=X Selected=0x13926F0B\n"
+" DockNode ID=0x00000003 Parent=0x00000001 SizeRef=441,1171 Split=Y Selected=0xDBB8CEFA\n"
+" DockNode ID=0x0000000B Parent=0x00000003 SizeRef=521,425 Selected=0xDBB8CEFA\n"
+" DockNode ID=0x0000000C Parent=0x00000003 SizeRef=521,347 Selected=0x56290987\n"
+" DockNode ID=0x00000004 Parent=0x00000001 SizeRef=1690,1171 Split=X Selected=0x13926F0B\n"
+" DockNode ID=0x00000005 Parent=0x00000004 SizeRef=1165,1171 Split=X Selected=0x13926F0B\n"
+" DockNode ID=0x0000000F Parent=0x00000005 SizeRef=495,856 Selected=0x199AB496\n"
+" DockNode ID=0x00000010 Parent=0x00000005 SizeRef=2199,856 CentralNode=1 Selected=0x13926F0B\n"
+" DockNode ID=0x00000006 Parent=0x00000004 SizeRef=523,1171 Split=Y Selected=0x86FA2F90\n"
+" DockNode ID=0x00000011 Parent=0x00000006 SizeRef=483,437 Selected=0xBF7DFDC9\n"
+" DockNode ID=0x00000012 Parent=0x00000006 SizeRef=483,766 Split=Y Selected=0x59A2A092\n"
+" DockNode ID=0x00000007 Parent=0x00000012 SizeRef=523,572 Selected=0x86FA2F90\n"
+" DockNode ID=0x00000008 Parent=0x00000012 SizeRef=523,192 Selected=0x812F222D\n"
+" DockNode ID=0x00000002 Parent=0x0000000E SizeRef=3200,559 Split=Y Selected=0x0F18B61B\n"
+" DockNode ID=0x00000009 Parent=0x00000002 SizeRef=3250,526 Selected=0xA1F22F4D\n"
+" DockNode ID=0x0000000A Parent=0x00000002 SizeRef=3250,323 HiddenTabBar=1 Selected=0x0F18B61B\n"
+"\n";
+
static void
Main_Renderer(project_data *File, project_state *State, memory *Memory, SDL_Window *window, GLuint textureID, ImGuiIO io)
{
@@ -593,23 +662,9 @@ int main(int argc, char *argv[]) {
File->Comp_Count = 1;
- {
- uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/a_small.jpg");
- block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, File->Source_Count - 1);
- Source->IsSelected = true;
- }
#if 0
- const char *myb[] = { "../asset/hand/IMG_4239.jpg", "../asset/hand/IMG_4242.jpg", "../asset/hand/IMG_4243.jpg",
- "../asset/hand/IMG_4244.jpg", "../asset/hand/IMG_4248.jpg", "../asset/hand/IMG_4249.jpg" };
-
- for (int i = 0; i < 6; i++) {
- uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)myb[i]);
- block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, File->Source_Count - 1);
- Source->IsSelected = true;
- }
-
{
- uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/hand/c.png");
+ uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/a_small.jpg");
block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, File->Source_Count - 1);
Source->IsSelected = true;
}
@@ -703,8 +758,8 @@ int main(int argc, char *argv[]) {
// I'm loading the window positions from this convenient tool. ImGui by
// default saves window position to an external .ini file, which can be
// loaded from disk or memory.
- // io.IniFilename = NULL;
- // ImGui::LoadIniSettingsFromMemory(ImGuiPrefs);
+ io.IniFilename = NULL;
+ ImGui::LoadIniSettingsFromMemory(ImGuiPrefs);
ImGui::StyleColorsDark();
@@ -722,7 +777,6 @@ int main(int argc, char *argv[]) {
Brush_CalcBitmapAlphaFromSize(&Memory, &State->Brush, 4);
State_BindBrushTexture(&Memory, &State->Brush, 4);
-
#if STABLE
curl_global_init(CURL_GLOBAL_ALL);
curl_state MainHandle = {};