summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--createcalls.cpp52
-rw-r--r--debug.h32
-rw-r--r--layer.cpp14
-rw-r--r--main.h13
-rw-r--r--my_imgui_widgets.cpp228
-rw-r--r--my_math.h5
-rw-r--r--prenderer.cpp1
7 files changed, 217 insertions, 128 deletions
diff --git a/createcalls.cpp b/createcalls.cpp
index a15ab70..5144cf0 100644
--- a/createcalls.cpp
+++ b/createcalls.cpp
@@ -255,9 +255,18 @@ Layer_LocalToScreenSpace(project_layer *Layer, ui *UI, comp_buffer CompBuffer, v
return ImVec2(ScreenPoint.x, ScreenPoint.y);
}
+
+static void
+Mask_PushPoint(mask *Mask, v2 Pos)
+{
+ mask_point *PointToAdd = &Mask->Point[Mask->NumberOfPoints];
+ PointToAdd->Pos = Pos;
+ Mask->NumberOfPoints++;
+}
+
static void
-Mask_AddPoint(mask *Mask, ImVec2 Pos, ImVec2 TangentLeft, ImVec2 TangentRight,
- ImVec2 Ratio0, ImVec2 Ratio1, uint16 Index)
+Mask_AddPointToCurve(mask *Mask, ImVec2 Pos, ImVec2 TangentLeft, ImVec2 TangentRight,
+ ImVec2 Ratio0, ImVec2 Ratio1, uint16 Index)
{
mask_point *Point = &Mask->Point[Index];
mask_point *NextPoint = &Mask->Point[Index+1];
@@ -272,8 +281,6 @@ Mask_AddPoint(mask *Mask, ImVec2 Pos, ImVec2 TangentLeft, ImVec2 TangentRight,
PointToAdd->Pos = {Pos.x, Pos.y};
PointToAdd->TangentLeft = {-TangentLeft.x, -TangentLeft.y};
PointToAdd->TangentRight = {-TangentRight.x, -TangentRight.y};
- PointToAdd->TangentLeft = {-TangentLeft.x, -TangentLeft.y};
- PointToAdd->TangentRight = {-TangentRight.x, -TangentRight.y};
Mask->NumberOfPoints++;
}
@@ -286,24 +293,25 @@ LoadTestFootage(project_data *File, project_state *State, memory *Memory)
Layer_CreateFromSource(File, State, Memory, Source);
SelectLayer(File->Layer[0], State, 0);
AddEffect(File->Layer[0], Memory, 3);
- mask *Mask = &File->Layer[0]->Mask[0];
- File->Layer[0]->NumberOfMasks = 1;
- Mask->Point[0].Pos = V2(200, 200);
- Mask->Point[1].Pos = V2(1280, 0);
- Mask->Point[2].Pos = V2(1280, 720);
- Mask->Point[3].Pos = V2(0, 720);
-
- Mask->Point[0].TangentLeft = V2(-50, 0);
- Mask->Point[1].TangentLeft = V2(-50, 0);
- Mask->Point[2].TangentLeft = V2(-50, 0);
- Mask->Point[3].TangentLeft = V2(-50, 0);
-
- Mask->Point[0].TangentRight = V2(50, 0);
- Mask->Point[1].TangentRight = V2(50, 0);
- Mask->Point[2].TangentRight = V2(50, 0);
- Mask->Point[3].TangentRight = V2(50, 0);
-
- Mask->NumberOfPoints = 4;
+
+ // mask *Mask = &File->Layer[0]->Mask[0];
+ // File->Layer[0]->NumberOfMasks = 1;
+ // Mask->Point[0].Pos = V2(200, 200);
+ // Mask->Point[1].Pos = V2(1280, 0);
+ // Mask->Point[2].Pos = V2(1280, 720);
+ // Mask->Point[3].Pos = V2(0, 720);
+
+ // Mask->Point[0].TangentLeft = V2(-50, 0);
+ // Mask->Point[1].TangentLeft = V2(-50, 0);
+ // Mask->Point[2].TangentLeft = V2(-50, 0);
+ // Mask->Point[3].TangentLeft = V2(-50, 0);
+
+ // Mask->Point[0].TangentRight = V2(50, 0);
+ // Mask->Point[1].TangentRight = V2(50, 0);
+ // Mask->Point[2].TangentRight = V2(50, 0);
+ // Mask->Point[3].TangentRight = V2(50, 0);
+ // Mask->NumberOfPoints = 4;
+
// property_channel *Property = &File->Layer[0]->x;
// ManualKeyframeInsertF(Property, Memory, 1, 500);
// ManualKeyframeInsertF(Property, Memory, 30, 800);
diff --git a/debug.h b/debug.h
index 36b9557..e2df239 100644
--- a/debug.h
+++ b/debug.h
@@ -15,18 +15,18 @@ union debugval {
int32 i;
};
-struct project_debug
+// things that get cleared every frame with the UI
+struct debug_temp
{
- uint32 Markers[8];
- uint32 MarkerIndex = 0;
- uint64 CycleCount[8];
- uint64 EndCycleCount[8];
- uint64 ExecutionAmount[8];
-
valtype DebugPropertyType[16];
debugval Val[16];
char *String[16];
uint32 WatchedProperties;
+};
+
+struct project_debug
+{
+ debug_temp Temp;
bool32 ToggleWindow;
};
@@ -42,16 +42,16 @@ static project_debug Debug;
static void
DebugWatchVar(char *Name, void *Address, valtype Type) {
- uint32 i = Debug.WatchedProperties;
- Debug.String[i] = Name;
+ uint32 i = Debug.Temp.WatchedProperties;
+ Debug.Temp.String[i] = Name;
if (Type == d_float)
- Debug.Val[i].f = *(real32 *)Address;
+ Debug.Temp.Val[i].f = *(real32 *)Address;
if (Type == d_uint)
- Debug.Val[i].u = *(uint32 *)Address;
+ Debug.Temp.Val[i].u = *(uint32 *)Address;
if (Type == d_int)
- Debug.Val[i].i = *(int32 *)Address;
- Debug.DebugPropertyType[i] = Type;
- Debug.WatchedProperties++;
+ Debug.Temp.Val[i].i = *(int32 *)Address;
+ Debug.Temp.DebugPropertyType[i] = Type;
+ Debug.Temp.WatchedProperties++;
}
#else
@@ -64,6 +64,10 @@ enum valtype {
union debugval {
};
+struct debug_temp
+{
+};
+
struct project_debug
{
};
diff --git a/layer.cpp b/layer.cpp
index d6c225b..5d3a4c0 100644
--- a/layer.cpp
+++ b/layer.cpp
@@ -21,21 +21,17 @@ FindSelectedLayerIndex(project_data *File, int16 NumberOfSelectedLayers)
static transform_info
CalculateTransforms(project_layer *Layer, comp_buffer *CompBuffer);
-static bool32
-TestPointInLayer(project_layer *Layer, comp_buffer *CompBuffer, v2 UV)
+static v2
+CompUVToLayerUV(project_layer *Layer, comp_buffer *CompBuffer, v2 CompUV)
{
- bool32 Result = false;
- real32 X = UV.x*CompBuffer->Width;
- real32 Y = UV.y*CompBuffer->Height;
+ real32 X = CompUV.x*CompBuffer->Width;
+ real32 Y = CompUV.y*CompBuffer->Height;
transform_info T = CalculateTransforms(Layer, CompBuffer);
real32 StartVectorX = X - T.OriginX;
real32 StartVectorY = Y - T.OriginY;
real32 LayerU = (StartVectorX * T.XAxisPX) + (StartVectorY * T.XAxisPY);
real32 LayerV = (StartVectorX * T.YAxisPX) + (StartVectorY * T.YAxisPY);
- if (LayerU <= 1.0f && LayerU >= 0.0f && LayerV <= 1.0f && LayerV >= 0.0f) {
- Result = true;
- }
- return Result;
+ return V2(LayerU, LayerV);
}
static void
diff --git a/main.h b/main.h
index da099cc..8a6c7ca 100644
--- a/main.h
+++ b/main.h
@@ -252,6 +252,8 @@ struct layer_bitmap_info {
void *AVInfo; // Internal data containing current frame info
};
+// NOTE(fox): I use the term "comp" (composition) to mean the canvas that is
+// being rendered to, since it's what I'm used to from AE.
struct comp_buffer {
uint16 Width;
uint16 Height;
@@ -418,7 +420,12 @@ enum selection_type
enum tool {
tool_default,
- tool_pen
+ tool_pen,
+ tool_count
+};
+
+struct pen_state {
+ bool32 IsActive;
};
struct project_state
@@ -428,6 +435,7 @@ struct project_state
bool32 DebugDisableCache = 1;
tool Tool = tool_default;
+ pen_state Pen = {};
uint16 LayersToRender[MAX_LAYERS];
uint16 NumberOfLayersToRender;
@@ -470,6 +478,9 @@ struct ui
real32 TimelineSplit = 600;
real32 TimelineZoom;
+ // Note that I don't use "zoom" to mean the scale in relation to the
+ // original (i.e. default = 1.0f); it's the literal screen size in pixels
+ // of the composition in the UI.
ImVec2 CompZoom;
ImVec2 CompPos;
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index cb981c2..6f785de 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -70,6 +70,17 @@ ImGui_KeyframeDragging(project_data *File, project_state *State, ui *UI, propert
}
}
+// Returns a normalized UV position of the composition
+static ImVec2
+ImGui_ScreenPointToCompUV(ImVec2 ViewportMin, ImVec2 CompPos, ImVec2 CompZoom, ImVec2 MousePos)
+{
+ ImVec2 LocalMousePos = MousePos - ViewportMin;
+ ImVec2 LocalCompPos = CompPos - ViewportMin;
+ ImVec2 MouseScreenUV = LocalMousePos - LocalCompPos;
+ ImVec2 Result = MouseScreenUV / CompZoom;
+ return Result;
+}
+
static void
ImGui_DebugMemoryViewer(project_data *File, memory *Memory)
{
@@ -331,6 +342,7 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
UI->FocusedWindow = focus_viewport;
// Primarily taken from the Custom Rendering section of the demo
+
ImVec2 ViewportMin = ImGui::GetCursorScreenPos();
ImVec2 ViewportScale = ImGui::GetContentRegionAvail();
ViewportScale.y -= ImGui::GetFontSize();
@@ -357,18 +369,20 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
// UI+interaction for layer
if (State->MostRecentlySelectedLayer > -1) {
project_layer *Layer = File.Layer[State->MostRecentlySelectedLayer];
+ source *Source = Layer->Source;
- // Anchor point
+ // Anchor point UI
ImVec2 AUV = ImVec2(Layer->x.CurrentValue.f / CompBuffer.Width, Layer->y.CurrentValue.f / CompBuffer.Height);
ImVec2 ScreenAP = ImVec2(UI->CompPos.x + AUV.x * UI->CompZoom.x, UI->CompPos.y + AUV.y * UI->CompZoom.y);
draw_list->AddNgon(ScreenAP, 20, ImGui::GetColorU32(ImGuiCol_ScrollbarGrab), 8, 10.0f);
- // Mask points
+ // Mask UI
if (Layer->NumberOfMasks) {
for (int i = 0; i < Layer->NumberOfMasks; i++) {
mask *Mask = &Layer->Mask[i];
ImGui::PushID(i);
- source *Source = Layer->Source;
+
+ real32 PointSize = 40;
for (int p = 0; p < Mask->NumberOfPoints; p++) {
@@ -397,6 +411,8 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
ImU32 col = ImGui::GetColorU32(ImGuiCol_ScrollbarGrab);
+ // The handle itself
+
draw_list->AddNgon(Point0_ScreenPos, 10, col, 8, 5.0f);
draw_list->AddNgon(Point0_ScreenPos_Left, 10, col, 8, 5.0f);
draw_list->AddNgon(Point0_ScreenPos_Right, 10, col, 8, 5.0f);
@@ -406,51 +422,6 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
ImU32 col2 = ImGui::GetColorU32(ImGuiCol_Button);
-
- real32 PointSize = 40;
-
-
- // Ratio of the point along the curve. See internal for more info.
- float ratio;
-
- if (ImGui::BezierInteractive(Point0_ScreenPos, Point0_ScreenPos_Right,
- Point1_ScreenPos_Left, Point1_ScreenPos, ratio))
- {
- // Using a button like this may be kinda janky, but it gives us access
- // to all of ButtonBehavior and the ID system without having to rewrite it.
- ImGui::SetCursorScreenPos(io.MousePos - ImVec2(5,5));
- ImGui::Button("maskbezier", ImVec2(10, 10));
-
- if(ImGui::IsItemHovered()) {
- ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll);
- draw_list->AddNgon(io.MousePos, 2, col, 8, 5.0f);
- ImVec2 RatioLeft = ImGui::RatioToPoint(Point0_ScreenPos, Point0_ScreenPos_Right, ratio);
- ImVec2 RatioTop = ImGui::RatioToPoint(Point0_ScreenPos_Right, Point1_ScreenPos_Left, ratio);
- ImVec2 RatioRight = ImGui::RatioToPoint(Point1_ScreenPos_Left, Point1_ScreenPos, ratio);
- ImVec2 TangentLeft = ImGui::RatioToPoint(RatioLeft, RatioTop, ratio);
- ImVec2 TangentRight = ImGui::RatioToPoint(RatioTop, RatioRight, ratio);
- draw_list->AddLine(RatioLeft, RatioTop, col, 2.0f);
- draw_list->AddLine(RatioRight, RatioTop, col, 2.0f);
- draw_list->AddLine(TangentLeft, TangentRight, col, 2.0f);
- }
- if(ImGui::IsItemActivated() && io.KeyCtrl) {
- ImVec2 Ratio0 = ImGui::RatioToPoint(Point0_Pos, Point0_Pos_Right, ratio);
- ImVec2 RatioTop = ImGui::RatioToPoint(Point0_Pos_Right, Point1_Pos_Left, ratio);
- ImVec2 Ratio1 = ImGui::RatioToPoint(Point1_Pos_Left, Point1_Pos, ratio);
- ImVec2 TangentLeft = ImGui::RatioToPoint(Ratio0, RatioTop, ratio);
- ImVec2 TangentRight = ImGui::RatioToPoint(RatioTop, Ratio1, ratio);
- ImVec2 Point = ImGui::RatioToPoint(TangentLeft, TangentRight, ratio);
- Mask_AddPoint(Mask, Point, Point - TangentLeft, Point - TangentRight,
- Point0_Pos - Ratio0, Point1_Pos - Ratio1, p);
- }
- }
-
- DebugWatchVar("ratio", &ratio, d_float);
-
- // if (ImGui::TestLine(PointScreenPos[0], PointScreenPos[1])) {
- // }
-
- // loops over point and handles
for (int b = 0; b < 3; b++)
{
ImGui::PushID(b);
@@ -496,6 +467,56 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
}
+ // The bezier path
+
+ if (Mask->NumberOfPoints == 1) {
+ ImGui::PopID();
+ continue;
+ }
+
+ // Ratio of the point along the curve. See internal for more info.
+ float ratio;
+
+ if (ImGui::BezierInteractive(Point0_ScreenPos, Point0_ScreenPos_Right,
+ Point1_ScreenPos_Left, Point1_ScreenPos, ratio) &&
+ State->Tool == tool_pen)
+ {
+ // Using a button like this may be kinda janky, but it gives us access
+ // to all of ButtonBehavior and the ID system without having to rewrite it.
+ ImGui::SetCursorScreenPos(io.MousePos - ImVec2(5,5));
+ ImGui::Button("maskbezier", ImVec2(10, 10));
+
+ if(ImGui::IsItemHovered()) {
+ // ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll);
+ draw_list->AddNgon(io.MousePos, 2, col, 8, 5.0f);
+ ImVec2 RatioLeft = ImGui::RatioToPoint(Point0_ScreenPos, Point0_ScreenPos_Right, ratio);
+ ImVec2 RatioTop = ImGui::RatioToPoint(Point0_ScreenPos_Right, Point1_ScreenPos_Left, ratio);
+ ImVec2 RatioRight = ImGui::RatioToPoint(Point1_ScreenPos_Left, Point1_ScreenPos, ratio);
+ ImVec2 TangentLeft = ImGui::RatioToPoint(RatioLeft, RatioTop, ratio);
+ ImVec2 TangentRight = ImGui::RatioToPoint(RatioTop, RatioRight, ratio);
+ draw_list->AddLine(RatioLeft, RatioTop, col, 2.0f);
+ draw_list->AddLine(RatioRight, RatioTop, col, 2.0f);
+ draw_list->AddLine(TangentLeft, TangentRight, col, 2.0f);
+ }
+ if(ImGui::IsItemActivated() && io.KeyCtrl) {
+ ImVec2 Ratio0 = ImGui::RatioToPoint(Point0_Pos, Point0_Pos_Right, ratio);
+ ImVec2 RatioTop = ImGui::RatioToPoint(Point0_Pos_Right, Point1_Pos_Left, ratio);
+ ImVec2 Ratio1 = ImGui::RatioToPoint(Point1_Pos_Left, Point1_Pos, ratio);
+ ImVec2 TangentLeft = ImGui::RatioToPoint(Ratio0, RatioTop, ratio);
+ ImVec2 TangentRight = ImGui::RatioToPoint(RatioTop, Ratio1, ratio);
+ ImVec2 Point = ImGui::RatioToPoint(TangentLeft, TangentRight, ratio);
+ Mask_AddPointToCurve(Mask, Point, Point - TangentLeft, Point - TangentRight,
+ Point0_Pos - Ratio0, Point1_Pos - Ratio1, p);
+ }
+ }
+
+ // DebugWatchVar("ratio", &ratio, d_float);
+
+ // if (ImGui::TestLine(PointScreenPos[0], PointScreenPos[1])) {
+ // }
+
+
+
ImGui::PopID();
}
ImGui::PopID();
@@ -506,25 +527,73 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
// Interactions for dragging and zooming
ImGui::SetCursorScreenPos(ViewportMin);
+ real32 ButtonSize = 20;
+
+ for (int t = 0; t < tool_count; t++) {
+ ImGui::PushID(t);
+ bool32 Selected = (State->Tool == t);
+ if (ImGui::Selectable("##tool", Selected, 0, ImVec2(ButtonSize, ButtonSize))) {
+ State->Tool = (tool)t;
+ }
+ ImGui::PopID();
+ }
+
ImGui::InvisibleButton("canvas", ViewportScale, ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight);
bool32 IsHovered = ImGui::IsItemHovered();
bool32 IsActive = ImGui::IsItemActive();
bool32 IsActivated = ImGui::IsItemActivated();
+ if (State->MostRecentlySelectedLayer > -1)
+ {
+ project_layer *Layer = File.Layer[State->MostRecentlySelectedLayer];
+ if (IsActivated && ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
+ if (State->Tool == tool_pen && !State->Pen.IsActive) {
+ State->Pen.IsActive = true;
+ Layer->NumberOfMasks++;
+ }
+ }
+
+ if (State->Pen.IsActive && !ImGui::IsKeyDown(ImGuiKey_Z)) {
+ if (IsActivated) {
+ v2 CompUV = V2(ImGui_ScreenPointToCompUV(ViewportMin, UI->CompPos, UI->CompZoom, io.MousePos));
+ v2 LayerUV = CompUVToLayerUV(Layer, &CompBuffer, CompUV);
+ v2 LayerPos = LayerUV * V2(Layer->Source->Info.Width, Layer->Source->Info.Height);
+ Mask_PushPoint(&Layer->Mask[Layer->NumberOfMasks-1], LayerPos);
+ }
+ if (IsActive) {
+ mask *Mask = &Layer->Mask[Layer->NumberOfMasks-1];
+ mask_point *CurrentPoint = &Mask->Point[Mask->NumberOfPoints-1];
+ v2 CompUV = V2(ImGui_ScreenPointToCompUV(ViewportMin, UI->CompPos, UI->CompZoom, io.MousePos));
+ v2 LayerUV = CompUVToLayerUV(Layer, &CompBuffer, CompUV);
+ v2 LayerPos = LayerUV * V2(Layer->Source->Info.Width, Layer->Source->Info.Height);
+ v2 OffsetPos = CurrentPoint->Pos - LayerPos;
+ CurrentPoint->TangentRight = -OffsetPos;
+ CurrentPoint->TangentLeft = OffsetPos;
+ }
+ if (State->Tool != tool_pen) {
+ State->Pen.IsActive = false;
+ }
+ }
+ }
+
+ if (IsHovered && IsActivated && ImGui::IsMouseDown(ImGuiMouseButton_Left))
+ {
+ // Point to zoom in on if Z is held
+ UI->TempZoomRatio = V2(ImGui_ScreenPointToCompUV(ViewportMin, UI->CompPos, UI->CompZoom, io.MousePos));
+ DebugWatchVar("MouseScreenUV", &UI->TempZoomRatio.x, d_float);
+ DebugWatchVar("MouseScreenUV", &UI->TempZoomRatio.y, d_float);
- if (IsHovered && IsActivated && ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
- v2 LocalMousePos = (V2(io.MousePos) - V2(ViewportMin));
- v2 LocalCompPos = V2(UI->CompPos) - V2(ViewportMin);
- v2 MouseScreenUV = LocalMousePos - LocalCompPos;
- UI->TempZoomRatio = MouseScreenUV / V2(UI->CompZoom); // AKA actual normalized UV of comp
- if (!ImGui::IsKeyDown(ImGuiKey_Z)) {
+ // Layer selection
+ if (!ImGui::IsKeyDown(ImGuiKey_Z) || !State->Pen.IsActive) {
for (int i = File.NumberOfLayers - 1; i >= 0; i--) {
- if (!io.KeyShift) DeselectAllLayers(&File, State);
- if (TestPointInLayer(File.Layer[i], &CompBuffer, UI->TempZoomRatio) && !File.Layer[i]->IsSelected)
- {
- SelectLayer(File.Layer[i], State, i);
- break;
- }
+ project_layer *Layer = File.Layer[i];
+ if (!io.KeyShift) DeselectAllLayers(&File, State);
+ v2 LayerUV = CompUVToLayerUV(Layer, &CompBuffer, UI->TempZoomRatio);
+ if (TestUV(LayerUV) && !Layer->IsSelected)
+ {
+ SelectLayer(Layer, State, i);
+ break;
+ }
}
}
}
@@ -535,14 +604,6 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
UI->CompPos.y += io.MouseDelta.y;
}
- ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonMiddle);
- if (ImGui::BeginPopup("context")) {
- if (ImGui::MenuItem("Scalar", NULL, false, InstructionMode != instruction_mode_scalar)) { InstructionMode = instruction_mode_scalar; State->UpdateFrame = true; }
- if (ImGui::MenuItem("SSE", NULL, false, InstructionMode != instruction_mode_sse)) { InstructionMode = instruction_mode_sse; State->UpdateFrame = true; }
- if (ImGui::MenuItem("AVX2", NULL, false, InstructionMode != instruction_mode_avx)) { InstructionMode = instruction_mode_avx; State->UpdateFrame = true; }
- ImGui::EndPopup();
- }
-
if (IsActive && ImGui::IsMouseDragging(ImGuiMouseButton_Left, -1.0f) && ImGui::IsKeyDown(ImGuiKey_Z))
{
real32 Distance = io.MouseDelta.x + io.MouseDelta.y;
@@ -560,6 +621,16 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, comp_buffer Comp
State->MsgTime--;
}
+
+ ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonMiddle);
+ if (ImGui::BeginPopup("context")) {
+ if (ImGui::MenuItem("Scalar", NULL, false, InstructionMode != instruction_mode_scalar)) { InstructionMode = instruction_mode_scalar; State->UpdateFrame = true; }
+ if (ImGui::MenuItem("SSE", NULL, false, InstructionMode != instruction_mode_sse)) { InstructionMode = instruction_mode_sse; State->UpdateFrame = true; }
+ if (ImGui::MenuItem("AVX2", NULL, false, InstructionMode != instruction_mode_avx)) { InstructionMode = instruction_mode_avx; State->UpdateFrame = true; }
+ ImGui::EndPopup();
+ }
+
+
ImGui::End();
}
@@ -644,16 +715,16 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG
// // AddSource(File, State, Memory, Input);
// }
#if DEBUG
- for (int i = 0; i < Debug.WatchedProperties; i++) {
- if (Debug.DebugPropertyType[i] == d_float) {
- ImGui::Text("%s: %f", Debug.String[i], Debug.Val[i].f);
- } else if (Debug.DebugPropertyType[i] == d_int) {
- ImGui::Text("%s: %i", Debug.String[i], Debug.Val[i].i);
- } else if (Debug.DebugPropertyType[i] == d_uint) {
- ImGui::Text("%s: %u", Debug.String[i], Debug.Val[i].u);
+ for (int i = 0; i < Debug.Temp.WatchedProperties; i++) {
+ if (Debug.Temp.DebugPropertyType[i] == d_float) {
+ ImGui::Text("%s: %f", Debug.Temp.String[i], Debug.Temp.Val[i].f);
+ } else if (Debug.Temp.DebugPropertyType[i] == d_int) {
+ ImGui::Text("%s: %i", Debug.Temp.String[i], Debug.Temp.Val[i].i);
+ } else if (Debug.Temp.DebugPropertyType[i] == d_uint) {
+ ImGui::Text("%s: %u", Debug.Temp.String[i], Debug.Temp.Val[i].u);
}
}
- Debug = {};
+ Debug.Temp = {};
#endif
ImGui::End();
}
@@ -1451,11 +1522,6 @@ ImGui_ProcessInputs(project_data *File, project_state *State, comp_buffer *CompB
{
SwitchBool(Debug.ToggleWindow);
}
- if (ImGui::IsKeyPressed(ImGuiKey_M))
- {
- Debug.Markers[Debug.MarkerIndex] = File->CurrentFrame;
- Debug.MarkerIndex++;
- }
#endif
bool32 Ended = ImGui::IsMouseDown(ImGuiMouseButton_Left);
diff --git a/my_math.h b/my_math.h
index 0f9e429..b95e71d 100644
--- a/my_math.h
+++ b/my_math.h
@@ -577,6 +577,11 @@ Ceil(real32 A, real32 B)
return A;
}
+inline bool32
+TestUV(v2 UV) {
+ return (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f);
+}
+
inline real32
Clamp(real32 A, real32 B, real32 C)
{
diff --git a/prenderer.cpp b/prenderer.cpp
index 24b271c..7550d0f 100644
--- a/prenderer.cpp
+++ b/prenderer.cpp
@@ -154,7 +154,6 @@ QueueCurrentFrame(project_data *File, comp_buffer *CompBuffer, project_state *St
uint16 TileWidth = CompBuffer->Width / 4;
uint16 TileHeight = CompBuffer->Height / 4;
- DEBUG_CycleCountStart(3);
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 4; x++) {
// if (x == y) {