summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index 844a6f7..59d0e3a 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,4 +1,3 @@
-#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#if WINDOWS
@@ -6,6 +5,15 @@
#include <sys/mman.h>
#endif
+// TODO(fox): Switch all thread code to SDL!
+#if WINDOWS
+#else
+#if THREADED
+#include <pthread.h>
+#else
+#endif
+#endif
+
#if ARM
#include <arm_neon.h>
#else
@@ -15,7 +23,11 @@
#include "imgui/imgui.h"
#include "imgui/backends/imgui_impl_sdl.h"
#include "imgui/backends/imgui_impl_opengl3.h"
+#if WINDOWS
+#include <SDL.h>
+#else
#include <SDL2/SDL.h>
+#endif
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <SDL_opengles2.h>
#else
@@ -104,7 +116,10 @@ SDL_sem *Semaphore;
#include "effects.cpp"
#include "keyframes.cpp"
#include "layer.cpp"
+#if THREADED
#include "threading.cpp"
+#else
+#endif
#include "prenderer.cpp"
#include "video.cpp"
#include "createcalls.cpp"
@@ -416,7 +431,7 @@ int main(int argc, char *argv[]) {
RenderInfo.File = &File;
RenderInfo.State = &State;
RenderInfo.CompBuffer = &CompBuffer;
-
+#if THREADED
thread_info ThreadInfo[7];
for (int i = 0; i < 7; i++) {
@@ -425,7 +440,7 @@ int main(int argc, char *argv[]) {
ThreadInfo[i].RenderInfo = &RenderInfo;
thread[i] = SDL_CreateThread(TestThread, str, &ThreadInfo[i]);
}
-
+#endif
sdl_input Input;
sdl_input OldInput;
@@ -564,6 +579,7 @@ int main(int argc, char *argv[]) {
State.UpdateFrame = 0;
}
+#if THREADED
if (IsRendering) {
while (CompletedJobs != 16) {
CheckQueue(RenderInfo, 8);
@@ -586,6 +602,18 @@ int main(int argc, char *argv[]) {
}
}
+#else
+#if PACKEDRGB
+ Unpack4x4Chunk(&CompBuffer);
+ // SSE_CopyToBuffer(CompBuffer);
+#else
+ PackBitmapRGB(&CompBuffer);
+#endif
+ EndRenderState(&State);
+ glBindTexture(GL_TEXTURE_2D, textureID);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, CompBuffer.Width, CompBuffer.Height, GL_RGBA, GL_UNSIGNED_BYTE,
+ CompBuffer.EffectBuffer);
+#endif
ImGui::Render();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);