summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp154
1 files changed, 99 insertions, 55 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 534460e..e5fae1d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -292,24 +292,47 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
glUseProgram(DefaultShaderProgram);
bool32 KeepStencil = false;
+ int StencilLayer = 0;
+
+ // stencil buffer
+ glDisable(GL_CULL_FACE);
+ glEnable(GL_STENCIL_TEST);
+ glStencilMask(0xff);
+ glClearStencil(0);
+ glClear(GL_STENCIL_BUFFER_BIT);
for (int i = 0; i < RenderData->LayerCount; i++) {
gl_data *Data = RenderData->LayerEntry[i];
if (Data->Type == 0) {
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL_RasterizeShape2(&MSBuffer, Data->StrokeData, Data->FillData, Data->StrokeCount, Data->FillCount,
+ Data->T, RenderData->Width, RenderData->Height, RenderData->BytesPerPixel,
+ Data->Width, Data->Height, Data->StrokeCol, Data->FillCol, Data->RenderMode, 0,
+ RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom, StencilLayer);
+ } else if (Data->Type == 1) {
+ GL_BlitStencil(&MSBuffer, Data->StrokeData, Data->FillData, Data->StrokeCount, Data->FillCount,
+ Data->T, RenderData->Width, RenderData->Height, RenderData->BytesPerPixel,
+ Data->Width, Data->Height, Data->StrokeCol, Data->FillCol, Data->RenderMode, 0,
+ RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom, StencilLayer, GL_INCR);
+ StencilLayer++;
+ } else if (Data->Type == 2) {
+ GL_BlitStencil(&MSBuffer, Data->StrokeData, Data->FillData, Data->StrokeCount, Data->FillCount,
Data->T, RenderData->Width, RenderData->Height, RenderData->BytesPerPixel,
Data->Width, Data->Height, Data->StrokeCol, Data->FillCol, Data->RenderMode, 0,
- RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom, KeepStencil);
+ RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom, StencilLayer, GL_DECR);
+ StencilLayer--;
} else {
- // GL_BlitStencil(&MSBuffer, Data->StrokeData, Data->FillData, Data->StrokeCount, Data->FillCount,
- // Data->T, RenderData->Width, RenderData->Height, RenderData->BytesPerPixel,
- // Data->Width, Data->Height, Data->StrokeCol, Data->FillCol, Data->RenderMode, 0,
- // RenderData->ViewportSize, RenderData->UIPos, RenderData->UIZoom);
- // KeepStencil = true;
+ Assert(0);
}
}
+ // stencil buffer testing not needed
+ glDisable(GL_STENCIL_TEST);
+ glStencilMask(0xFF);
+ glStencilFunc(GL_ALWAYS, 0, 0xFF);
+
+
glBindFramebuffer(GL_READ_FRAMEBUFFER, MSBuffer.FramebufferObject);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
// The multisample framebuffer allows us to conveniently clip to the comp bounds.
@@ -322,9 +345,9 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd)
GL_DeleteHWBuffer(&MSBuffer);
}
-static void
+static uint8 *
Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDrawList *draw_list, uint8 *PointBuffer, gl_viewport_data *RenderData,
- sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, layer_transforms *ExtraT,
+ sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, layer_transforms ExtraT,
sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray, uint32 CompIndex, int32 Frame_Current)
{
block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, CompIndex);
@@ -342,46 +365,6 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
sorted_layer_array SortEntry = SortedLayerStart[i];
uint32 Index_Physical = SortEntry.Block_Layer_Index;
block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
- if (Layer->IsPrecomp) {
- *ExtraT = Layer_GetTransforms(Layer);
- if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) {
- Transform_ApplyInteractive(State->Interact_Transform, &ExtraT->x, &ExtraT->y, &ExtraT->rotation, &ExtraT->scale);
- }
- if (State->Interact_Active == interact_type_viewport_transform_gizmo && Layer->IsSelected == 1) {
- Transform_ApplyInteractive(State->Interact_Transform, &ExtraT->x, &ExtraT->y, &ExtraT->rotation, &ExtraT->scale);
- }
- if (State->Interact_Active == interact_type_viewport_slide && Layer->IsSelected == 1) {
- Assert(0);
- // Transform_ApplySlide((v2 *)&State->Interact_Offset[0], &T);
- }
- if (State->Interact_Active == interact_type_viewport_duplicate && SortEntry.IsFake) {
- Assert(Layer->IsSelected);
- ExtraT->x += State->Interact_Offset[0];
- ExtraT->y += State->Interact_Offset[1];
- }
- gl_data *GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)PointBuffer;
- RenderData->LayerCount++;
- PointBuffer += sizeof(gl_data);
- int Width = 0, Height = 0;
- Layer_GetDimensions(Memory, Layer, &Width, &Height);
- GL_Data->Type = 1;
- GL_Data->T = *ExtraT;
- GL_Data->Width = Width;
- GL_Data->Height = Height;
- GL_Data->FillData = PointBuffer;
- real32 CompVerts[16] = { 0.f, 0.f, 0.f, 0.f,
- 0.f, (real32)Height, 0.f, 0.f,
- (real32)Width, (real32)Height, 0.f, 0.f,
- (real32)Width, 0.f, 0.f, 0.f };
- for (int a = 0; a < 16; a++) {
- *(real32 *)PointBuffer = CompVerts[a];
- PointBuffer += sizeof(real32);
- }
- GL_Data->FillCount = 4;
- Render_UI(File, State, Memory, UI, draw_list, PointBuffer, RenderData,
- SortedCompArray, SortedLayerArray, ExtraT,
- SortedPropertyStart, SortedKeyframeArray, Layer->Block_Source_Index, Frame_Current);
- }
int32 Frame_Start = Layer->Frame_Start;
int32 Frame_End = Layer->Frame_End;
int32 Frame_Offset = Layer->Frame_Offset;
@@ -394,8 +377,6 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
if (Frame_Start_Abs <= Frame_Current &&
Frame_End_Abs > Frame_Current && Layer->IsVisible)
{
- void *Data = PointBuffer;
-
layer_transforms T = Layer_GetTransforms(Layer);
if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) {
Transform_ApplyInteractive(State->Interact_Transform, &T.x, &T.y, &T.rotation, &T.scale);
@@ -412,11 +393,12 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
T.x += State->Interact_Offset[0];
T.y += State->Interact_Offset[1];
}
- if (ExtraT->scale != 0) {
- T = Transform_Add(T, *ExtraT, Comp->Width, Comp->Height);
+ if (ExtraT.scale != 0) {
+ T = Transform_Add(T, ExtraT, Comp->Width, Comp->Height);
}
if (Layer->IsShapeLayer) {
+ void *Data = PointBuffer;
shape_layer *Shape = &Layer->Shape;
shape_options ShapeOpt = Layer->ShapeOpt;
if (ShapeOpt.Visibility == 1 && ShapeOpt.StrokeWidth <= 0.0f)
@@ -444,7 +426,68 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
*GL_Data = { 0, Data_Stroke, StrokeCount, ShapeOpt.StrokeCol,
Data_Fill, NumberOfVerts, ShapeOpt.FillCol,
T, Shape->Width, Shape->Height, Visibility };
- } else if (!Layer->IsPrecomp) {
+ } else if (Layer->IsPrecomp) {
+
+ layer_transforms NewExtraT = Layer_GetTransforms(Layer);
+ if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected == 1) {
+ Transform_ApplyInteractive(State->Interact_Transform, &NewExtraT.x, &NewExtraT.y, &NewExtraT.rotation, &NewExtraT.scale);
+ }
+ if (State->Interact_Active == interact_type_viewport_transform_gizmo && Layer->IsSelected == 1) {
+ Transform_ApplyInteractive(State->Interact_Transform, &NewExtraT.x, &NewExtraT.y, &NewExtraT.rotation, &NewExtraT.scale);
+ }
+ if (State->Interact_Active == interact_type_viewport_slide && Layer->IsSelected == 1) {
+ Assert(0);
+ // Transform_ApplySlide((v2 *)&State->Interact_Offset[0], &T);
+ }
+ if (State->Interact_Active == interact_type_viewport_duplicate && SortEntry.IsFake) {
+ Assert(Layer->IsSelected);
+ NewExtraT.x += State->Interact_Offset[0];
+ NewExtraT.y += State->Interact_Offset[1];
+ }
+ if (ExtraT.scale != 0) {
+ ExtraT = Transform_Add(NewExtraT, ExtraT, Comp->Width, Comp->Height);
+ } else {
+ ExtraT = NewExtraT;
+ }
+ gl_data *GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)PointBuffer;
+ RenderData->LayerCount++;
+ PointBuffer += sizeof(gl_data);
+ int Width = 0, Height = 0;
+ Layer_GetDimensions(Memory, Layer, &Width, &Height);
+ GL_Data->Type = 1;
+ GL_Data->T = ExtraT;
+ GL_Data->Width = Width;
+ GL_Data->Height = Height;
+ GL_Data->FillData = PointBuffer;
+ real32 CompVerts[16] = { 0.f, 0.f, 0.f, 0.f,
+ 0.f, (real32)Height, 0.f, 0.f,
+ (real32)Width, (real32)Height, 0.f, 0.f,
+ (real32)Width, 0.f, 0.f, 0.f };
+ for (int a = 0; a < 16; a++) {
+ *(real32 *)PointBuffer = CompVerts[a];
+ PointBuffer += sizeof(real32);
+ }
+ GL_Data->FillCount = 4;
+
+ PointBuffer = Render_UI(File, State, Memory, UI, draw_list, PointBuffer, RenderData,
+ SortedCompArray, SortedLayerArray, ExtraT,
+ SortedPropertyStart, SortedKeyframeArray, Layer->Block_Source_Index, Frame_Current);
+
+ GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)PointBuffer;
+ RenderData->LayerCount++;
+ PointBuffer += sizeof(gl_data);
+ GL_Data->Type = 2;
+ GL_Data->T = ExtraT;
+ GL_Data->Width = Width;
+ GL_Data->Height = Height;
+ GL_Data->FillData = PointBuffer;
+ for (int a = 0; a < 16; a++) {
+ *(real32 *)PointBuffer = CompVerts[a];
+ PointBuffer += sizeof(real32);
+ }
+ GL_Data->FillCount = 4;
+ } else {
+ Assert(0);
int Width = 0, Height = 0;
Layer_GetDimensions(Memory, Layer, &Width, &Height);
@@ -456,13 +499,13 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr
GL_Data->Width = Width;
GL_Data->Height = Height;
GL_Data->T = T;
- } else {
- }
+ }
}
}
Assert((PointBuffer - (uint8 *)Memory->Slot[B_PointData].Address) < Memory->Slot[B_PointData].Size);
+ return PointBuffer;
}
static void *
@@ -950,6 +993,7 @@ int main(int argc, char *argv[]) {
State->UpdateFrame = true;
State->MostRecentlySelectedLayer = 0;
}
+
#else
// uint16 SourceIndex = Source_Generate(File, State, &Memory, (void *)"../asset/yu.webm");
// block_source *Source = (block_source *)Memory_Block_AddressAtIndex(&Memory, F_Sources, SourceIndex);