diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 116 |
1 files changed, 7 insertions, 109 deletions
@@ -34,6 +34,7 @@ #include "defines.h" #include "my_math.h" +#include "structs.h" #include "main.h" #include "debug.h" #include "functions.h" @@ -73,7 +74,7 @@ SDL_sem *Semaphore; static void MainFunction(main_sdl *Main, memory *Memory, project_state *State, project_data *File, - cache_pool *Cache, comp_buffer *CompBuffer) + comp_buffer *CompBuffer) { Bitmap_Clear(CompBuffer->PackedBuffer, CompBuffer->Width, CompBuffer->Height, CompBuffer->BytesPerPixel); Bitmap_Clear(CompBuffer->UnpackedBuffer, CompBuffer->Width, CompBuffer->Height, CompBuffer->BytesPerPixel); @@ -99,106 +100,6 @@ MainFunction(main_sdl *Main, memory *Memory, QueueCurrentFrame(File, CompBuffer, State); } -#if 0 -static void -MainFunction(main_sdl *Main, project_debug *D, memory *Memory, sdl_input *Input, sdl_input *OldInput, - project_state *State, brush_tool *Brush, project_data *File, - cache_pool *Cache, pixel_buffer *CompBuffer) -{ - ClearBuffer(CompBuffer); - - if (Cache->Frame[File->CurrentFrame].Cached) { - FetchCache(&Cache->Frame[File->CurrentFrame], CompBuffer); - } else { - for (int i = 0; i < File->NumberOfLayers; i++) { - if (File->Layer[i]->Raster.OriginalBuffer) { - for (int p = 0; p < File->Layer[i]->NumberOfEffects; p++) { - for (int o = 0; o < File->Layer[i]->Effect[p].NumberOfProperties; o++) { - CalculateKeyframesLinearly(File->CurrentFrame, &File->Layer[i]->Effect[p].Property[o]); - } - } - for (int r = 0; r < AmountOf(File->Layer[i]->Property); r++) { - CalculateKeyframesLinearly(File->CurrentFrame, &File->Layer[i]->Property[r]); - } - if (File->Layer[i]->Raster.ToUpdate) { - UpdateEffects(File->Layer[i], Memory); - File->Layer[i]->Raster.ToUpdate = true; - } - } - } - - if (State->DebugDisableCache) { - RenderCurrentFrame(File, CompBuffer, State); - } else { - if (Cache->Interact == Clear) { - Cache->Intermediate[0].Cached = 0; - Cache->Intermediate[1].Cached = 0; - Cache->Intermediate[2].Cached = 0; - Cache->Interact = Inactive; - } - if (Cache->Interact == Active) { - if (!Cache->Intermediate[0].Address) { - Cache->Intermediate[0].Address = (uint64 *)Memory->Address + Memory->CurrentPosition; - Memory->CurrentPosition += File->Width * File->Height * 4; - Cache->Intermediate[1].Address = (uint64 *)Memory->Address + Memory->CurrentPosition; - Memory->CurrentPosition += File->Width * File->Height * 4; - Cache->Intermediate[2].Address = (uint64 *)Memory->Address + Memory->CurrentPosition; - Memory->CurrentPosition += File->Width * File->Height * 4; - } - pixel_buffer TempBuffer = *CompBuffer; - if (!Cache->Intermediate[0].Cached) { - TempBuffer.OriginalBuffer = Cache->Intermediate[0].Address; - ClearBuffer(&TempBuffer); - for (int i = 0; i < Cache->InteractIndex; i++) { - // RenderLayer(File->LayerPTR[i], &TempBuffer, State); - // RenderCurrentFrame(File->LayerPTR[Cache->InteractIndex], &TempBuffer, State); - } - Cache->Intermediate[0].Cached = 1; - } - TempBuffer.OriginalBuffer = Cache->Intermediate[1].Address; - ClearBuffer(&TempBuffer); - // RenderLayer(File->LayerPTR[Cache->InteractIndex], &TempBuffer, State); - // RenderCurrentFrame(File->LayerPTR[Cache->InteractIndex], &TempBuffer, State); - if (!Cache->Intermediate[2].Cached) { - TempBuffer.OriginalBuffer = Cache->Intermediate[2].Address; - ClearBuffer(&TempBuffer); - for (int i = Cache->InteractIndex + 1; i < File->NumberOfLayers; i++) { - // RenderLayer(File->LayerPTR[i], &TempBuffer, State); - // RenderCurrentFrame(File->LayerPTR[Cache->InteractIndex], &TempBuffer, State); - } - Cache->Intermediate[2].Cached = 1; - } - InteractToComp(CompBuffer, Cache); - } else { - for (int i = 0; i < File->NumberOfLayers; i++) { - } - } - if (!Cache->Interact) { - if (!Cache->Frame[File->CurrentFrame].Address) { - Cache->Frame[File->CurrentFrame].Address = (uint64 *)Memory->Address + Memory->CurrentPosition; - Memory->CurrentPosition += File->Width * File->Height * 4; - } - CacheFrame(&Cache->Frame[File->CurrentFrame], CompBuffer); - Cache->Frame[File->CurrentFrame].Cached = true; - } else { - Cache->Frame[File->CurrentFrame].Cached = false; - } - } - } -} -#endif - - -static void -DebugPrintMemoryUsage(memory Memory) -{ - for (int i = 0; i < 8; i++) { - memory_table Table = Memory.Slot[i]; - printf("%s: %li bytes, %li kb\n", Table.Name, Table.CurrentPosition, Table.CurrentPosition / 1024); - } -} - - int main(int argc, char *argv[]) { global_memory GlobalMemory = {}; @@ -249,8 +150,8 @@ int main(int argc, char *argv[]) { #endif project_data File = {}; - File.Width = 1280; - File.Height = 720; + File.Width = 1920; + File.Height = 1080; File.NumberOfFrames = 65; File.FPS = 30; File.CurrentFrame = 1; @@ -279,9 +180,6 @@ int main(int argc, char *argv[]) { CompBuffer.PackedBuffer = Layer_AllocateBitmap(&Memory, CompBuffer.Width, CompBuffer.Height, CompBuffer.BytesPerPixel); CompBuffer.UnpackedBuffer = Layer_AllocateBitmap(&Memory, CompBuffer.Width, CompBuffer.Height, CompBuffer.BytesPerPixel); - cache_pool Cache = {}; - Cache.Interact = Inactive; - ui UI = {}; // shm_unlink("/testl"); @@ -385,8 +283,8 @@ int main(int argc, char *argv[]) { return -1; } - TestGL_InitDefaultShader(); - TestGL_InitDefaultVerts(); + GL_InitDefaultShader(); + GL_InitDefaultVerts(); SDL_GL_MakeCurrent(window, gl_context); @@ -487,7 +385,7 @@ int main(int argc, char *argv[]) { // UI never lags. if (State.UpdateFrame && !IsRendering) { - MainFunction(0, &Memory, &State, &File, &Cache, &CompBuffer); + MainFunction(0, &Memory, &State, &File, &CompBuffer); State.UpdateFrame = 0; } |