summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f5ffbea..0b57e99 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -174,7 +174,7 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, sorted_
test = 0;
uint64 InputTime = SDL_GetPerformanceCounter() - InputStart;
- printf("OURUI: %.2lu\n", InputTime);
+ // printf("OURUI: %.2lu\n", InputTime);
return test;
}
@@ -371,7 +371,7 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
GL_DeleteHWBuffer(&MSBuffer);
uint64 PerfEnd = SDL_GetPerformanceCounter() - PerfStart;
- printf("OPENGL: %.2lu\n", PerfEnd);
+ // printf("OPENGL: %.2lu\n", PerfEnd);
}
// TODO(fox): We have five functions that essentially do this same precomp loop
@@ -454,7 +454,7 @@ LayerIterate_SelectionStatus(project_state *State, memory *Memory, uint32 CompIn
Position = XAxis + YAxis;
layer_transforms T = Layer_GetTransforms(Layer);
v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Width, Height, Center / V2(Comp->Width, Comp->Height));
- if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && (Layer->IsSelected & 0x03) && !Layer->IsLocked)
+ if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && (Layer->IsSelected & 0x01) && !Layer->IsLocked)
{
*SelectionCount += 1;
*SelectedLayerIndex = i;
@@ -623,18 +623,37 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
void *Data = PointBuffer;
shape_layer *Shape = &Layer->Shape;
shape_options ShapeOpt = Layer->ShapeOpt;
- if (ShapeOpt.Visibility == 1 && ShapeOpt.StrokeWidth <= 0.0f)
- continue;
+ if (ShapeOpt.StrokeWidth == 0.0f) {
+ if (ShapeOpt.Visibility == 0)
+ ShapeOpt.Visibility = 2;
+ if (ShapeOpt.Visibility == 1)
+ continue;
+ }
+ bool32 IsConvex = 0;
v2 Min = {}, Max = {};
uint32 NumberOfVerts = NVG_FlattenPath(Memory, Shape, ShapeOpt, (nvg_point *)Data,
- State, T, Shape->Width, Shape->Height, Comp->Width, Comp->Height, 1, &Min, &Max);
+ State, T, Shape->Width, Shape->Height, Comp->Width, Comp->Height, 1, &Min, &Max, &IsConvex);
PointBuffer += NumberOfVerts * sizeof(nvg_point);
void *Data_Stroke = PointBuffer;
- uint32 StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, ShapeOpt.StrokeWidth, ShapeOpt.LineCapType, ShapeOpt.LineJoinType, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke);
- PointBuffer += StrokeCount * sizeof(real32) * 4;
void *Data_Fill = PointBuffer;
- NVG_ExpandFill(Memory, NumberOfVerts, (nvg_point *)Data, (real32 *)Data_Fill);
- PointBuffer += NumberOfVerts * sizeof(real32) * 4;
+ uint32 StrokeCount = 0;
+
+ int RenderFlags = 0;
+ if (ShapeOpt.Visibility == 1 || ShapeOpt.Visibility == 2) {
+ RenderFlags |= gl_renderflag_stroke;
+ StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, ShapeOpt.StrokeWidth, ShapeOpt.LineCapType, ShapeOpt.LineJoinType, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke, &IsConvex);
+ PointBuffer += StrokeCount * sizeof(real32) * 4;
+ Data_Fill = PointBuffer;
+ }
+
+ if (ShapeOpt.Visibility == 0 || ShapeOpt.Visibility == 2) {
+ RenderFlags |= gl_renderflag_fill;
+ NVG_ExpandFill(Memory, NumberOfVerts, (nvg_point *)Data, (real32 *)Data_Fill);
+ PointBuffer += NumberOfVerts * sizeof(real32) * 4;
+ }
+
+ if (!IsConvex)
+ RenderFlags |= gl_renderflag_concave;
// zero to set the framebuffer to main
gl_effect_layer TestL = {};
@@ -644,19 +663,13 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
RenderData->LayerCount++;
PointBuffer += sizeof(gl_data);
- int RenderFlags = 0;
- int Visibility = ShapeOpt.Visibility;
- if (Visibility == 0 || Visibility == 2)
- RenderFlags |= gl_renderflag_fill;
- if (Visibility == 1 || Visibility == 2)
- RenderFlags |= gl_renderflag_stroke;
-
*GL_Data = { 0, Data_Stroke, StrokeCount, ShapeOpt.StrokeCol,
Data_Fill, NumberOfVerts, ShapeOpt.FillCol,
T, Shape->Width, Shape->Height, RenderFlags };
} else if (Layer->IsPrecomp) {
layer_transforms NewExtraT = Layer_GetTransforms(Layer);
+ // TODO(fox): Add center point for proper scaling!
NewExtraT = Transform_TestInteracts(State, Layer, SortEntry, NewExtraT);
if (ExtraT.scale != 0) {
NewExtraT = Transform_Add(NewExtraT, ExtraT, Comp->Width, Comp->Height);
@@ -1203,9 +1216,7 @@ int main(int argc, char *argv[]) {
sprintf(State->DummyName, "test");
if (File_Open(File, State, &Memory, State->DummyName)) {
State->UpdateFrame = true;
- State->MostRecentlySelectedLayer = 0;
}
- File->UI.LayerColors[3] = 0xff203d6a;
// File->PrincipalCompIndex = 1;
#else
// uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/yu.webm");
@@ -1492,7 +1503,7 @@ int main(int argc, char *argv[]) {
if (TargetMS > FrameMS)
SDL_Delay((uint64)(TargetMS - FrameMS));
}
- printf("TOTAL: %.2lu, (%.2f ms) - INPUTS: %.2lu - RENDERING: %.2lu\n", PerfTime, FrameMS, InputTime, RenderTime);
+ // printf("TOTAL: %.2lu, (%.2f ms) - INPUTS: %.2lu - RENDERING: %.2lu\n", PerfTime, FrameMS, InputTime, RenderTime);
// printf("TOTAL: %.2lu, (%.2f ms) - RENDERING: %.2lu\n", PerfTime, FrameMS, PerfTime);
}