diff --git a/Makefile b/Makefile index 2e91abe..ff54bfc 100755 --- a/Makefile +++ b/Makefile @@ -36,14 +36,11 @@ define rm rm $${tmp} endef -define findindir - find $(1) -maxdepth 1 -type f -name '$(2)' -endef - # All other sources edirs != find source -type d -name include -edirs += source/engine source/engine/thirdparty/Nuklear -ehead != $(call findindir, source/engine,*.h) +subengs = sound debug editor 3d +edirs += source/engine $(addprefix source/engine/, $(subengs)) source/engine/thirdparty/Nuklear +ehead != find source/engine source/engine/sound source/engine/debug source/engine/editor -maxdepth 1 -type f -name *.h eobjects != find source/engine -type f -name '*.c' | sed -r 's|^(.*)\.c|$(objprefix)/\1.o|' # Gets all .c files and makes .o refs eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player yugine nuklear) @@ -88,24 +85,33 @@ LINK = $(LIBPATH) $(LINKER_FLAGS) $(ELIBS) MYTAG = $(VER)_$(PTYPE)_$(INFO) +DIST = yugine-$(MYTAG).tar.gz + .PHONY: yugine -yugine: $(objprefix)/source/engine/yugine.o $(ENGINE) - @echo $(CC) +$(BIN)yugine: $(objprefix)/source/engine/yugine.o $(ENGINE) @echo Linking yugine - $(CC) $< $(LINK) -o yugine + $(CC) $< $(LINK) -o $(BIN)yugine @echo Finished build -dist: yugine - mkdir -p bin/dist - cp yugine bin/dist - cp -rf assets/fonts bin/dist - cp -rf source/scripts bin/dist - cp -rf source/shaders bin/dist - tar -czf yugine-$(MYTAG).tar.gz --directory bin/dist . +$(BIN)$(DIST): $(BIN)yugine + @echo Creating distribution zip + @mkdir -p $(BIN)dist + @cp $(BIN)yugine $(BIN)dist + @cp -rf assets/fonts $(BIN)dist + @cp -rf source/scripts $(BIN)dist + @cp -rf source/shaders $(BIN)dist + @tar czf $(DIST) --directory $(BIN)dist . + @mv $(DIST) $(BIN) -install: yugine - cp yugine ~/.local/bin + +dist: $(BIN)$(DIST) + +install: $(BIN)$(DIST) + @echo Unpacking distribution in $(DESTDIR) + @cp $(BIN)$(DIST) $(DESTDIR) + @tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) + @rm $(DESTDIR)/$(DIST) $(ENGINE): $(eobjects) @echo Making library engine.a @@ -122,4 +128,4 @@ $(objprefix)/%.o:%.c clean: @echo Cleaning project @find $(BIN) -type f -delete - @rm -rf source/portaudio/build source/glfw/build + @rm -f *.gz diff --git a/source/engine/3dphysics.c b/source/engine/3d/3dphysics.c similarity index 100% rename from source/engine/3dphysics.c rename to source/engine/3d/3dphysics.c diff --git a/source/engine/3dphysics.h b/source/engine/3d/3dphysics.h similarity index 100% rename from source/engine/3dphysics.h rename to source/engine/3d/3dphysics.h diff --git a/source/engine/3pfollow.c b/source/engine/3d/3pfollow.c similarity index 100% rename from source/engine/3pfollow.c rename to source/engine/3d/3pfollow.c diff --git a/source/engine/3pfollow.h b/source/engine/3d/3pfollow.h similarity index 100% rename from source/engine/3pfollow.h rename to source/engine/3d/3pfollow.h diff --git a/source/engine/light.c b/source/engine/3d/light.c similarity index 100% rename from source/engine/light.c rename to source/engine/3d/light.c diff --git a/source/engine/light.h b/source/engine/3d/light.h similarity index 100% rename from source/engine/light.h rename to source/engine/3d/light.h diff --git a/source/engine/mesh.c b/source/engine/3d/mesh.c similarity index 100% rename from source/engine/mesh.c rename to source/engine/3d/mesh.c diff --git a/source/engine/mesh.h b/source/engine/3d/mesh.h similarity index 100% rename from source/engine/mesh.h rename to source/engine/3d/mesh.h diff --git a/source/engine/model.c b/source/engine/3d/model.c similarity index 100% rename from source/engine/model.c rename to source/engine/3d/model.c diff --git a/source/engine/model.h b/source/engine/3d/model.h similarity index 100% rename from source/engine/model.h rename to source/engine/3d/model.h diff --git a/source/engine/skybox.c b/source/engine/3d/skybox.c similarity index 100% rename from source/engine/skybox.c rename to source/engine/3d/skybox.c diff --git a/source/engine/skybox.h b/source/engine/3d/skybox.h similarity index 100% rename from source/engine/skybox.h rename to source/engine/3d/skybox.h diff --git a/source/engine/static_actor.c b/source/engine/3d/static_actor.c similarity index 100% rename from source/engine/static_actor.c rename to source/engine/3d/static_actor.c diff --git a/source/engine/static_actor.h b/source/engine/3d/static_actor.h similarity index 100% rename from source/engine/static_actor.h rename to source/engine/3d/static_actor.h diff --git a/source/engine/camera.h b/source/engine/camera.h index eea9122..fc4634c 100644 --- a/source/engine/camera.h +++ b/source/engine/camera.h @@ -16,8 +16,7 @@ struct mCamera { void camera_2d_update(struct mCamera *camera, float deltaT); -mfloat_t *getviewmatrix(mfloat_t view[MAT4_SIZE], - const struct mCamera *const camera); +mfloat_t *getviewmatrix(mfloat_t view[MAT4_SIZE], const struct mCamera *const camera); void cam_goto_object(struct mCamera *cam, struct mTransform *transform); void cam_inverse_goto(struct mCamera *cam, struct mTransform *transform); diff --git a/source/engine/debug.c b/source/engine/debug/debug.c similarity index 100% rename from source/engine/debug.c rename to source/engine/debug/debug.c diff --git a/source/engine/debug.h b/source/engine/debug/debug.h similarity index 100% rename from source/engine/debug.h rename to source/engine/debug/debug.h diff --git a/source/engine/debugdraw.c b/source/engine/debug/debugdraw.c similarity index 71% rename from source/engine/debugdraw.c rename to source/engine/debug/debugdraw.c index 2b6f51a..8b7bb43 100644 --- a/source/engine/debugdraw.c +++ b/source/engine/debug/debugdraw.c @@ -37,8 +37,7 @@ void debugdraw_init() glGenVertexArrays(1, &gridVAO); glBindVertexArray(gridVAO); glBindBuffer(GL_ARRAY_BUFFER, gridVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(gridverts), &gridverts, - GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(gridverts), &gridverts, GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); @@ -56,24 +55,12 @@ void draw_line(int x1, int y1, int x2, int y2) x2, y2 }; - glBindBuffer(GL_ARRAY_BUFFER, rectVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(verts), &verts, GL_DYNAMIC_DRAW); - glBindVertexArray(rectVAO); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); - glDrawArrays(GL_LINE_STRIP, 0, 2); + draw_poly(&verts, 2); } void draw_edge(float *points, int n) { - shader_use(rectShader); - glBindBuffer(GL_ARRAY_BUFFER, rectVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n * 2, points, - GL_DYNAMIC_DRAW); - glBindVertexArray(rectVAO); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); - glDrawArrays(GL_LINE_STRIP, 0, n); + draw_poly(points, n); } void draw_circle(int x, int y, float radius, int pixels) @@ -81,10 +68,10 @@ void draw_circle(int x, int y, float radius, int pixels) shader_use(circleShader); float verts[] = { - x - radius, y - radius, -1.f, -1.f, - x + radius, y - radius, 1.f, -1.f, - x - radius, y + radius, -1.f, 1.f, - x + radius, y + radius, 1.f, 1.f + x - radius, y - radius, + x + radius, y - radius, + x - radius, y + radius, + x + radius, y + radius, }; glBindBuffer(GL_ARRAY_BUFFER, circleVBO); @@ -95,7 +82,7 @@ void draw_circle(int x, int y, float radius, int pixels) glBindVertexArray(circleVAO); glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } @@ -111,13 +98,7 @@ void draw_rect(int x, int y, int w, int h) x - hw, y + hh }; - shader_use(rectShader); - glBindBuffer(GL_ARRAY_BUFFER, rectVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(verts), &verts, GL_DYNAMIC_DRAW); - glBindVertexArray(rectVAO); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); - glDrawArrays(GL_LINE_LOOP, 0, 4); + draw_poly(&verts, 4); } void draw_grid(int width, int span) @@ -140,8 +121,7 @@ void draw_poly(float *points, int n) { shader_use(rectShader); glBindBuffer(GL_ARRAY_BUFFER, rectVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n * 2, points, - GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n * 2, points, GL_DYNAMIC_DRAW); glBindVertexArray(rectVAO); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); diff --git a/source/engine/debugdraw.h b/source/engine/debug/debugdraw.h similarity index 100% rename from source/engine/debugdraw.h rename to source/engine/debug/debugdraw.h diff --git a/source/engine/log.c b/source/engine/debug/log.c similarity index 100% rename from source/engine/log.c rename to source/engine/debug/log.c diff --git a/source/engine/log.h b/source/engine/debug/log.h similarity index 100% rename from source/engine/log.h rename to source/engine/debug/log.h diff --git a/source/engine/ed_project.c b/source/engine/editor/ed_project.c similarity index 100% rename from source/engine/ed_project.c rename to source/engine/editor/ed_project.c diff --git a/source/engine/ed_project.h b/source/engine/editor/ed_project.h similarity index 100% rename from source/engine/ed_project.h rename to source/engine/editor/ed_project.h diff --git a/source/engine/editor.c b/source/engine/editor/editor.c similarity index 93% rename from source/engine/editor.c rename to source/engine/editor/editor.c index 055bca8..4dc79e5 100644 --- a/source/engine/editor.c +++ b/source/engine/editor/editor.c @@ -336,7 +336,6 @@ static void edit_input_cb(GLFWwindow *w, int key, int scancode, int action, int break; case GLFW_KEY_F5: - NEGATE(editor.lighting.show); break; case GLFW_KEY_F6: @@ -543,19 +542,6 @@ void editor_project_gui() { NK_MENU_END() - // Shadow map vars - NK_MENU_START(lighting) - - nk_layout_row_dynamic(ctx, 25, 1); - nk_label(ctx, "Directional shadow map", NK_TEXT_LEFT); - - nk_property_float(ctx, "Near plane", -200.f, &near_plane, 200.f, 1.f, 0.01f); - nk_property_float(ctx, "Far plane", -200.f, &far_plane, 200.f, 1.f, 0.01f); - nk_property_float(ctx, "Shadow lookahead", 0.f, &shadowLookahead, 100.f, 1.f, 0.01f); - nk_property_float(ctx, "Plane size", 0.f, &plane_size, 100.f, 1.f, 0.01f); - - NK_MENU_END() - NK_MENU_START(gamesettings) nk_layout_row_dynamic(ctx,25,1); @@ -598,34 +584,6 @@ void editor_project_gui() { NK_MENU_START(debug) - nk_layout_row_dynamic(ctx, 25, 1); - - nk_property_float(ctx, "Camera FOV", 0.1f, &editorFOV, 90.f, 1.f, 0.1f); - nk_property_float(ctx, "Camera Near Plane", 0.1f, &editorClose, 5.f, 0.1f, 0.01f); - nk_property_float(ctx, "Camera Far Plane", 50.f, &editorFar, 10000.f, 1.f,1.f); - - if (nk_tree_push(ctx, NK_TREE_NODE, "Shading mode", NK_MINIMIZED)) { - renderMode = - nk_option_label(ctx, "Lit", renderMode == LIT) ? LIT : renderMode; - renderMode = nk_option_label(ctx, "Unlit", renderMode == UNLIT) - ? UNLIT - : renderMode; - renderMode = nk_option_label(ctx, "Wireframe", renderMode == WIREFRAME) - ? WIREFRAME - : renderMode; - renderMode = nk_option_label(ctx, "Directional shadow map", - renderMode == DIRSHADOWMAP) - ? DIRSHADOWMAP - : renderMode; - nk_tree_pop(ctx); - } - - if (nk_tree_push(ctx, NK_TREE_NODE, "Lighting", NK_MINIMIZED)) { - nk_checkbox_label(ctx, "Shadows", &renderDynamicShadows); - nk_checkbox_label(ctx, "Ambient Occlusion", &renderAO); - nk_tree_pop(ctx); - } - if (nk_tree_push(ctx, NK_TREE_NODE, "Debug Draws", NK_MINIMIZED)) { nk_checkbox_label(ctx, "Gizmos", &renderGizmos); nk_checkbox_label(ctx, "Grid", &showGrid); diff --git a/source/engine/editor.h b/source/engine/editor/editor.h similarity index 99% rename from source/engine/editor.h rename to source/engine/editor/editor.h index f2c9212..6c0f979 100644 --- a/source/engine/editor.h +++ b/source/engine/editor/editor.h @@ -27,7 +27,6 @@ typedef struct { struct editorVars { editor_win stats; editor_win hierarchy; - editor_win lighting; editor_win gamesettings; editor_win viewmode; editor_win debug; diff --git a/source/engine/editorstate.c b/source/engine/editor/editorstate.c similarity index 100% rename from source/engine/editorstate.c rename to source/engine/editor/editorstate.c diff --git a/source/engine/editorstate.h b/source/engine/editor/editorstate.h similarity index 100% rename from source/engine/editorstate.h rename to source/engine/editor/editorstate.h diff --git a/source/engine/input.c b/source/engine/input.c index 2349bd1..bf55e77 100644 --- a/source/engine/input.c +++ b/source/engine/input.c @@ -103,7 +103,7 @@ void win_key_callback(GLFWwindow *w, int key, int scancode, int action, int mods void cursor_hide() { - glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); } void cursor_show() diff --git a/source/engine/openglrender.c b/source/engine/openglrender.c index 7fc451a..651bd67 100644 --- a/source/engine/openglrender.c +++ b/source/engine/openglrender.c @@ -16,38 +16,10 @@ int renderMode = 0; static GLuint UBO; - -static GLuint gridVBO = 0; -static GLuint gridVAO = 0; - -static GLuint quadVAO = 0; -static GLuint quadVBO = 0; - -static GLuint depthMapFBO = 0; -static GLuint depthMap = 0; -const unsigned int SHADOW_WIDTH = 2048, SHADOW_HEIGHT = 2048; - -static struct shader *outlineShader; -static struct shader *modelShader; -static struct shader *shadowShader; - struct shader *spriteShader = NULL; struct shader *animSpriteShader = NULL; static struct shader *textShader; -static struct shader *diffuseShader; -struct sFont *stdFont; - -static struct shader *debugDepthQuad; -static struct shader *debugColorPickShader; -static struct shader *debugGridShader; -static struct shader *debugGizmoShader; - -struct mStaticActor *gizmo; - -float editorFOV = 45.f; -float editorClose = 0.1f; -float editorFar = 1000.f; mfloat_t editorClearColor[4] = { 0.2f, 0.4f, 0.3f, 1.f }; float shadowLookahead = 8.5f; @@ -65,9 +37,6 @@ float gridOpacity = 0.3f; mfloat_t proj[16]; -float near_plane = -100.f, far_plane = 10.f, plane_size = 60.f; - - // Debug render modes bool renderGizmos = false; bool showGrid = true; @@ -116,23 +85,12 @@ void openglInit() sprite_initialize(); debugdraw_init(); - //glEnable(GL_STENCIL_TEST); - - glClearColor(editorClearColor[0], editorClearColor[1], editorClearColor[2], editorClearColor[3]); glEnable(GL_CULL_FACE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //glDisable(GL_DEPTH_TEST); - //glLineWidth(1.3f); - - //glEnable(GL_TEXTURE_3D); - //glEnable(GL_MULTISAMPLE); - //glLineWidth(2); - - glGenBuffers(1, &projUBO); glBindBuffer(GL_UNIFORM_BUFFER, projUBO); glBufferData(GL_UNIFORM_BUFFER, 64, NULL, GL_DYNAMIC_DRAW); @@ -181,467 +139,7 @@ void openglRender(struct window *window) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void openglInit3d(struct window *window) +void BindUniformBlock(GLuint shaderID, const char *bufferName, GLuint bufferBind) { -/* TODO: IMG init doesn't work in C++ - int init =(0x00000001 | 0x00000002); - int initted =IMG_Init(init); - YughLog(0, SDL_LOG_PRIORITY_ERROR, "Init flags: %d\nInitted values: %d ", init, initted); - if ((initted & (IMG_INIT_JPG | IMG_INIT_PNG)) != (IMG_INIT_JPG | IMG_INIT_PNG)) { - YughLog(0, SDL_LOG_PRIORITY_ERROR, - "IMG_Init: Failed to init required jpg and png support! SDL_IMG error: %s", - IMG_GetError()); - - } -*/ - - - - ////// MAKE SHADERS - outlineShader = MakeShader("outlinevert.glsl", "outline.glsl"); - diffuseShader = MakeShader("simplevert.glsl", "albedofrag.glsl"); - modelShader = MakeShader("modelvert.glsl", "modelfrag.glsl"); - shadowShader = MakeShader("shadowvert.glsl", "shadowfrag.glsl"); - - textShader = MakeShader("textvert.glsl", "textfrag.glsl"); - spriteShader = MakeShader("spritevert.glsl", "spritefrag.glsl"); - - debugDepthQuad = MakeShader("postvert.glsl", "debugdepthfrag.glsl"); - debugColorPickShader = - MakeShader("simplevert.glsl", "debugcolorfrag.glsl"); - debugGridShader = MakeShader("gridvert.glsl", "gridfrag.glsl"); - debugGizmoShader = MakeShader("gizmovert.glsl", "gizmofrag.glsl"); - - stdFont = MakeFont("notosans.ttf", 300); - - shader_compile_all(); - - mat4_perspective_fov(proj, editorFOV * DEG2RADS, window->width, - window->height, editorClose, editorFar); - - glEnable(GL_STENCIL_TEST); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_TEXTURE_3D); - glEnable(GL_MULTISAMPLE); - glLineWidth(2); - - //// - // Shadow mapping buffers - //// - glGenFramebuffers(1, &depthMapFBO); - glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); - - glGenTextures(1, &depthMap); - glBindTexture(GL_TEXTURE_2D, depthMap); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, SHADOW_WIDTH, - SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); - - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_TEXTURE_2D, depthMap, 0); - glDrawBuffer(GL_NONE); - //glReadBuffer(GL_NONE); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - //// Universal buffer to hold projection and light coordinates - glGenBuffers(1, &UBO); - glBindBuffer(GL_UNIFORM_BUFFER, UBO); - - glBufferData(GL_UNIFORM_BUFFER, 2 * sizeof(proj), NULL, - GL_STATIC_DRAW); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - glBindBufferRange(GL_UNIFORM_BUFFER, 0, UBO, 0, 2 * sizeof(proj)); - - - glBindBuffer(GL_UNIFORM_BUFFER, UBO); - glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(proj), proj); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - - ////// debug color pick buffer - glGenFramebuffers(1, &debugColorPickBO); - glBindFramebuffer(GL_FRAMEBUFFER, debugColorPickBO); - - glGenTextures(1, &debugColorPickTEX); - glBindTexture(GL_TEXTURE_2D, debugColorPickTEX); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SCREEN_WIDTH, SCREEN_HEIGHT, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, debugColorPickTEX, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - - //////// Create grid - float gridVertices[] = { - -1.f, 0.f, 1.f, 0.f, 1.f, - -1.f, 0.f, -1.f, 0.f, 0.f, - 1.f, 0.f, 1.f, 1.f, 1.f, - 1.f, 0.f, -1.f, 1.f, 0.f, - }; - - glGenVertexArrays(1, &gridVAO); - glGenBuffers(1, &gridVBO); - glBindVertexArray(gridVAO); - glBindBuffer(GL_ARRAY_BUFFER, gridVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(gridVertices), &gridVertices, - GL_STATIC_DRAW); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), - (void *) 0); - glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), - (void *) (3 * sizeof(float))); - - //////// Create post quad - float quadVertices[] = { - // positions // texture Coords - -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, - -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, - 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, - }; - // setup plane VAO - glGenVertexArrays(1, &quadVAO); - glGenBuffers(1, &quadVBO); - glBindVertexArray(quadVAO); - glBindBuffer(GL_ARRAY_BUFFER, quadVBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, - GL_STATIC_DRAW); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), - (void *) 0); - glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), - (void *) (3 * sizeof(float))); - - ////// - - // skybox = new Skybox("skybox"); - - BindUniformBlock(modelShader->id, "Matrices", 0); - BindUniformBlock(outlineShader->id, "Matrices", 0); - // BindUniformBlock(skybox->shader->id, "Matrices", 0); - BindUniformBlock(diffuseShader->id, "Matrices", 0); - - BindUniformBlock(debugGridShader->id, "Matrices", 0); - BindUniformBlock(debugGizmoShader->id, "Matrices", 0); - - shader_use(debugDepthQuad); - shader_setint(debugDepthQuad, "depthMap", 0); - - glBindTexture(GL_TEXTURE_2D, 0); - - //////////// 2D projection - mfloat_t projection[16] = { 0.f }; - mat4_ortho(projection, 0.f, SCREEN_WIDTH, SCREEN_HEIGHT, 1.f, -1.f, - 1.f); - shader_setmat4(textShader, "projection", projection); - shader_setmat4(spriteShader, "projection", projection); - shader_setmat4(debugGizmoShader, "proj", projection); - - - - -} - -void openglRender3d(struct window *window, struct mCamera *mcamera) -{ - //////// SET NEW PROJECTION - // TODO: Make this not happen every frame - mat4_perspective_fov(proj, editorFOV * DEG2RADS, window->width, - window->height, editorClose, editorFar); - - glBindBuffer(GL_UNIFORM_BUFFER, UBO); - glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(proj), proj); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - glEnable(GL_CULL_FACE); - glEnable(GL_DEPTH_TEST); - - ////////// Render a depthmap from the perspective of the directional light - - glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT); - glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); - glCullFace(GL_BACK); - glClear(GL_DEPTH_BUFFER_BIT); - - // Configure matrices with an orthogonal - - mfloat_t lightSpaceMatrix[16] = { 0.f }; - -/* - if (dLight) { - - mfloat_t lightProjection[16] = { 0.f }; - mat4_ortho(lightProjection, -plane_size, plane_size, -plane_size, - plane_size, near_plane, far_plane); - - mfloat_t lookPos[3] = { 0.f }; - mfloat_t cam_fwd[3] = { 0.f }; - vec3_add(lookPos, mcamera->transform.position, - vec3_multiply_f(lookPos, - trans_forward(cam_fwd, - &mcamera->transform), - shadowLookahead)); - lookPos[1] = 0.f; - - mfloat_t lightLookPos[3] = { 0.f }; - mfloat_t light_fwd[3] = { 0.f }; - mat4_look_at(lightView, - vec3_subtract(lightLookPos, lookPos, - trans_forward(light_fwd, - &dLight->light.obj. - transform)), lookPos, UP); - - mat4_multiply(lightSpaceMatrix, lightProjection, lightView); - //lightSpaceMatrix = lightProjection * lightView; - - if (renderDynamicShadows) { - shader_use(shadowShader); - shader_setmat4(shadowShader, "lightSpaceMatrix", - lightSpaceMatrix); - staticactor_draw_shadowcasters(shadowShader); - } - } - */ - ////////////////////////// - - // Back to the normal render - window_makecurrent(window); - - - glCullFace(GL_BACK); - - // Render the color thing for debug picking - glBindFramebuffer(GL_FRAMEBUFFER, debugColorPickBO); - glClearColor(editorClearColor[0], editorClearColor[1], - editorClearColor[2], editorClearColor[3]); - glClear(GL_COLOR_BUFFER_BIT); - shader_use(debugColorPickShader); - staticactor_draw_dbg_color_pick(debugColorPickShader); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - // Clear color and depth - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT); - - if (renderMode == DIRSHADOWMAP) { - // render Depth map to quad for visual debugging - // --------------------------------------------- - shader_use(debugDepthQuad); - shader_setfloat(debugDepthQuad, "near_plane", near_plane); - shader_setfloat(debugDepthQuad, "far_plane", far_plane); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, depthMap); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glBindVertexArray(quadVAO); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - } else if (renderMode == OBJECTPICKER) { - // TODO: This rendering mode - shader_use(debugColorPickShader); - } else { - - glClearColor(editorClearColor[0], editorClearColor[1], - editorClearColor[2], editorClearColor[3]); - glDepthMask(GL_TRUE); - - mfloat_t view[16] = { 0.f }; - getviewmatrix(view, mcamera); - - glBindBuffer(GL_UNIFORM_BUFFER, UBO); - glBufferSubData(GL_UNIFORM_BUFFER, sizeof(view), sizeof(view), - view); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - - switch (renderMode) { - case LIT: - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - - shader_use(modelShader); - -/* - if (dLight) - dlight_prepshader(dLight, modelShader); - - pointlights_prepshader(modelShader); - spotlights_prepshader(modelShader); -*/ - - shader_setvec3(modelShader, "viewPos", - mcamera->transform.position); - shader_setmat4(modelShader, "lightSpaceMatrix", - lightSpaceMatrix); - shader_setint(modelShader, "shadowMap", 12); - glActiveTexture(GL_TEXTURE); - glBindTexture(GL_TEXTURE_2D, depthMap); - staticactor_draw_models(modelShader); - - - break; - - case UNLIT: - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - shader_use(diffuseShader); - staticactor_draw_models(diffuseShader); - - break; - - case WIREFRAME: - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - shader_use(diffuseShader); - staticactor_draw_models(diffuseShader); - - break; - } - - //// skybox - // draw skybox as last - glDepthFunc(GL_LEQUAL); - // skybox->Draw(mcamera); - glDepthFunc(GL_LESS); - - - - - - if (debugDrawPhysics) { - // Render physics world - //dynamicsWorld->debugDrawWorld(); - } - // Draw outline - if (selectedobject != NULL) { - // Draw the selected object outlined - glClearStencil(0); - glClear(GL_STENCIL_BUFFER_BIT); - glStencilFunc(GL_ALWAYS, 1, 0xFF); - glDepthFunc(GL_ALWAYS); - glDepthMask(false); - glColorMask(false, false, false, false); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - glStencilMask(0xFF); - shader_use(diffuseShader); - setup_model_transform(&selectedobject->transform, - diffuseShader, 1.f); - //selectedobject->draw(diffuseShader); - - glStencilFunc(GL_NOTEQUAL, 1, 0xFF); - glDepthMask(true); - glColorMask(true, true, true, true); - glStencilMask(0x00); - shader_use(outlineShader); - setup_model_transform(&selectedobject->transform, - outlineShader, 1.f); - //selectedobject->draw(outlineShader); - - - } - - glDepthFunc(GL_LESS); - glStencilMask(0xFF); - glStencilFunc(GL_ALWAYS, 0, 0xFF); - - } - - ////// TEXT && GUI - // glCullFace(GL_FRONT); - glDepthFunc(GL_ALWAYS); - shader_use(textShader); - shader_setmat4(textShader, "projection", window->projection); - mfloat_t fontpos[2] = { 25.f, 25.f }; - mfloat_t fontcolor[3] = { 0.5f, 0.8f, 0.2f }; - text_settype(stdFont); - renderText("Sample text", fontpos, 0.4f, - fontcolor, -1.f); - - sprite_draw(tsprite); - - glDepthFunc(GL_LESS); - - - ////// Render grid - if (showGrid) { - glDisable(GL_CULL_FACE); - shader_use(debugGridShader); - mfloat_t gmodel[16] = { 0.f }; - mfloat_t gridscale[3] = { 0.f }; - vec3(gridscale, gridScale, gridScale, gridScale); - mat4_multiply_f(gmodel, gmodel, gridScale); - // TODO: Hook into here to make the grid scalable - shader_setmat4(debugGridShader, "model", gmodel); - shader_setvec3(debugGridShader, "smallColor", gridSmallColor); - shader_setvec3(debugGridShader, "bigColor", gridBigColor); - shader_setfloat(debugGridShader, "gridScale", gridScale); - shader_setfloat(debugGridShader, "smallUnit", smallGridUnit); - shader_setfloat(debugGridShader, "bigUnit", bigGridUnit); - shader_setfloat(debugGridShader, "smallThickness", - gridSmallThickness); - shader_setfloat(debugGridShader, "largeThickness", - gridBigThickness); - shader_setfloat(debugGridShader, "opacity", gridOpacity); - glBindVertexArray(gridVAO); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - } - ///// Render gizmos - // These are things that are overlaid on everything else - - - // glBindFramebuffer(GL_FRAMEBUFFER, 0); // back to default - // glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - // glClear(GL_COLOR_BUFFER_BIT); - - // postShader.use(); - // glBindVertexArray(quadVAO); - // glBindTexture(GL_TEXTURE_2D, fboTexture); - // glDrawArrays(GL_TRIANGLES, 0, 6); -} - -void BindUniformBlock(GLuint shaderID, const char *bufferName, - GLuint bufferBind) -{ - glUniformBlockBinding(shaderID, - glGetUniformBlockIndex(shaderID, bufferName), - bufferBind); + glUniformBlockBinding(shaderID, glGetUniformBlockIndex(shaderID, bufferName), bufferBind); } diff --git a/source/engine/openglrender.h b/source/engine/openglrender.h index 919c17a..2a613bb 100644 --- a/source/engine/openglrender.h +++ b/source/engine/openglrender.h @@ -13,9 +13,6 @@ extern struct sprite *tsprite; extern int renderMode; - -extern float editorClose; -extern float editorFar; extern float gridScale; extern float smallGridUnit; extern float bigGridUnit; @@ -26,9 +23,6 @@ extern float gridSmallColor[]; extern float gridOpacity; extern float editorFOV; extern float shadowLookahead; -extern float plane_size; -extern float near_plane; -extern float far_plane; extern char objectName[]; extern GLuint debugColorPickBO; diff --git a/source/engine/dr_flac.h b/source/engine/sound/dr_flac.h similarity index 100% rename from source/engine/dr_flac.h rename to source/engine/sound/dr_flac.h diff --git a/source/engine/dr_mp3.h b/source/engine/sound/dr_mp3.h similarity index 100% rename from source/engine/dr_mp3.h rename to source/engine/sound/dr_mp3.h diff --git a/source/engine/dr_wav.h b/source/engine/sound/dr_wav.h similarity index 100% rename from source/engine/dr_wav.h rename to source/engine/sound/dr_wav.h diff --git a/source/engine/dsp.c b/source/engine/sound/dsp.c similarity index 100% rename from source/engine/dsp.c rename to source/engine/sound/dsp.c diff --git a/source/engine/dsp.h b/source/engine/sound/dsp.h similarity index 100% rename from source/engine/dsp.h rename to source/engine/sound/dsp.h diff --git a/source/engine/iir.c b/source/engine/sound/iir.c similarity index 100% rename from source/engine/iir.c rename to source/engine/sound/iir.c diff --git a/source/engine/iir.h b/source/engine/sound/iir.h similarity index 100% rename from source/engine/iir.h rename to source/engine/sound/iir.h diff --git a/source/engine/mix.c b/source/engine/sound/mix.c similarity index 100% rename from source/engine/mix.c rename to source/engine/sound/mix.c diff --git a/source/engine/mix.h b/source/engine/sound/mix.h similarity index 100% rename from source/engine/mix.h rename to source/engine/sound/mix.h diff --git a/source/engine/music.c b/source/engine/sound/music.c similarity index 100% rename from source/engine/music.c rename to source/engine/sound/music.c diff --git a/source/engine/music.h b/source/engine/sound/music.h similarity index 100% rename from source/engine/music.h rename to source/engine/sound/music.h diff --git a/source/engine/sprite.c b/source/engine/sprite.c index 2ba6e4c..27de345 100644 --- a/source/engine/sprite.c +++ b/source/engine/sprite.c @@ -131,10 +131,6 @@ void sprite_initialize() glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); - - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); } void sprite_draw(struct sprite *sprite) diff --git a/source/engine/window.c b/source/engine/window.c index df9fe9c..8dbf1e1 100644 --- a/source/engine/window.c +++ b/source/engine/window.c @@ -1,4 +1,4 @@ - #include "window.h" +#include "window.h" #include #include "texture.h" #include "log.h" @@ -282,12 +282,14 @@ void window_render(struct window *w) { script_call_sym(w->nuke_cb); nk_end(ctx); nuke_end(); - } else if (w->nuke_gui != NULL) { + } else + +*/if (w->nuke_gui != NULL) { nuke_start(); w->nuke_gui(); nuke_end(); } -*/ + window_swap(w); } diff --git a/source/engine/yugine.c b/source/engine/yugine.c index 823ba80..231c15b 100644 --- a/source/engine/yugine.c +++ b/source/engine/yugine.c @@ -123,15 +123,15 @@ int main(int argc, char **args) { double framet = fmin(fmin(renderMS,physMS),updateMS); - script_dofile("scripts/engine.rb"); - script_dofile("config.rb"); + script_dofile("scripts/engine.scm"); + script_dofile("config.scm"); window_set_icon("icon.png"); if (ed) { editor_init(MakeSDLWindow("Editor", 600, 600, 0)); } else { - script_dofile("game.rb"); + script_dofile("game.scm"); } openglInit(); diff --git a/source/portaudio/bindings/java/scripts/make_header.bat b/source/portaudio/bindings/java/scripts/make_header.bat deleted file mode 100644 index 14fa280..0000000 --- a/source/portaudio/bindings/java/scripts/make_header.bat +++ /dev/null @@ -1,4 +0,0 @@ -REM Generate the JNI header file from the Java code for JPortAudio -REM by Phil Burk - -javah -classpath ../jportaudio/bin -d ../c/src com.portaudio.PortAudio com.portaudio.BlockingStream diff --git a/source/portaudio/cmake_support/template_portaudio.def b/source/portaudio/cmake_support/template_portaudio.def deleted file mode 100644 index 768716d..0000000 --- a/source/portaudio/cmake_support/template_portaudio.def +++ /dev/null @@ -1,61 +0,0 @@ -; $Id: $ -; -; !!! @GENERATED_MESSAGE@ !!! -EXPORTS - -; -Pa_GetVersion @1 -Pa_GetVersionText @2 -Pa_GetErrorText @3 -Pa_Initialize @4 -Pa_Terminate @5 -Pa_GetHostApiCount @6 -Pa_GetDefaultHostApi @7 -Pa_GetHostApiInfo @8 -Pa_HostApiTypeIdToHostApiIndex @9 -Pa_HostApiDeviceIndexToDeviceIndex @10 -Pa_GetLastHostErrorInfo @11 -Pa_GetDeviceCount @12 -Pa_GetDefaultInputDevice @13 -Pa_GetDefaultOutputDevice @14 -Pa_GetDeviceInfo @15 -Pa_IsFormatSupported @16 -Pa_OpenStream @17 -Pa_OpenDefaultStream @18 -Pa_CloseStream @19 -Pa_SetStreamFinishedCallback @20 -Pa_StartStream @21 -Pa_StopStream @22 -Pa_AbortStream @23 -Pa_IsStreamStopped @24 -Pa_IsStreamActive @25 -Pa_GetStreamInfo @26 -Pa_GetStreamTime @27 -Pa_GetStreamCpuLoad @28 -Pa_ReadStream @29 -Pa_WriteStream @30 -Pa_GetStreamReadAvailable @31 -Pa_GetStreamWriteAvailable @32 -Pa_GetSampleSize @33 -Pa_Sleep @34 -@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetAvailableBufferSizes @50 -@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_ShowControlPanel @51 -@DEF_EXCLUDE_X86_PLAIN_CONVERTERS@PaUtil_InitializeX86PlainConverters @52 -@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetInputChannelName @53 -@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetOutputChannelName @54 -PaUtil_SetDebugPrintFunction @55 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetAudioClient @56 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_UpdateDeviceList @57 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceCurrentFormat @58 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceDefaultFormat @59 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceMixFormat @60 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceRole @61 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityBoost @62 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityRevert @63 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetFramesPerHostBuffer @64 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackCount @65 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackDescription @66 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_SetStreamStateHandler @68 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_SetDefaultDeviceId @67 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_PopulateDeviceList @69 -@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetIMMDevice @70 diff --git a/source/portaudio/pablio/pablio.def b/source/portaudio/pablio/pablio.def deleted file mode 100644 index 36af739..0000000 --- a/source/portaudio/pablio/pablio.def +++ /dev/null @@ -1,35 +0,0 @@ -LIBRARY PABLIO -DESCRIPTION 'PABLIO Portable Audio Blocking I/O' - -EXPORTS - ; Explicit exports can go here - Pa_Initialize @1 - Pa_Terminate @2 - Pa_GetHostError @3 - Pa_GetErrorText @4 - Pa_CountDevices @5 - Pa_GetDefaultInputDeviceID @6 - Pa_GetDefaultOutputDeviceID @7 - Pa_GetDeviceInfo @8 - Pa_OpenStream @9 - Pa_OpenDefaultStream @10 - Pa_CloseStream @11 - Pa_StartStream @12 - Pa_StopStream @13 - Pa_StreamActive @14 - Pa_StreamTime @15 - Pa_GetCPULoad @16 - Pa_GetMinNumBuffers @17 - Pa_Sleep @18 - - OpenAudioStream @19 - CloseAudioStream @20 - WriteAudioStream @21 - ReadAudioStream @22 - - Pa_GetSampleSize @23 - - ;123456789012345678901234567890123456 - ;000000000111111111122222222223333333 - - diff --git a/source/scripts/engine.rb b/source/scripts/engine.rb deleted file mode 100644 index e88bf55..0000000 --- a/source/scripts/engine.rb +++ /dev/null @@ -1,62 +0,0 @@ -class Method - def source(n=5) - loc = source_location - puts `sed -n "#{loc[1]},#{loc[1]+n}p;#{loc[1]+6}q" #{loc[0]}` - end -end - -class Music - - def initialize(mpath = "") - load(mpath); - end - - - def load(mpath) - #@music = load(path); - end - - def play - - end -end - -class Sound - def initialize(path = "") - load(path); - end - - def load(path) - #@sound = - end - - def play - - end -end - -def checknewer - $maketimes ||= {} - file = caller[0].split(":")[0] - if $maketimes[file].nil? - $maketimes[file] = `stat --printf '%Y' #{file}` - return - end - - newtime = `stat --printf '%Y' #{file}` - if newtime > $maketimes[file] - load(file) - end -end - -def set_renderms(val) - settings_cmd(0, val); -end - -def set_updatems(val) - settings_cmd(1, val); -end - -def set_physms(val) - settings_cmd(2, val); -end \ No newline at end of file diff --git a/source/scripts/engine.scm b/source/scripts/engine.scm new file mode 100644 index 0000000..e69de29