diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0b57e99..0bac544 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -300,6 +300,8 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd) gl_viewport_data *RenderData = (gl_viewport_data *)cmd->UserCallbackData; gl_effect_layer MSBuffer = {}; + int err = 0; + int A[4] = {}; glGetIntegerv(GL_VIEWPORT, A); @@ -321,6 +323,8 @@ GL_Test(const ImDrawList* parent_list, const ImDrawCmd* cmd) glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); + // printf("%i\n", RenderData->LayerCount); + for (int i = 0; i < RenderData->LayerCount; i++) { gl_data *Data = RenderData->LayerEntry[i]; @@ -619,14 +623,32 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr } T = Transform_TestInteracts(State, Layer, SortEntry, T); + int Width = 0, Height = 0; + Layer_GetDimensions(Memory, Layer, &Width, &Height); + + // quick test to see if layer is outside viewport + if (CompIndex == File->PrincipalCompIndex) { + int MaxDist = (Width > Height) ? Width : Height; + v2 Pos = V2(T.x, T.y); + v2 Min = Pos - V2(MaxDist / 2); + v2 Max = Pos + V2(MaxDist / 2); + ImVec2 ScreenMin = UI->CompPos + (IV2(Min) / ImVec2(Comp->Width, Comp->Height)) * UI->CompZoom; + ImVec2 ScreenMax = UI->CompPos + (IV2(Max) / ImVec2(Comp->Width, Comp->Height)) * UI->CompZoom; + if (ScreenMax.x < RenderData->ViewportMin.x || + ScreenMin.x > RenderData->ViewportMax.x || + ScreenMin.y > RenderData->ViewportMax.y || + ScreenMax.y < RenderData->ViewportMin.y) + continue; + } + if (Layer->IsShapeLayer) { void *Data = PointBuffer; shape_layer *Shape = &Layer->Shape; shape_options ShapeOpt = Layer->ShapeOpt; if (ShapeOpt.StrokeWidth == 0.0f) { if (ShapeOpt.Visibility == 0) - ShapeOpt.Visibility = 2; - if (ShapeOpt.Visibility == 1) + ShapeOpt.Visibility = 1; + if (ShapeOpt.Visibility == 2) continue; } bool32 IsConvex = 0; @@ -639,21 +661,21 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr uint32 StrokeCount = 0; int RenderFlags = 0; - if (ShapeOpt.Visibility == 1 || ShapeOpt.Visibility == 2) { + if (ShapeOpt.Visibility == 0 || 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) { + if (ShapeOpt.Visibility == 0 || ShapeOpt.Visibility == 1) { 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; + RenderFlags |= gl_renderflag_convex; // zero to set the framebuffer to main gl_effect_layer TestL = {}; @@ -674,11 +696,10 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr if (ExtraT.scale != 0) { NewExtraT = Transform_Add(NewExtraT, ExtraT, Comp->Width, Comp->Height); } + 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 = NewExtraT; GL_Data->Width = Width; @@ -713,9 +734,6 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr GL_Data->FillCount = 4; } else { Assert(0); - int Width = 0, Height = 0; - Layer_GetDimensions(Memory, Layer, &Width, &Height); - gl_data *GL_Data = RenderData->LayerEntry[RenderData->LayerCount] = (gl_data *)PointBuffer; RenderData->LayerCount++; PointBuffer += sizeof(gl_data); @@ -1142,16 +1160,17 @@ int main(int argc, char *argv[]) { ScreenSize[1] = 1080; } #endif - SDL_Window* window = SDL_CreateWindow("Event Tester", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, ScreenSize[0], ScreenSize[1], window_flags); + SDL_Window* window = SDL_CreateWindow("Event Tester", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, ScreenSize[0], ScreenSize[1] - 80, window_flags); SDL_GLContext gl_context = SDL_GL_CreateContext(window); SDL_GL_MakeCurrent(window, gl_context); SDL_GL_SetSwapInterval(1); // Enable vsync - if (!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress)) + if (!gladLoadGL((GLADloadfunc)SDL_GL_GetProcAddress)) { printf("Failed to initialize GLAD"); return -1; } + gladInstallGLDebug(); GL_InitDefaultShader(); GL_InitDefaultVerts(); |