initial commit
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 24 Jul 2016 16:27:23 +0000 (19:27 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 24 Jul 2016 16:27:23 +0000 (19:27 +0300)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
NOTES [new file with mode: 0644]
src/app.h [new file with mode: 0644]
src/main.cc [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..1e4dfcb
--- /dev/null
@@ -0,0 +1,4 @@
+*.o
+*.swp
+*.d
+vrfileman
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..5d666ac
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,51 @@
+# ---- options ----
+PREFIX = /usr/local
+opt = -O0
+dbg = -g
+# -----------------
+
+src = $(wildcard src/*.cc)
+obj = $(src:.cc=.o)
+dep = $(obj:.o=.d)
+bin = vrfileman
+
+warn = -pedantic -Wall
+
+CXXFLAGS = $(warn) $(opt) $(dbg) $(inc) `pkg-config --cflags sdl2`
+LDFLAGS = $(libgl) -lgmath `pkg-config --libs sdl2`
+
+
+ifeq ($(shell uname -s), Darwin)
+       libgl = -framework OpenGL -lGLEW
+else
+       libgl = -lGL -lGLEW
+endif
+
+
+$(bin): $(obj)
+       $(CXX) -o $@ $(obj) $(LDFLAGS)
+
+-include $(dep)
+
+%.d: %.c
+       @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
+
+%.d: %.cc
+       @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@
+
+.PHONY: clean
+clean:
+       rm -f $(obj) $(bin)
+
+.PHONY: cleandep
+cleandep:
+       rm -f $(dep)
+
+.PHONY: install
+install: $(bin)
+       mkdir -p $(DESTDIR)$(PREFIX)/bin
+       cp $(bin) $(DESTDIR)$(PREFIX)/bin/$(bin)
+
+.PHONY: uninstall
+uninstall:
+       rm -f $(DESTDIR)$(PREFIX)/bin/$(bin)
diff --git a/NOTES b/NOTES
new file mode 100644 (file)
index 0000000..396a0e4
--- /dev/null
+++ b/NOTES
@@ -0,0 +1,12 @@
+- cyberpunk aesthetic: don't forget the mandatory grids and purple-ish horizon
+  gradients.
+- point of view inside a directory node
+- files in this directory are geometric shapes around the user
+- some gesture for scrolling through them like in a tunnel if they are more than
+  fit in the screen
+- point with laser sight to files, and grab them, at which point show a minature
+  of each file next to the manipulator
+- subdirectories as links going off to the bottom somehow, select them to
+  traverse the tree
+- parent directory link going off above...
+- when sorting files, do transition and move them around.
diff --git a/src/app.h b/src/app.h
new file mode 100644 (file)
index 0000000..ee34a44
--- /dev/null
+++ b/src/app.h
@@ -0,0 +1,22 @@
+#ifndef APP_H_
+#define APP_H_
+
+extern int win_width, win_height;
+extern float win_aspect;
+extern long time_msec;
+
+bool app_init(int argc, char **argv);
+void app_cleanup();
+
+void app_draw();
+void app_reshape(int x, int y);
+void app_keyboard(int key, bool pressed);
+void app_mouse_button(int bn, bool pressed, int x, int y);
+void app_mouse_motion(int x, int y);
+
+// the following functions are implemented by the window system backend
+void app_redraw();
+void app_swap_buffers();
+long app_get_msec();
+
+#endif // APP_H_
diff --git a/src/main.cc b/src/main.cc
new file mode 100644 (file)
index 0000000..66e8e98
--- /dev/null
@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <SDL2/SDL.h>
+#include "app.h"
+
+static void process_event(SDL_Event *ev);
+
+static SDL_Window *win;
+static SDL_GLContext ctx;
+static bool redraw_pending = true;
+static bool quit;
+
+int main(int argc, char **argv)
+{
+       if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) {
+               fprintf(stderr, "failed to initialize SDL\n");
+               return 1;
+       }
+
+       int x = SDL_WINDOWPOS_UNDEFINED;
+       int y = SDL_WINDOWPOS_UNDEFINED;
+       unsigned int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
+       win_width = 1280;
+       win_height = 800;
+       if(!(win = SDL_CreateWindow("vrfileman", x, y, win_width, win_height, flags))) {
+               fprintf(stderr, "failed to create window\n");
+               return 1;
+       }
+
+       SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+       SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+       SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+       SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+       SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
+
+       if(!(ctx = SDL_GL_CreateContext(win))) {
+               fprintf(stderr, "failed to create OpenGL context\n");
+               return 1;
+       }
+       SDL_GL_GetDrawableSize(win, &win_width, &win_height);
+       app_reshape(win_width, win_height);
+
+       while(!quit) {
+               SDL_Event ev;
+
+               if(!redraw_pending) {
+                       if(!SDL_WaitEvent(0)) {
+                               fprintf(stderr, "error while waiting for events\n");
+                               break;
+                       }
+               }
+
+               time_msec = app_get_msec();
+               while(SDL_PollEvent(&ev)) {
+                       process_event(&ev);
+                       if(quit) goto break_evloop;
+               }
+
+               if(redraw_pending) {
+                       redraw_pending = false;
+                       app_draw();
+               }
+       }
+break_evloop:
+
+       app_cleanup();
+       SDL_Quit();
+       return 0;
+}
+
+void app_redraw()
+{
+       redraw_pending = true;
+}
+
+void app_swap_buffers()
+{
+       SDL_GL_SwapWindow(win);
+}
+
+long app_get_msec()
+{
+       return SDL_GetTicks();
+}