From 84aa5c466f57c9541243dbaa7442fdee734af7b7 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Sat, 18 Feb 2023 14:25:13 -0500 Subject: gl sampling test --- build.sh | 2 +- src/gl_calls.cpp | 17 ++++++----------- src/main.cpp | 35 ++++++++++++++++++++++++++--------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/build.sh b/build.sh index c2a90f7..10f5929 100755 --- a/build.sh +++ b/build.sh @@ -109,7 +109,7 @@ clang src/main.cpp -MJ bin/main.json $WARNING_FLAGS $OPTIMIZATION $ADDITIONAL_FL -lm $(pkg-config --cflags --libs $FFMPEG_LIBS) if [[ "$DEBUG" == 1 ]]; then -echo "c ec compiled" > /tmp/control_pipe.dat + pidof gf2 && echo "c ec compiled" > /tmp/control_pipe.dat fi diff --git a/src/gl_calls.cpp b/src/gl_calls.cpp index 39dba50..82e8be2 100644 --- a/src/gl_calls.cpp +++ b/src/gl_calls.cpp @@ -118,23 +118,18 @@ const char *BlendFragmentShaderSource = "#version 330 core\n" "uniform sampler2D Texture;\n" "uniform sampler2D Texture1;\n" "uniform vec3 InputCol;\n" -"uniform float Rad;\n" +"uniform vec2 ScreenDimensions;\n" "void main()\n" "{\n" -" float Rada = Rad;\n" -" vec2 XRotation = vec2(cos(Rada), sin(Rada));\n" -" vec2 YRotation = vec2(sin(Rada), -cos(Rada));\n" -" vec2 XAxis = (TexCoord.x - 0.5) * XRotation;\n" -" vec2 YAxis = (TexCoord.y - 0.5) * YRotation;\n" -" vec2 NewCoord = vec2(0.5, 0.5) + vec2(XAxis + YAxis);\n" +" vec2 NewCoord = gl_FragCoord.xy / ScreenDimensions;\n" " vec4 Col = texture(Texture, TexCoord);\n" " vec4 Dest = texture(Texture1, NewCoord);\n" " FragColor = Dest + Col;\n" " FragColor = ((1.0f - Dest * 2) * Col * Col) + (Dest * 2 * Col);\n" -" FragColor.a = Col.a;\n" -" FragColor = Col + Dest;\n" "}\0"; +// " vec2 NewCoord = vec2(0.5, 0.5) + vec2(XAxis + YAxis);\n" + static void GL_InitDefaultShader(uint32 *VertexShader, const char *VertexShaderSource, uint32 *FragmentShader, const char *FragmentShaderSource, uint32 *ShaderProgram) @@ -439,8 +434,8 @@ GL_RasterizeShape2(gl_effect_layer *TestM, gl_effect_layer *TestM2, void *Stroke glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, TestM2->FramebufferObject); - glBlitFramebuffer(0, 0, 2000, 2000, - 0, 0, 2000, 2000, + glBlitFramebuffer(0, 0, 3200, 1720, + 0, 0, 3200, 1720, GL_COLOR_BUFFER_BIT, GL_LINEAR); glBindFramebuffer(GL_FRAMEBUFFER, TestM->FramebufferObject); diff --git a/src/main.cpp b/src/main.cpp index b144942..91a8ef2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -811,6 +811,19 @@ Render_UI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDr v2 Pos = V2(T.x, T.y); real32 Scale = T.scale; + v2 TexCoord = V2(0.5, 0.5); + + float Rada = -Rad;; + v2 XRotation = V2(cos(Rada), sin(Rada)); + v2 YRotation = V2(sin(Rada), -cos(Rada)); + v2 XAxis = (TexCoord.x - Anchor.x) * XRotation; + v2 YAxis = (TexCoord.y - Anchor.y) * YRotation; + v2 CompUV = Anchor + (XAxis + YAxis); + v2 ScreenPos = UIOffset + (CompUV * UIZoom); + v2 ScreenUV = ScreenPos / ScreenDimensions; + v2 ScreenPos2 = UIOffset + (TexCoord * UIZoom); + v2 ScreenUV2 = ScreenPos / ScreenDimensions; + for (int a = 0; a < 4; a++) { real32 *PointX = &CompVerts[(a*6)]; @@ -1132,7 +1145,7 @@ int main(int argc, char *argv[]) { global_memory GlobalMemory = {}; - GlobalMemory.Size = ((uint64)8 * 1024 * 1024 * 1024); + GlobalMemory.Size = ((uint64)1 * 1024 * 1024 * 1024); GlobalMemory.CurrentPosition = 0; #if WINDOWS @@ -1167,7 +1180,7 @@ int main(int argc, char *argv[]) { Memory_InitTable(&GlobalMemory, &Memory, (uint64)5 * 1024 * 1024, B_Thumbnails, "Thumbnails"); Memory_InitTable(&GlobalMemory, &Memory, (uint64)5 * 1024 * 1024, B_PointData, "Point data"); Memory_InitTable(&GlobalMemory, &Memory, (uint64)128 * 1024 * 1024, B_ScratchSpace, "Scratch"); - Memory_InitTable(&GlobalMemory, &Memory, (uint64)5400 * 1024 * 1024, B_CachedBitmaps, "Cached bitmap buffer"); + Memory_InitTable(&GlobalMemory, &Memory, (uint64)700 * 1024 * 1024, B_CachedBitmaps, "Cached bitmap buffer"); uint8 *Test = (uint8 *)Memory.Slot[B_ScratchSpace].Address + Memory.Slot[B_ScratchSpace].Size + 2; *Test = 30; @@ -1285,6 +1298,8 @@ int main(int argc, char *argv[]) { #if DEBUG #if ARM uint32 ScreenSize[2] = {(uint32)(2560/1.2), (uint32)(1600/1.2)}; +#elif WINDOWS + real32 ScreenSize[2] = {3840/1.6, 2160/1.6}; #else real32 ScreenSize[2] = {3840/1.2, 2160/1.2}; #endif @@ -1438,7 +1453,7 @@ int main(int argc, char *argv[]) { while (State->IsRunning) { - // uint64 StartTime = GetCPUTime(); + uint64 StartTime = GetCPUTime(); uint64 PerfFrequency = SDL_GetPerformanceFrequency(); uint64 PerfStart = SDL_GetPerformanceCounter(); @@ -1529,9 +1544,9 @@ int main(int argc, char *argv[]) { // TODO(fox): Do the same thing with the timeline and viewport to // reduce wasted rendering further; for now I am at least pausing all // UI when no inputs happen. - // uint64 InputStart = GetCPUTime(); + uint64 InputStart = GetCPUTime(); State->UpdateScreen += Main_InputTest(File, State, &Memory, Sorted, &File->UI, window, textureID); - // uint64 InputTime = GetCPUTime() - InputStart; + uint64 InputTime = GetCPUTime() - InputStart; if (State->IsPlaying) { block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(&Memory, F_Precomps, File->PrincipalCompIndex); @@ -1634,7 +1649,7 @@ int main(int argc, char *argv[]) { // frames, but we'd have to make sure the pop order stays the same in all scenarios. Assert(Debug.ScratchState == 0); - // uint64 RenderStart = GetCPUTime(); + uint64 RenderStart = GetCPUTime(); bool32 UpdateScreen = 0; if (State->IsPlaying && State->HotFramePerf > 1 && FullyCached) { uint64 RenderTime = SDL_GetPerformanceCounter() - State->HotFramePerf; @@ -1651,7 +1666,7 @@ int main(int argc, char *argv[]) { UpdateScreen = 1; } } - // uint64 RenderTime = GetCPUTime() - RenderStart; + uint64 RenderTime = GetCPUTime() - RenderStart; if (State->HotFramePerf == 1) { State->HotFramePerf = SDL_GetPerformanceCounter(); @@ -1673,9 +1688,11 @@ int main(int argc, char *argv[]) { SDL_Delay((uint64)(TargetMS - FrameMS)); } - // uint64 TotalTime = GetCPUTime() - StartTime; + uint64 TotalTime = GetCPUTime() - StartTime; // printf("TOTAL: %.2lu, (%.2f ms) - INPUTS: %.2lu - RENDERING: %.2lu\n", PerfTime, FrameMS, InputTime, RenderTime); - // printf("TOTAL: %.2lu - INPUTS: %.2lu (%.2f) - RENDERING: %.2lu (%.2f)\n", TotalTime, InputTime, (real64)InputTime / TotalTime, RenderTime, (real64)RenderTime / TotalTime); +#if DEBUG + printf("TOTAL: %.2lu (%.2f ms) - INPUTS: %.2lu (%.2f) - RENDERING: %.2lu (%.2f)\n", TotalTime, FrameMS, InputTime, (real64)InputTime / TotalTime, RenderTime, (real64)RenderTime / TotalTime); +#endif // printf("TOTAL: %.2lu, (%.2f ms) - RENDERING: %.2lu\n", PerfTime, FrameMS, PerfTime); } -- cgit v1.2.3