From c60930e739ce3893eb6a7ab16a2d8afef7371351 Mon Sep 17 00:00:00 2001 From: shariq shah Date: Thu, 10 Aug 2017 16:13:35 +0500 Subject: [PATCH] Made minor modifications to makefiles and changed readme format from org to simple text file. --- README | 910 -------------------------- README.md | 262 ++++++++ assets/ground.ent | 11 + assets/light.ent | 19 + assets/player.ent | 15 + assets/shaders/blinn_phong.frag.orig | 130 ++++ assets/shaders/deferred_light.frag | 118 ++++ assets/shaders/deferred_light.vert | 15 + assets/shaders/phong.frag | 7 + assets/shaders/phong.vert | 8 + assets/shaders/phongTextured.frag | 10 + assets/shaders/quad.frag | 13 + assets/shaders/quad.vert | 14 + assets/shaders/simple.frag | 13 + assets/shaders/simple.vert | 12 + assets/shaders/unshaded_textured.frag | 9 + assets/shaders/unshaded_textured.vert | 7 + build/linux/makefile | 2 +- build/win_mingw64/makefile | 2 +- orgfile.org | 334 ---------- src/editor.c | 5 +- src/game.c | 20 +- src/game.h | 4 +- src/linmath.h | 4 +- src/platform.c | 2 +- src/platform.h | 2 +- src/sound.c | 3 +- 27 files changed, 686 insertions(+), 1265 deletions(-) delete mode 100644 README create mode 100644 README.md create mode 100644 assets/ground.ent create mode 100644 assets/light.ent create mode 100644 assets/player.ent create mode 100644 assets/shaders/blinn_phong.frag.orig create mode 100644 assets/shaders/deferred_light.frag create mode 100644 assets/shaders/deferred_light.vert create mode 100644 assets/shaders/phong.frag create mode 100644 assets/shaders/phong.vert create mode 100644 assets/shaders/phongTextured.frag create mode 100644 assets/shaders/quad.frag create mode 100644 assets/shaders/quad.vert create mode 100644 assets/shaders/simple.frag create mode 100644 assets/shaders/simple.vert create mode 100644 assets/shaders/unshaded_textured.frag create mode 100644 assets/shaders/unshaded_textured.vert delete mode 100644 orgfile.org diff --git a/README b/README deleted file mode 100644 index b31df39..0000000 --- a/README +++ /dev/null @@ -1,910 +0,0 @@ - __________________ - - PROJECT SYMMETRY - - Shariq Shah - __________________ - - -Table of Contents -_________________ - -1 Project Symmetry -.. 1.1 What? -.. 1.2 License -.. 1.3 File format specifications -..... 1.3.1 Entity -..... 1.3.2 Configuration Variables a.k.a cfg-vars -..... 1.3.3 Keybindings -..... 1.3.4 Level/Scene -..... 1.3.5 Materials -..... 1.3.6 Mesh/Geometry -.. 1.4 Notes on entity Systems -2 Things TODO -.. 2.1 DONE Input -.. 2.2 DONE Shaders -.. 2.3 DONE Geometry -.. 2.4 DONE change struct usage -.. 2.5 DONE change Array implementation -.. 2.6 DONE resolve vec-types sizes -.. 2.7 DONE Transform -.. 2.8 DONE Deltatime -.. 2.9 DONE Investigate about Exit() and at_exit() functions and whether to use them or not. -.. 2.10 DONE Fix readme markdown -.. 2.11 DONE Framebuffer and resolution independent rendering -.. 2.12 DONE A simpler build system without dependencies -.. 2.13 DONE Remove dependencies -.. 2.14 DONE Remove Kazmath dependency -.. 2.15 DONE Entity -.. 2.16 TODO Positive and negative values for input_maps and returning corresponding values when they are true -.. 2.17 DONE Find a permanent solution for build system -.. 2.18 TODO Text rendering using freetype or stb lib -.. 2.19 DONE Textures -.. 2.20 DONE Camera -.. 2.21 DONE Test render -.. 2.22 TODO Bounding Boxes -.. 2.23 DONE Fix input lag and other framerate related issues -.. 2.24 TODO File extension checking for asset loading -.. 2.25 DONE Materials -.. 2.26 DONE Mesh/Model -.. 2.27 DONE Add modifiers to input maps to enable combinations for example, c-x, m-k etc -.. 2.28 TODO Only allocate hashmap bucket when required -.. 2.29 TODO Mapping actions to keybindings, for example map action "Jump" to Space key etc -.. 2.30 DONE Heirarchical Transforms -.. 2.31 DONE Materials with textures -.. 2.32 DONE Lights! -.. 2.33 DONE Fix problems with texture units -.. 2.34 CANCELED Draw light volumes -.. 2.35 DONE Fix problems with frustrum culling -.. 2.36 TODO 2d drawing routines -.. 2.37 DONE Gui -.. 2.38 CANCELED Image based lighting? -.. 2.39 CANCELED Deferred rendering? -.. 2.40 DONE Fix mouse bugs on windows -.. 2.41 DONE Configuration/Settings load/save handling -.. 2.42 DONE Fix mousewheel bugs and gui not responding to mousewheel input -.. 2.43 TODO Ability to mark meshes for debug rendering with possibility of different color for each? -.. 2.44 TODO Switch to completely static allocation of entites i.e. have a static array of MAX_ENTITIES size. This way we can store pointers to entites and they'll still be in an array and fast to process. -.. 2.45 DONE Setup cross compilation with mingw or stick to msvc? -.. 2.46 TODO Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example -.. 2.47 DONE Toggleable debug drawing for meshes -.. 2.48 TODO Interleaved vbos for meshes and changes to blender exporter accordingly -.. 2.49 TODO Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? -.. 2.50 TODO Physics/Collision detection in 2d -.. 2.51 TODO Complete gui integration -.. 2.52 TODO Allow passsing base path as commandline argument? -.. 2.53 TODO Remove components and switch to "Fat Entities" i.e. one entity struct contains all combinations -.. 2.54 TODO Use variants for material params -.. 2.55 TODO Improve Material Parameters/Pipeline Uniforms/Instance Uniforms are handled -.. 2.56 TODO Fix light rotation/direction bugs -.. 2.57 DONE In second refactor pass, use entities everywhere, no need to pass in transform and model separately for example since they're both part of the same entity anyway -.. 2.58 DONE Show SDL dialogbox if we cannot launch at all? -.. 2.59 DONE Writing back to config file -.. 2.60 DONE Reading from config file -.. 2.61 DONE Variant -> String conversion procedure. Use in editor for debug var slots -.. 2.62 DONE Add strings and booleans to variant types -.. 2.63 DONE Fix Key release not being reported -.. 2.64 TODO Better handling incase assets folder is not found? -.. 2.65 TODO Write entity to/from file -.. 2.66 DONE OpenAL not working in releasebuilds -.. 2.67 DONE 3d sound using OpenAL -.. 2.68 TODO Ogg format loading and playback -.. 2.69 TODO Stick with OpenAL or switch to SoLoud + SDL for sound? -.. 2.70 TODO Sound streaming -.. 2.71 TODO Implment missing sound source properties (inner/outer cone, getting sound source data) -.. 2.72 TODO Ingame console and console commands etc -.. 2.73 TODO Allow binding/unbinding input maps to functions at runtime, for example if input map "Recompute" is triggered, it would call some function that can recompute bounding spheres. -.. 2.74 TODO Better handling of wav format checking at load time -.. 2.75 DONE Fix frustum culling bugs -.. 2.76 DONE Array-based Hashmaps -.. 2.77 TODO Sprite sheet animations -.. 2.78 DONE Fix bugs with heirarchical transformations -.. 2.79 TODO Replace orgfile with simple text readme and reduce duplication? -.. 2.80 TODO Ray picking -.. 2.81 DONE Remove reduntant "settings" structures and move all configuration stuff to config variables -.. 2.82 TODO Shadow maps -.. 2.83 DONE Log output to file on every run -.. 2.84 TODO Print processor stats and machine capabilites RAM etc on every run to log. -.. 2.85 TODO Milestone: Pong! -.. 2.86 TODO Do input maps really need to be queried by their string names? -.. 2.87 TODO Reloading all the things! (textures/shaders/models/settings/entities etc) -.. 2.88 TODO Separate Debug/Editor camera from the active camera in the scene that can be switched to at any time -.. 2.89 TODO Make logging to file and console toggleable at complie-time or run-time -.. 2.90 DONE Add option to specify where to read/write files from instead of being hard-coded assets dir -.. 2.91 TODO Add default keybindings -.. 2.92 TODO Write default config/keybindings etc to file if none are found in preferences dir -.. 2.93 DONE Fix input map bugs -.. 2.94 TODO Wrap malloc and free calls in custom functions to track usage -.. 2.95 TODO Flatpak packaging for linux releases -.. 2.96 TODO Use hashmap for debugvar slots in editor -.. 2.97 TODO Use hashmap to store input maps -.. 2.98 DONE Live data views in editor -.. 2.99 DONE Camera resize on window reisze -.. 2.100 DONE Resizable framebuffers and textures -.. 2.101 DONE Support for multiple color attachments in framebuffers? -.. 2.102 TODO Multisampled textures and framebuffers -.. 2.103 DONE Better way to store and manage textures attached to framebuffers -.. 2.104 TODO Validate necessary assets at game launch -.. 2.105 TODO Gamma correctness -.. 2.106 DONE Variant type -.. 2.107 TODO Log and debug/stats output in gui -.. 2.108 TODO Editor automatic window layout adjusting to the current window resolution -.. 2.109 DONE Editor -.. 2.110 TODO Event Subsystem -.. 2.111 TODO Keybindings for gui? -.. 2.112 TODO Textual/Binary format for data serialization and persistance -.. 2.113 TODO Better logging -.. 2.114 TODO Hatching/Ink rendering style -.. 2.115 DONE Fix frustum culling sometimes not working -.. 2.116 DONE Compile and test on windows -.. 2.117 TODO Array based string type comptible with cstring(char*) -.. 2.118 TODO Separate game, engine and assets into different repositories. Combine as sub-repositories -.. 2.119 DONE Fix mouse bugs -.. 2.120 DONE Fix -.. 2.121 DONE issues with opengl context showing 2.1 only -.. 2.122 TODO Improve this readme -.. 2.123 TODO ??? -.. 2.124 TODO Profit! - - -1 Project Symmetry -================== - -1.1 What? -~~~~~~~~~ - - A topdown 2D shooter exploring symmetry. - - -1.2 License -~~~~~~~~~~~ - - All the code in this repository is under GPLv3, see LICENSE for more - information - - -1.3 File format specifications -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -1.3.1 Entity ------------- - - entity: "Something" position: 0 0 0 scale: 1 1 1 rotation: 0 0 0 1 - model: "suzanne.pamesh" material: "blinn_phong" diffuse_color: 1 0 0 1 - diffuse_texture: "checkered.tga" specular: 0.55 - - - Add to_string functions for major structs like transform, model etc - to ease in conversion? - - -1.3.2 Configuration Variables a.k.a cfg-vars --------------------------------------------- - - render_width: 1024 render_height: 1024 debug_draw_enabled: true - fog_color: 0.5 0.2 0.2 1 - - ambient_light: 0.1 0.1 0.1 1 msaa: true msaa_levels: 8 - - -1.3.3 Keybindings ------------------ - - Move_Forward: W - - Move_Backward: S,Down - - Quit: Left Ctrl-Q - - Sprint: Left Shift - - -1.3.4 Level/Scene ------------------ - - - Binary format with header attached at the top - - Save child entities first - - Copy paste all entites in the file one by one. Since the entites all - look the same in memory and are made up of tagged unions, a simple - memcpy approach should suffice. The problem is entity - heirarchies. There are multiple approaches to solve this problem. - -- Save a sorted list of entites to file i.e. before saving create a - new list that does not have the empty array slots in the entity list - and then just copy and paste. This is the simplest way to solve the - problem as we don't have to worry about indexes of parent/child - entites in heirarchy. We can take the whole array and paste it to - the file but creating a copy of entity list for this purpose only - would be slow and consume a lot of memory. -- Instead of creating a - copy of the entity list for sorting and saving, sort the actual - entity list and update all references as necessary then save the - array to file. -- Just write the name of the parent entity as - parent. Make sure that all entity names are unique. - - -1.3.5 Materials ---------------- - - -1.3.6 Mesh/Geometry -------------------- - - -1.4 Notes on entity Systems -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - Fat entites with all related properties, i.e. position, mesh etc in - them. Easy to serialize, memory friendly, simple to implement but - would require significant changes to the current codebase. e.g. - struct Entity { int type; char* name; struct Transform {....}; - struct Camera {....}; - - // Separate properties unique to entity types by using unions struct - Renderable { struct Model {....}; union { struct Player { int score; - int bullets; }; - - struct Enemy { int target; }; } } }; - - Change component implementation by using anonymous unions to - simulate interfaces. e.g struct Component { int type; union { struct - Transform {....}; struct Model {....}; struct Camera {....}; } } - - Use handles for assets - - Use something similar to Variant to use as entity, not sure what or - how - - Don't forget to think of the actual use-case and usage when coming - up with a solution, don't build castles in the air! - - -2 Things TODO -============= - -2.1 DONE Input -~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-02 Thu 01:24] - - Input maps (addition/removal) - - Adding removing keys to input maps - - Changing map na - - -2.2 DONE Shaders -~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-11 Sat 17:57] - - set asset folder - - load/compile shader - - -2.3 DONE Geometry -~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-11 Sat 17:57] - - -2.4 DONE change struct usage -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-21 Tue 15:13] - - -2.5 DONE change Array implementation -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-25 Sat 20:27] - - -2.6 DONE resolve vec-types sizes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-25 Sat 20:27] - - -2.7 DONE Transform -~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-26 Sun 18:01] - - -2.8 DONE Deltatime -~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-07-27 Mon 11:54] - - -2.9 DONE Investigate about Exit() and at_exit() functions and whether to use them or not. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-08-02 Sun 19:09] - - -2.10 DONE Fix readme markdown -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-12-10 Thu 16:36] - - -2.11 DONE Framebuffer and resolution independent rendering -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2016-05-27 Fri 18:02] - - -2.12 DONE A simpler build system without dependencies -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2016-05-27 Fri 14:50] - - -2.13 DONE Remove dependencies -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-02-26 Sun 01:46] - - glfw3 - - glew - - -2.14 DONE Remove Kazmath dependency -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-12-10 Thu 16:36] - - -2.15 DONE Entity -~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-09-15 Tue 12:17] - - -2.16 TODO Positive and negative values for input_maps and returning corresponding values when they are true -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.17 DONE Find a permanent solution for build system -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-15 Wed 00:59] - - -2.18 TODO Text rendering using freetype or stb lib -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.19 DONE Textures -~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-10-09 Fri 18:47] - - -2.20 DONE Camera -~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-08-19 Wed 13:30] - - -2.21 DONE Test render -~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-08-19 Wed 13:30] - - -2.22 TODO Bounding Boxes -~~~~~~~~~~~~~~~~~~~~~~~~ - - - Recalculated bounding boxes for rotated meshes? - - -2.23 DONE Fix input lag and other framerate related issues -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-07 Sun 18:40] - - -2.24 TODO File extension checking for asset loading -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.25 DONE Materials -~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-10-13 Tue 19:38] - - -2.26 DONE Mesh/Model -~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-10-13 Tue 19:38] - - -2.27 DONE Add modifiers to input maps to enable combinations for example, c-x, m-k etc -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-20 Sat 21:54] - - -2.28 TODO Only allocate hashmap bucket when required -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.29 TODO Mapping actions to keybindings, for example map action "Jump" to Space key etc -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.30 DONE Heirarchical Transforms -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.31 DONE Materials with textures -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2015-10-15 Thu 21:21] - - -2.32 DONE Lights! -~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-14 Tue 00:31] - - -2.33 DONE Fix problems with texture units -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2016-05-30 Mon 00:57] - - -2.34 CANCELED Draw light volumes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "CANCELED" from "TODO" [2017-02-26 Sun 15:39] - Deferred rendering on hold for now. - - -2.35 DONE Fix problems with frustrum culling -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-26 Sun 01:33] - - -2.36 TODO 2d drawing routines -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - Sprite batching - - -2.37 DONE Gui -~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-15 Wed 23:41] - - -2.38 CANCELED Image based lighting? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "CANCELED" from "TODO" [2017-03-14 Tue 00:31] - Not a requirement for current project - - -2.39 CANCELED Deferred rendering? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] - Sticking with forward rendering for now and focusing on tools etc. - - -2.40 DONE Fix mouse bugs on windows -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-25 Sat 17:27] - - -2.41 DONE Configuration/Settings load/save handling -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-20 Sat 21:54] - - -2.42 DONE Fix mousewheel bugs and gui not responding to mousewheel input -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-19 Sun 01:31] - - -2.43 TODO Ability to mark meshes for debug rendering with possibility of different color for each? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.44 TODO Switch to completely static allocation of entites i.e. have a static array of MAX_ENTITIES size. This way we can store pointers to entites and they'll still be in an array and fast to process. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.45 DONE Setup cross compilation with mingw or stick to msvc? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-20 Sat 21:55] - - Done, going with mingw for now. - - -2.46 TODO Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.47 DONE Toggleable debug drawing for meshes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-18 Sat 16:18] - - -2.48 TODO Interleaved vbos for meshes and changes to blender exporter accordingly -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.49 TODO Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.50 TODO Physics/Collision detection in 2d -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.51 TODO Complete gui integration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - x Font selection x Font atlas proper cleanup - - Decoupled event handling of gui and input if possible - - Custom rendering for gui - - -2.52 TODO Allow passsing base path as commandline argument? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.53 TODO Remove components and switch to "Fat Entities" i.e. one entity struct contains all combinations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.54 TODO Use variants for material params -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.55 TODO Improve Material Parameters/Pipeline Uniforms/Instance Uniforms are handled -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.56 TODO Fix light rotation/direction bugs -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.57 DONE In second refactor pass, use entities everywhere, no need to pass in transform and model separately for example since they're both part of the same entity anyway -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-31 Wed 21:44] - - -2.58 DONE Show SDL dialogbox if we cannot launch at all? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-26 Fri 00:41] - - -2.59 DONE Writing back to config file -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-08 Mon 00:57] - - -2.60 DONE Reading from config file -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-07 Sun 23:52] - - -2.61 DONE Variant -> String conversion procedure. Use in editor for debug var slots -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-07 Sun 18:43] - - -2.62 DONE Add strings and booleans to variant types -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-29 Wed 00:23] - - -2.63 DONE Fix Key release not being reported -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-26 Sun 01:16] - - -2.64 TODO Better handling incase assets folder is not found? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.65 TODO Write entity to/from file -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.66 DONE OpenAL not working in releasebuilds -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-25 Sat 02:06] - - -2.67 DONE 3d sound using OpenAL -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-23 Thu 01:43] - - -2.68 TODO Ogg format loading and playback -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.69 TODO Stick with OpenAL or switch to SoLoud + SDL for sound? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.70 TODO Sound streaming -~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.71 TODO Implment missing sound source properties (inner/outer cone, getting sound source data) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.72 TODO Ingame console and console commands etc -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.73 TODO Allow binding/unbinding input maps to functions at runtime, for example if input map "Recompute" is triggered, it would call some function that can recompute bounding spheres. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.74 TODO Better handling of wav format checking at load time -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.75 DONE Fix frustum culling bugs -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-31 Wed 23:38] - - -2.76 DONE Array-based Hashmaps -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-07 Sun 18:42] - - -2.77 TODO Sprite sheet animations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.78 DONE Fix bugs with heirarchical transformations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-06-01 Thu 00:20] - - -2.79 TODO Replace orgfile with simple text readme and reduce duplication? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.80 TODO Ray picking -~~~~~~~~~~~~~~~~~~~~~ - - -2.81 DONE Remove reduntant "settings" structures and move all configuration stuff to config variables -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-06-05 Mon 02:25] - - -2.82 TODO Shadow maps -~~~~~~~~~~~~~~~~~~~~~ - - -2.83 DONE Log output to file on every run -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-26 Fri 00:41] - - -2.84 TODO Print processor stats and machine capabilites RAM etc on every run to log. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.85 TODO Milestone: Pong! -~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - In order to put things into perspective and get a feel for what - really needs to be prioritized, a very small but actual game release - is necessary. - - Release platforms: Windows and Linux - - Makefile additions. Try to compile game as a dynamically loaded - library with ability to reload on recompile - - Separation between game and engine base - ? Game .so with init, update and cleanup functions x Configuration - files and "cvars" load/reload x Keybindings in config x Log output on - every run. - - Implement entity load/save to file - ? Prefab load/save to file - - -2.86 TODO Do input maps really need to be queried by their string names? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.87 TODO Reloading all the things! (textures/shaders/models/settings/entities etc) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.88 TODO Separate Debug/Editor camera from the active camera in the scene that can be switched to at any time -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.89 TODO Make logging to file and console toggleable at complie-time or run-time -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.90 DONE Add option to specify where to read/write files from instead of being hard-coded assets dir -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-24 Wed 17:12] - - -2.91 TODO Add default keybindings -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.92 TODO Write default config/keybindings etc to file if none are found in preferences dir -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.93 DONE Fix input map bugs -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-05-31 Wed 23:19] - - -2.94 TODO Wrap malloc and free calls in custom functions to track usage -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.95 TODO Flatpak packaging for linux releases -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.96 TODO Use hashmap for debugvar slots in editor -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.97 TODO Use hashmap to store input maps -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.98 DONE Live data views in editor -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-22 Wed 02:14] - - -2.99 DONE Camera resize on window reisze -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-20 Mon 15:22] - - -2.100 DONE Resizable framebuffers and textures -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-16 Thu 22:50] - - -2.101 DONE Support for multiple color attachments in framebuffers? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-16 Thu 22:51] - - -2.102 TODO Multisampled textures and framebuffers -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.103 DONE Better way to store and manage textures attached to framebuffers -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-16 Thu 22:51] - - -2.104 TODO Validate necessary assets at game launch -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.105 TODO Gamma correctness -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.106 DONE Variant type -~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-22 Wed 02:14] - - -2.107 TODO Log and debug/stats output in gui -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.108 TODO Editor automatic window layout adjusting to the current window resolution -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.109 DONE Editor -~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-06-20 Tue 01:12] - - -2.110 TODO Event Subsystem -~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.111 TODO Keybindings for gui? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.112 TODO Textual/Binary format for data serialization and persistance -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.113 TODO Better logging -~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.114 TODO Hatching/Ink rendering style -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.115 DONE Fix frustum culling sometimes not working -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-25 Sat 19:10] - - -2.116 DONE Compile and test on windows -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-14 Tue 00:32] - - -2.117 TODO Array based string type comptible with cstring(char*) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.118 TODO Separate game, engine and assets into different repositories. Combine as sub-repositories -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.119 DONE Fix mouse bugs -~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-01 Wed 00:45] - - -2.120 DONE Fix -~~~~~~~~~~~~~~ - - -2.121 DONE issues with opengl context showing 2.1 only -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - State "DONE" from "TODO" [2017-03-19 Sun 14:03] - - State "DONE" from "TODO" [2017-02-26 Sun 15:39] - - -2.122 TODO Improve this readme -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -2.123 TODO ??? -~~~~~~~~~~~~~~ - - -2.124 TODO Profit! -~~~~~~~~~~~~~~~~~~ diff --git a/README.md b/README.md new file mode 100644 index 0000000..47e891d --- /dev/null +++ b/README.md @@ -0,0 +1,262 @@ +=================== +Project Symmetry +=================== + +** What? +A topdown 2D shooter exploring symmetry. + +** License +All the code in this repository is under GPLv3, see LICENSE for more information + +** File format specifications + *** Entity + # Comment, Sample entity definition in file, paremeters left out are set to defaults + # Empty line at the end specifies end of entity definition + entity: "Something" + position: 0 0 0 + scale: 1 1 1 + rotation: 0 0 0 1 + model: "suzanne.pamesh" + material: "blinn_phong" + diffuse_color: 1 0 0 1 + diffuse_texture: "checkered.tga" + specular: 0.55 + + - Add to_string functions for major structs like transform, model etc to ease in conversion? + + *** Configuration Variables a.k.a cfg-vars + # Comment + render_width: 1024 + render_height: 1024 + debug_draw_enabled: true + fog_color: 0.5 0.2 0.2 1 + # There can be comments or empty newlines in between unlike entity definitions + + ambient_light: 0.1 0.1 0.1 1 + msaa: true + msaa_levels: 8 + + *** Keybindings + # All keys are parsed by comparing the output of SDL_GetKeyname + # Each line represents a keybinding + Move_Forward: W + + # Multiple keys to a single binding are specified with commas + Move_Backward: S,Down + + # Combinations are specified with a hyphen/dash + # When specifing combinations, modifiers(shift, alt, ctrl) always come before + # the hyphen and the actual key comes afterwards. At the moment modifier keys are + # forced to be on the left side i.e. Left Control, Left Shift and Left Alt. + Quit: Left Ctrl-Q + + # Single modifier keys are allowed but multiple modifier keys without corresponding + # non-modifier key are not allowed + Sprint: Left Shift + + *** Level/Scene + - Binary format with header attached at the top + - Save child entities first + - Copy paste all entites in the file one by one. Since the entites all look + the same in memory and are made up of tagged unions, a simple memcpy approach + should suffice. The problem is entity heirarchies. There are multiple approaches to + solve this problem. + -- Save a sorted list of entites to file i.e. before saving create a new list that does + not have the empty array slots in the entity list and then just copy and paste. This + is the simplest way to solve the problem as we don't have to worry about indexes of + parent/child entites in heirarchy. We can take the whole array and paste it to the + file but creating a copy of entity list for this purpose only would be slow and consume a lot of memory. + -- Instead of creating a copy of the entity list for sorting and saving, sort the actual entity list + and update all references as necessary then save the array to file. + -- Just write the name of the parent entity as parent. Make sure that all entity names are unique. + *** Materials + *** Mesh/Geometry +** Notes on entity Systems + - Fat entites with all related properties, i.e. position, mesh etc in them. Easy to serialize, memory friendly, simple to implement + but would require significant changes to the current codebase. e.g. + struct Entity + { + int type; + char* name; + struct Transform {....}; + struct Camera {....}; + + // Separate properties unique to entity types by using unions + struct Renderable + { + struct Model {....}; + union + { + struct Player + { + int score; + int bullets; + }; + + struct Enemy + { + int target; + }; + } + } + }; + - Change component implementation by using anonymous unions to simulate interfaces. e.g + struct Component + { + int type; + union + { + struct Transform {....}; + struct Model {....}; + struct Camera {....}; + } + } + - Use handles for assets + - Use something similar to Variant to use as entity, not sure what or how + - Don't forget to think of the actual use-case and usage when coming up with a solution, don't build castles in the air! + + +================ +Things TODO +================ + +x Input +x Shaders +x Geometry +x change struct usage +x change Array implementation +x resolve vec-types sizes +x Transform +x Deltatime +x Investigate about Exit() and at_exit() functions and whether to use them or not. +x Fix readme markdown +x Framebuffer and resolution independent rendering +x A simpler build system without dependencies +x Remove dependencies +x Remove Kazmath dependency +x Entity +x Find a permanent solution for build system +? Positive and negative values for input_maps and returning corresponding values when they are true +x Textures +x Camera +x Test render +x Fix input lag and other framerate related issues +x Materials +x Mesh/Model +x Add modifiers to input maps to enable combinations for example, c-x, m-k etc +x Heirarchical Transforms +x Materials with textures +x Lights! +x Fix problems with texture units +x Fix problems with frustrum culling +x Gui +x Fix mouse bugs on windows +x Configuration/Settings load/save handling +x Fix mousewheel bugs and gui not responding to mousewheel input +x Setup cross compilation with mingw or stick to msvc? +x Toggleable debug drawing for meshes +x Font selection +x Font atlas proper cleanup +x In second refactor pass, use entities everywhere, no need to pass in transform and model separately for example since they're both part of the same entity anyway +x Show SDL dialogbox if we cannot launch at all? +x Writing back to config file +x Reading from config file +x Variant -> String conversion procedure. Use in editor for debug var slots +x Add strings and booleans to variant types +x Fix Key release not being reported +x OpenAL not working in releasebuilds +x 3d sound using OpenAL +x Fix frustum culling bugs +x Array-based Hashmaps +x Fix bugs with heirarchical transformations +x Remove reduntant "settings" structures and move all configuration stuff to config variables +x Log output to file on every run +x Add option to specify where to read/write files from instead of being hard-coded assets dir +x Fix input map bugs +x Live data views in editor +x Camera resize on window reisze +x Resizable framebuffers and textures +x Support for multiple color attachments in framebuffers? +x Better way to store and manage textures attached to framebuffers +x Variant type +x Editor +x Fix frustum culling sometimes not working +x Compile and test on windows +x Fix mouse bugs +x Fix +x issues with opengl context showing 2.1 only +x Improve this readme +x Replace orgfile with simple text readme and reduce duplication? +- Bounding Boxes + ? Recalculated bounding boxes for rotated meshes? +- File extension checking for asset loading +- Only allocate hashmap bucket when required +- Mapping actions to keybindings, for example map action "Jump" to Space key etc +- Ability to mark meshes for debug rendering with possibility of different color for each? +- Switch to completely static allocation of entites i.e. have a static array of MAX_ENTITIES size. This way we can store pointers to entites and they'll still be in an array and fast to process. +? CANCELED Image based lighting? +? CANCELED Deferred rendering? +- Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example +- Interleaved vbos for meshes and changes to blender exporter accordingly +- Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? +- Physics/Collision detection in 2d +- Complete gui integration +- Decoupled event handling of gui and input if possible +- Custom rendering for gui +- Allow passsing base path as commandline argument? +- Remove components and switch to "Fat Entities" i.e. one entity struct contains all combinations +- Use variants for material params +- Improve Material Parameters/Pipeline Uniforms/Instance Uniforms are handled +- Fix light rotation/direction bugs +- Better handling incase assets folder is not found? +- Write entity to/from file +- Ogg format loading and playback +- Stick with OpenAL or switch to SoLoud + SDL for sound? +- Sound streaming +- Implment missing sound source properties (inner/outer cone, getting sound source data) +- Ingame console and console commands etc +- Allow binding/unbinding input maps to functions at runtime, for example if input map "Recompute" is triggered, it would call some function that can recompute bounding spheres. +- Better handling of wav format checking at load time +- Sprite sheet animations +- First class 2d rendering + - Sprite batching (XNA like) + - Font rendering(2d/3d) with stb_ttf or freetype + ? Minimal custom UI for in-game usage that can be rendered to a texture or modify nuklear for that? +- Ray picking +- Shadow maps +- Print processor stats and machine capabilites RAM etc on every run to log. +- Milestone: Pong! + - In order to put things into perspective and get a feel for what really needs to be prioritized, a very small but actual game release is necessary. + - Release platforms: Windows and Linux + - Makefile additions. Try to compile game as a dynamically loaded library with ability to reload on recompile + - Separation between game and engine base + ? Game .so with init, update and cleanup functions + x Configuration files and "cvars" load/reload + x Keybindings in config + x Log output on every run. + - Implement entity load/save to file + ? Prefab load/save to file +- Do input maps really need to be queried by their string names? +- Reloading all the things! (textures/shaders/models/settings/entities etc) +- Separate Debug/Editor camera from the active camera in the scene that can be switched to at any time +- Make logging to file and console toggleable at complie-time or run-time +- Add default keybindings +- Write default config/keybindings etc to file if none are found in preferences dir +- Wrap malloc and free calls in custom functions to track usage +- Flatpak packaging for linux releases +- Use hashmap for debugvar slots in editor +- Use hashmap to store input maps +- Multisampled textures and framebuffers +- Validate necessary assets at game launch +- Gamma correctness +- Log and debug/stats output in gui +- Editor automatic window layout adjusting to the current window resolution +- Event Subsystem +- Keybindings for gui? +- Textual/Binary format for data serialization and persistance +- Better logging +- Hatching/Ink rendering style +- Array based string type comptible with cstring(char*) +- Separate game, engine and assets into different repositories. Combine as sub-repositories +- ??? +- Profit! diff --git a/assets/ground.ent b/assets/ground.ent new file mode 100644 index 0000000..487d98f --- /dev/null +++ b/assets/ground.ent @@ -0,0 +1,11 @@ +name: Ground +type: 5 +is_listener: false +renderable: true +parent: ROOT +position: 0.00000 -5.00000 0.00000 +scale: 400.00000 2.00000 400.00000 +rotation: 0.00000 0.00000 0.00000 1.00000 +material: Blinn_Phong +geometry: default.pamesh + diff --git a/assets/light.ent b/assets/light.ent new file mode 100644 index 0000000..2c9283d --- /dev/null +++ b/assets/light.ent @@ -0,0 +1,19 @@ +name: Light_Ent +type: 4 +is_listener: false +renderable: false +parent: ROOT +position: 7.00000 1.00000 82.00000 +scale: 1.00000 1.00000 1.00000 +rotation: 0.00000 0.00000 0.00000 1.00000 +light_type: 0 +outer_angle: 0.52360 +inner_angle: 0.34907 +falloff: 1.50000 +radius: 40 +intensity: 2.00000 +depth_bias: 0.00050 +valid: true +cast_shadow: false +pcf_enabled: false +color: 0.00000 1.0000 0.000 diff --git a/assets/player.ent b/assets/player.ent new file mode 100644 index 0000000..eac0ea7 --- /dev/null +++ b/assets/player.ent @@ -0,0 +1,15 @@ +name: player +type: 2 +is_listener: 1 +renderable: 0 +parent: ROOT +position: 10.00000 5.00000 100.00000 +scale: 1.00000 1.00000 1.00000 +rotation: 0.00000 0.00000 0.00000 1.00000 +ortho: 0 +resizeable: 1 +fov: 60.00000 +nearz: 0.10000 +farz: 1000.00000 +render_texture: 1 + diff --git a/assets/shaders/blinn_phong.frag.orig b/assets/shaders/blinn_phong.frag.orig new file mode 100644 index 0000000..13b4c96 --- /dev/null +++ b/assets/shaders/blinn_phong.frag.orig @@ -0,0 +1,130 @@ +//include fog.glsl common.glsl commonFrag.glsl version.glsl + +struct Light +{ + vec3 position; + vec3 direction; + float outer_angle; + float inner_angle; + float falloff; + float intensity; + vec3 color; + uint pcf_enabled; + int type; + int radius; + float depth_bias; +}; + +const int LT_SPOT = 0; +const int LT_DIR = 1; +const int LT_POINT = 2; + +const int MAX_LIGHTS = 128; + +uniform sampler2D diffuse_texture; +uniform Light lights[MAX_LIGHTS]; +uniform int total_active_lights; + +uniform float specular; +uniform float diffuse; +uniform float specular_strength; +out vec4 frag_color; + +vec3 calc_point_light(in Light light) +{ + vec3 diffuse_comp = vec3(0.0); + vec3 specular_comp = vec3(0.0); + vec3 light_direction = vertex - light.position; + float dist = abs(length(light_direction)); + if(dist <= light.radius) + { + light_direction = normalize(light_direction); + vec3 normalized_normal = normalize(normal); + float cos_ang_incidence = dot(normalized_normal, -light_direction); + cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); + + if(cos_ang_incidence > 0) + { + diffuse_comp = light.color * diffuse * cos_ang_incidence; + vec3 vertex_to_eye = normalize(camera_pos - vertex); + vec3 halfway = normalize(light.direction + vertex_to_eye); + float specular_factor = max(0.0, dot(normalized_normal, halfway)); + specular_factor = pow(specular_factor, specular_strength); + specular_comp = light.color * specular * specular_factor; + } + float attenuation = pow(max(0.0, (1.0 - (dist / light.radius))), light.falloff + 1.0f); + return (((diffuse_comp + specular_comp) * attenuation) * light.intensity); + } + else + { + return vec3(0.0); + } +} + +vec3 calc_dir_light(in Light light) +{ + vec3 diffuse_comp = vec3(0.0); + vec3 specular_comp = vec3(0.0); + vec3 normalized_normal = normalize(normal); + float cos_ang_incidence = dot(normalized_normal, -light.direction); + cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); + float shadow_factor = 1.0; + + if(cos_ang_incidence > 0) + { + diffuse_comp = light.color * diffuse * cos_ang_incidence; + + vec3 vertex_to_eye = normalize(camera_pos - vertex); + vec3 light_reflect = normalize(reflect(light.direction, normalized_normal)); + vec3 halfway = normalize(light.direction + vertex_to_eye); + float specular_factor = max(0.0, dot(normalized_normal, halfway)); + specular_factor = pow(specular_factor, specular_strength); + specular_comp = light.color * specular * specular_factor; + // if(light.castShadow == 1) + // { + // shadow_factor = calcShadowFactor(vertLightSpace.xyz); + // } + } + //return (light.intensity * (diffuse_comp + specular_comp)) * shadow_factor; + return (light.intensity * (diffuse_comp + specular_comp)); +} + +vec3 calc_spot_light(in Light light) +{ + vec3 color = vec3(0.0); + vec3 light_to_surface = vertex - light.position; + float angle = dot(light.direction, normalize(light_to_surface)); + if(acos(angle) < light.outer_angle) + { + color = calc_point_light(light); + color *= smoothstep(cos(light.outer_angle), cos(light.inner_angle), angle); + // if(light.cast_shadow != 0) + // { + // float shadow_factor = calc_shadow_factor(vert_light_space.xyz / vert_light_space.w); + // color *= shadow_factor; + // } + } + return color;// * shadowFactor; +} + + +void main() +{ + vec4 albedo_color = diffuse_color * texture(diffuse_texture, uv); + vec3 light_contribution = vec3(0.0, 0.0, 0.0); + + for(int i = 0; i < total_active_lights; i++) + { + if(i == total_active_lights) break; + + if(lights[i].type == LT_POINT) + light_contribution += calc_point_light(lights[i]); + else if(lights[i].type == LT_DIR) + light_contribution += calc_dir_light(lights[i]); + else + light_contribution += calc_spot_light(lights[i]); + } + + //frag_color = apply_fog((albedo_color * vec4(light_contribution + ambient_light, 1.0))); + frag_color = diffuse_color; +} diff --git a/assets/shaders/deferred_light.frag b/assets/shaders/deferred_light.frag new file mode 100644 index 0000000..f22afbf --- /dev/null +++ b/assets/shaders/deferred_light.frag @@ -0,0 +1,118 @@ +//include version.glsl + +in vec2 uv; + +out vec4 frag_color; + +struct Light +{ + vec3 position; + float outer_angle; + float inner_angle; + float falloff; + float intensity; + vec4 color; + uint pcf_enabled; + int type; + int radius; + float depth_bias; +}; + +const int LT_SPOT = 0; +const int LT_DIR = 1; +const int LT_POINT = 2; + +uniform sampler2D albedo_map; +uniform sampler2D position_map; +uniform sampler2D normal_map; +uniform sampler2D depth_map; + +uniform Light light; +uniform vec3 camera_pos; +uniform mat4 mvp; +uniform mat4 inv_proj_mat; +uniform vec2 screen_size; +uniform vec2 planes; + + +vec4 calc_point_light(Light point_light, + vec3 vertex, + vec3 normal, + vec4 albedo_color, + float mat_specular_strength, + float mat_specular) +{ + vec4 diffuse = vec4(0.0); + vec4 specular = vec4(0.0); + vec3 light_direction = vertex - point_light.position; + light_direction = normalize(light_direction); + float distance = abs(length(light_direction)); + vec3 normalized_normal = normalize(normal); + float cos_ang_incidence = dot(normalized_normal, -light_direction); + cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); + + if(cos_ang_incidence > 0) + { + diffuse = point_light.color * albedo_color * cos_ang_incidence; + vec3 vertex_to_eye = normalize(camera_pos - vertex); + vec3 light_reflect = normalize(reflect(light_direction, normalized_normal)); + float specular_factor = max(0.0, dot(vertex_to_eye, light_reflect)); + specular_factor = pow(specular_factor, mat_specular_strength); + specular = point_light.color * mat_specular * specular_factor; + } + float attenuation = pow(max(0.0, (1.0 - (distance / point_light.radius))), point_light.falloff + 1.0f); + return (((diffuse + specular) * attenuation) * point_light.intensity); + + // if(distance <= point_light.radius) + // { + // light_direction = normalize(light_direction); + // vec3 normalized_normal = normalize(normal); + // float cos_ang_incidence = dot(normalized_normal, -light_direction); + // cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); + + // if(cos_ang_incidence > 0) + // { + // diffuse = point_light.color * albedo_color * cos_ang_incidence; + // vec3 vertex_to_eye = normalize(camera_pos - vertex); + // vec3 light_reflect = normalize(reflect(light_direction, normalized_normal)); + // float specular_factor = max(0.0, dot(vertex_to_eye, light_reflect)); + // specular_factor = pow(specular_factor, mat_specular_strength); + // specular = point_light.color * mat_specular * specular_factor; + // } + // float attenuation = pow(max(0.0, (1.0 - (distance / point_light.radius))), point_light.falloff + 1.0f); + // return (((diffuse + specular) * attenuation) * point_light.intensity); + // } + // else + // { + // return vec4(0.0); + // } +} + +float lz(float depth) +{ + return planes.x / (planes.y - depth * (planes.y - planes.x)) * planes.y; +} + +void main() +{ + //vec2 uv_coords = gl_FragCoord.xy / screen_size; + vec2 uv_coords = uv; + vec4 albedo_color = texture(albedo_map, uv_coords); + vec3 position = texture(position_map, uv_coords).rgb; + vec3 normal = texture(normal_map, uv_coords).rgb; + normal = normalize(normal); + + // vec3 position = vec3(0); + // position = vec4(inv_proj_mat * vec4(position, 1.0)).xyz; + // float depth = texture(depth_map, uv_coords.st).x; + // position.x = ((gl_FragCoord.x / screen_size.x) - 0.5) * 2.0; + // position.y = ((-gl_FragCoord.y/screen_size.y)+0.5) * 2.0 / (screen_size.x/screen_size.y); + // position.z = lz(depth); + // position.x *= position.z; + // position.y *= -position.z; + + //normal = vec4(inv_proj_mat * vec4(normal, 1.0)).xyz; + + frag_color = calc_point_light(light, position, normal, albedo_color, 20, 1.f); + //frag_color = vec4(albedo_color, 1.0); +} diff --git a/assets/shaders/deferred_light.vert b/assets/shaders/deferred_light.vert new file mode 100644 index 0000000..3ee968e --- /dev/null +++ b/assets/shaders/deferred_light.vert @@ -0,0 +1,15 @@ +//include version.glsl + +in vec2 vPosition; +in vec2 vUV; + +out vec2 uv; + +uniform mat4 mvp; + +void main() +{ + uv = vUV; + //gl_Position = mvp * vec4(vPosition, 1.0); + gl_Position = vec4(vPosition, 0, 1.0); +} diff --git a/assets/shaders/phong.frag b/assets/shaders/phong.frag new file mode 100644 index 0000000..5b3d486 --- /dev/null +++ b/assets/shaders/phong.frag @@ -0,0 +1,7 @@ +//include fog.glsl phongCommon.glsl common.glsl commonFrag.glsl version.glsl + +void main() +{ + vec4 totalLightColor = calculateLight(); + fragColor = applyFog(diffuseColor * (totalLightColor + ambientLight)); +} diff --git a/assets/shaders/phong.vert b/assets/shaders/phong.vert new file mode 100644 index 0000000..08a55c3 --- /dev/null +++ b/assets/shaders/phong.vert @@ -0,0 +1,8 @@ +//include commonVert.glsl version.glsl + +void main() +{ + gl_Position = transformPosition(vPosition); + setOutputs(); +} + diff --git a/assets/shaders/phongTextured.frag b/assets/shaders/phongTextured.frag new file mode 100644 index 0000000..3a8031a --- /dev/null +++ b/assets/shaders/phongTextured.frag @@ -0,0 +1,10 @@ +//include fog.glsl phongCommon.glsl common.glsl commonFrag.glsl version.glsl + +uniform sampler2D sampler; + +void main() +{ + vec4 pixelColor = diffuseColor * texture(sampler, uv); + vec4 totalLightColor = calculateLight(); + fragColor = applyFog(pixelColor * (totalLightColor + ambientLight)); +} diff --git a/assets/shaders/quad.frag b/assets/shaders/quad.frag new file mode 100644 index 0000000..ccf66ef --- /dev/null +++ b/assets/shaders/quad.frag @@ -0,0 +1,13 @@ +#version 130 + +in vec2 uv; + +out vec4 fragColor; + +uniform vec4 textColor; +uniform sampler2D sampler; + +void main() +{ + fragColor = texture2D(sampler, uv) * textColor; +} diff --git a/assets/shaders/quad.vert b/assets/shaders/quad.vert new file mode 100644 index 0000000..398f7ce --- /dev/null +++ b/assets/shaders/quad.vert @@ -0,0 +1,14 @@ +#version 130 + +in vec2 vPosition; +in vec2 vUV; + +out vec2 uv; + +uniform mat4 mvp; + +void main() +{ + uv = vUV; + gl_Position = mvp * vec4(vPosition, 0, 1.0); +} diff --git a/assets/shaders/simple.frag b/assets/shaders/simple.frag new file mode 100644 index 0000000..f94bc01 --- /dev/null +++ b/assets/shaders/simple.frag @@ -0,0 +1,13 @@ +#version 130 + +uniform sampler2D sampler; + +in vec2 uv; + +out vec4 fragColor; + +void main() +{ + // fragColor = vec4(0, 1, 0, 1) * texture2D(sampler, uv.st); + fragColor = vec4(0, 1, 0, 1); +} diff --git a/assets/shaders/simple.vert b/assets/shaders/simple.vert new file mode 100644 index 0000000..f297431 --- /dev/null +++ b/assets/shaders/simple.vert @@ -0,0 +1,12 @@ +#version 130 + +in vec3 vPosition; +in vec2 vUV; + +out vec2 uv; + +void main() +{ + uv = vUV; + gl_Position = vec4(vPosition, 1.0); +} diff --git a/assets/shaders/unshaded_textured.frag b/assets/shaders/unshaded_textured.frag new file mode 100644 index 0000000..45ef4fb --- /dev/null +++ b/assets/shaders/unshaded_textured.frag @@ -0,0 +1,9 @@ +//include fog.glsl commonFrag.glsl common.glsl version.glsl + +uniform sampler2D sampler; + +void main() +{ + vec4 pixelColor = diffuseColor * texture(sampler, uv); + fragColor = applyFog(pixelColor); +} diff --git a/assets/shaders/unshaded_textured.vert b/assets/shaders/unshaded_textured.vert new file mode 100644 index 0000000..482a834 --- /dev/null +++ b/assets/shaders/unshaded_textured.vert @@ -0,0 +1,7 @@ +//include commonVert.glsl version.glsl + +void main() +{ + gl_Position = transformPosition(vPosition); + setOutputs(); +} diff --git a/build/linux/makefile b/build/linux/makefile index 8372560..478a886 100644 --- a/build/linux/makefile +++ b/build/linux/makefile @@ -38,7 +38,7 @@ debug: pre_build $(OBJS_DEBUG) post_build -@$(CC) $(CFLAGS) -c $< -o $@ pre_build: - -@mkdir .debug .release + -@mkdir -p .debug .release post_build: -@ln -fs /mnt/Dev/Projects/symmetry/assets assets diff --git a/build/win_mingw64/makefile b/build/win_mingw64/makefile index d478f3f..89911cd 100644 --- a/build/win_mingw64/makefile +++ b/build/win_mingw64/makefile @@ -26,7 +26,7 @@ release: pre_build $(OBJS_RELEASE) post_build -@$(CC) $(CFLAGS) -c $< -o $@ pre_build: - -@mkdir .debug .release + -@mkdir -p .debug .release post_build: -@ln -fs /mnt/Dev/Projects/symmetry/assets assets diff --git a/orgfile.org b/orgfile.org deleted file mode 100644 index ac799ad..0000000 --- a/orgfile.org +++ /dev/null @@ -1,334 +0,0 @@ -#+AUTHOR:Shariq Shah -#+EMAIL:bluerriq@gmail.com -#+TITLE:Project Symmetry -* Project Symmetry - -** What? -A topdown 2D shooter exploring symmetry. - -** License -All the code in this repository is under GPLv3, see LICENSE for more information - -** File format specifications -*** Entity -# Comment, Sample entity definition in file, paremeters left out are set to defaults -# Empty line at the end specifies end of entity definition -entity: "Something" -position: 0 0 0 -scale: 1 1 1 -rotation: 0 0 0 1 -model: "suzanne.pamesh" -material: "blinn_phong" -diffuse_color: 1 0 0 1 -diffuse_texture: "checkered.tga" -specular: 0.55 - -- Add to_string functions for major structs like transform, model etc to ease in conversion? - -*** Configuration Variables a.k.a cfg-vars -# Comment -render_width: 1024 -render_height: 1024 -debug_draw_enabled: true -fog_color: 0.5 0.2 0.2 1 -# There can be comments or empty newlines in between unlike entity definitions - -ambient_light: 0.1 0.1 0.1 1 -msaa: true -msaa_levels: 8 - -*** Keybindings -# All keys are parsed by comparing the output of SDL_GetKeyname -# Each line represents a keybinding -Move_Forward: W - -# Multiple keys to a single binding are specified with commas -Move_Backward: S,Down - -# Combinations are specified with a hyphen/dash -# When specifing combinations, modifiers(shift, alt, ctrl) always come before -# the hyphen and the actual key comes afterwards. At the moment modifier keys are -# forced to be on the left side i.e. Left Control, Left Shift and Left Alt. -Quit: Left Ctrl-Q - -# Single modifier keys are allowed but multiple modifier keys without corresponding -# non-modifier key are not allowed -Sprint: Left Shift - -*** Level/Scene -- Binary format with header attached at the top -- Save child entities first -- Copy paste all entites in the file one by one. Since the entites all look - the same in memory and are made up of tagged unions, a simple memcpy approach - should suffice. The problem is entity heirarchies. There are multiple approaches to - solve this problem. - -- Save a sorted list of entites to file i.e. before saving create a new list that does - not have the empty array slots in the entity list and then just copy and paste. This - is the simplest way to solve the problem as we don't have to worry about indexes of - parent/child entites in heirarchy. We can take the whole array and paste it to the - file but creating a copy of entity list for this purpose only would be slow and consume a lot of memory. - -- Instead of creating a copy of the entity list for sorting and saving, sort the actual entity list - and update all references as necessary then save the array to file. - -- Just write the name of the parent entity as parent. Make sure that all entity names are unique. -*** Materials -*** Mesh/Geometry -** Notes on entity Systems -- Fat entites with all related properties, i.e. position, mesh etc in them. Easy to serialize, memory friendly, simple to implement - but would require significant changes to the current codebase. e.g. - struct Entity - { - int type; - char* name; - struct Transform {....}; - struct Camera {....}; - - // Separate properties unique to entity types by using unions - struct Renderable - { - struct Model {....}; - union - { - struct Player - { - int score; - int bullets; - }; - - struct Enemy - { - int target; - }; - } - } - }; -- Change component implementation by using anonymous unions to simulate interfaces. e.g - struct Component - { - int type; - union - { - struct Transform {....}; - struct Model {....}; - struct Camera {....}; - } - } -- Use handles for assets -- Use something similar to Variant to use as entity, not sure what or how -- Don't forget to think of the actual use-case and usage when coming up with a solution, don't build castles in the air! - -* Things TODO -** DONE Input - - State "DONE" from "TODO" [2015-07-02 Thu 01:24] -- Input maps (addition/removal) -- Adding removing keys to input maps -- Changing map na -** DONE Shaders - - State "DONE" from "TODO" [2015-07-11 Sat 17:57] -- set asset folder -- load/compile shader -** DONE Geometry - - State "DONE" from "TODO" [2015-07-11 Sat 17:57] -** DONE change struct usage - - State "DONE" from "TODO" [2015-07-21 Tue 15:13] -** DONE change Array implementation - - State "DONE" from "TODO" [2015-07-25 Sat 20:27] -** DONE resolve vec-types sizes - - State "DONE" from "TODO" [2015-07-25 Sat 20:27] -** DONE Transform - - State "DONE" from "TODO" [2015-07-26 Sun 18:01] -** DONE Deltatime - - State "DONE" from "TODO" [2015-07-27 Mon 11:54] -** DONE Investigate about Exit() and at_exit() functions and whether to use them or not. - - State "DONE" from "TODO" [2015-08-02 Sun 19:09] -** DONE Fix readme markdown -- State "DONE" from "TODO" [2015-12-10 Thu 16:36] -** DONE Framebuffer and resolution independent rendering -- State "DONE" from "TODO" [2016-05-27 Fri 18:02] -** DONE A simpler build system without dependencies -- State "DONE" from "TODO" [2016-05-27 Fri 14:50] -** DONE Remove dependencies -- State "DONE" from "TODO" [2017-02-26 Sun 01:46] -- glfw3 -- glew -** DONE Remove Kazmath dependency -- State "DONE" from "TODO" [2015-12-10 Thu 16:36] -** DONE Entity -- State "DONE" from "TODO" [2015-09-15 Tue 12:17] -** TODO Positive and negative values for input_maps and returning corresponding values when they are true -** DONE Find a permanent solution for build system -- State "DONE" from "TODO" [2017-03-15 Wed 00:59] -** TODO Text rendering using freetype or stb lib -** DONE Textures -- State "DONE" from "TODO" [2015-10-09 Fri 18:47] -** DONE Camera -- State "DONE" from "TODO" [2015-08-19 Wed 13:30] -** DONE Test render -- State "DONE" from "TODO" [2015-08-19 Wed 13:30] -** TODO Bounding Boxes -- Recalculated bounding boxes for rotated meshes? -** DONE Fix input lag and other framerate related issues -- State "DONE" from "TODO" [2017-05-07 Sun 18:40] -** TODO File extension checking for asset loading -** DONE Materials -- State "DONE" from "TODO" [2015-10-13 Tue 19:38] -** DONE Mesh/Model -- State "DONE" from "TODO" [2015-10-13 Tue 19:38] -** DONE Add modifiers to input maps to enable combinations for example, c-x, m-k etc -- State "DONE" from "TODO" [2017-05-20 Sat 21:54] -** TODO Only allocate hashmap bucket when required -** TODO Mapping actions to keybindings, for example map action "Jump" to Space key etc -** DONE Heirarchical Transforms -** DONE Materials with textures -- State "DONE" from "TODO" [2015-10-15 Thu 21:21] -** DONE Lights! -- State "DONE" from "TODO" [2017-03-14 Tue 00:31] -** DONE Fix problems with texture units -- State "DONE" from "TODO" [2016-05-30 Mon 00:57] -** CANCELED Draw light volumes -- State "CANCELED" from "TODO" [2017-02-26 Sun 15:39] \\ - Deferred rendering on hold for now. -** DONE Fix problems with frustrum culling -- State "DONE" from "TODO" [2017-03-26 Sun 01:33] -** TODO 2d drawing routines -- Sprite batching -** DONE Gui -- State "DONE" from "TODO" [2017-03-15 Wed 23:41] -** CANCELED Image based lighting? -- State "CANCELED" from "TODO" [2017-03-14 Tue 00:31] \\ - Not a requirement for current project -** CANCELED Deferred rendering? -- State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\ - Sticking with forward rendering for now and focusing on tools etc. -** DONE Fix mouse bugs on windows -- State "DONE" from "TODO" [2017-03-25 Sat 17:27] -** DONE Configuration/Settings load/save handling -- State "DONE" from "TODO" [2017-05-20 Sat 21:54] -** DONE Fix mousewheel bugs and gui not responding to mousewheel input -- State "DONE" from "TODO" [2017-03-19 Sun 01:31] -** TODO Ability to mark meshes for debug rendering with possibility of different color for each? -** TODO Switch to completely static allocation of entites i.e. have a static array of MAX_ENTITIES size. This way we can store pointers to entites and they'll still be in an array and fast to process. -** DONE Setup cross compilation with mingw or stick to msvc? -- State "DONE" from "TODO" [2017-05-20 Sat 21:55] -- Done, going with mingw for now. -** TODO Add marking or queuing up custom meshes for debug render with particular transform and color for rendering bounding spheres for example -** DONE Toggleable debug drawing for meshes -- State "DONE" from "TODO" [2017-03-18 Sat 16:18] -** TODO Interleaved vbos for meshes and changes to blender exporter accordingly -** TODO Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? -** TODO Physics/Collision detection in 2d -** TODO Complete gui integration -x Font selection -x Font atlas proper cleanup -- Decoupled event handling of gui and input if possible -- Custom rendering for gui -** TODO Allow passsing base path as commandline argument? -** TODO Remove components and switch to "Fat Entities" i.e. one entity struct contains all combinations -** TODO Use variants for material params -** TODO Improve Material Parameters/Pipeline Uniforms/Instance Uniforms are handled -** TODO Fix light rotation/direction bugs -** DONE In second refactor pass, use entities everywhere, no need to pass in transform and model separately for example since they're both part of the same entity anyway -- State "DONE" from "TODO" [2017-05-31 Wed 21:44] -** DONE Show SDL dialogbox if we cannot launch at all? -- State "DONE" from "TODO" [2017-05-26 Fri 00:41] -** DONE Writing back to config file -- State "DONE" from "TODO" [2017-05-08 Mon 00:57] -** DONE Reading from config file -- State "DONE" from "TODO" [2017-05-07 Sun 23:52] -** DONE Variant -> String conversion procedure. Use in editor for debug var slots -- State "DONE" from "TODO" [2017-05-07 Sun 18:43] -** DONE Add strings and booleans to variant types -- State "DONE" from "TODO" [2017-03-29 Wed 00:23] -** DONE Fix Key release not being reported -- State "DONE" from "TODO" [2017-03-26 Sun 01:16] -** TODO Better handling incase assets folder is not found? -** TODO Write entity to/from file -** DONE OpenAL not working in releasebuilds -- State "DONE" from "TODO" [2017-03-25 Sat 02:06] -** DONE 3d sound using OpenAL -- State "DONE" from "TODO" [2017-03-23 Thu 01:43] -** TODO Ogg format loading and playback -** TODO Stick with OpenAL or switch to SoLoud + SDL for sound? -** TODO Sound streaming -** TODO Implment missing sound source properties (inner/outer cone, getting sound source data) -** TODO Ingame console and console commands etc -** TODO Allow binding/unbinding input maps to functions at runtime, for example if input map "Recompute" is triggered, it would call some function that can recompute bounding spheres. -** TODO Better handling of wav format checking at load time -** DONE Fix frustum culling bugs -- State "DONE" from "TODO" [2017-05-31 Wed 23:38] -** DONE Array-based Hashmaps -- State "DONE" from "TODO" [2017-05-07 Sun 18:42] -** TODO Sprite sheet animations -** DONE Fix bugs with heirarchical transformations -- State "DONE" from "TODO" [2017-06-01 Thu 00:20] -** TODO Replace orgfile with simple text readme and reduce duplication? -** TODO Ray picking -** DONE Remove reduntant "settings" structures and move all configuration stuff to config variables -- State "DONE" from "TODO" [2017-06-05 Mon 02:25] -** TODO Shadow maps -** DONE Log output to file on every run -- State "DONE" from "TODO" [2017-05-26 Fri 00:41] -** TODO Print processor stats and machine capabilites RAM etc on every run to log. -** TODO Milestone: Pong! -- In order to put things into perspective and get a feel for what really needs to be prioritized, a very small but actual game release is necessary. -- Release platforms: Windows and Linux -- Makefile additions. Try to compile game as a dynamically loaded library with ability to reload on recompile -- Separation between game and engine base -? Game .so with init, update and cleanup functions -x Configuration files and "cvars" load/reload -x Keybindings in config -x Log output on every run. -- Implement entity load/save to file -? Prefab load/save to file -** TODO Do input maps really need to be queried by their string names? -** TODO Reloading all the things! (textures/shaders/models/settings/entities etc) -** TODO Separate Debug/Editor camera from the active camera in the scene that can be switched to at any time -** TODO Make logging to file and console toggleable at complie-time or run-time -** DONE Add option to specify where to read/write files from instead of being hard-coded assets dir -- State "DONE" from "TODO" [2017-05-24 Wed 17:12] -** TODO Add default keybindings -** TODO Write default config/keybindings etc to file if none are found in preferences dir -** DONE Fix input map bugs -- State "DONE" from "TODO" [2017-05-31 Wed 23:19] -** TODO Wrap malloc and free calls in custom functions to track usage -** TODO Flatpak packaging for linux releases -** TODO Use hashmap for debugvar slots in editor -** TODO Use hashmap to store input maps -** DONE Live data views in editor -- State "DONE" from "TODO" [2017-03-22 Wed 02:14] -** DONE Camera resize on window reisze -- State "DONE" from "TODO" [2017-03-20 Mon 15:22] -** DONE Resizable framebuffers and textures -- State "DONE" from "TODO" [2017-03-16 Thu 22:50] -** DONE Support for multiple color attachments in framebuffers? -- State "DONE" from "TODO" [2017-03-16 Thu 22:51] -** TODO Multisampled textures and framebuffers -** DONE Better way to store and manage textures attached to framebuffers -- State "DONE" from "TODO" [2017-03-16 Thu 22:51] -** TODO Validate necessary assets at game launch -** TODO Gamma correctness -** DONE Variant type -- State "DONE" from "TODO" [2017-03-22 Wed 02:14] -** TODO Log and debug/stats output in gui -** TODO Editor automatic window layout adjusting to the current window resolution -** DONE Editor -- State "DONE" from "TODO" [2017-06-20 Tue 01:12] -** TODO Event Subsystem -** TODO Keybindings for gui? -** TODO Textual/Binary format for data serialization and persistance -** TODO Better logging -** TODO Hatching/Ink rendering style -** DONE Fix frustum culling sometimes not working -- State "DONE" from "TODO" [2017-03-25 Sat 19:10] -** DONE Compile and test on windows -- State "DONE" from "TODO" [2017-03-14 Tue 00:32] -** TODO Array based string type comptible with cstring(char*) -** TODO Separate game, engine and assets into different repositories. Combine as sub-repositories -** DONE Fix mouse bugs -- State "DONE" from "TODO" [2017-03-01 Wed 00:45] -** DONE Fix -** DONE issues with opengl context showing 2.1 only -- State "DONE" from "TODO" [2017-03-19 Sun 14:03] -- State "DONE" from "TODO" [2017-02-26 Sun 15:39] -** TODO Improve this readme -** TODO ??? -** TODO Profit! diff --git a/src/editor.c b/src/editor.c index a547137..028baf0 100644 --- a/src/editor.c +++ b/src/editor.c @@ -20,6 +20,7 @@ #include "file_io.h" #include "config_vars.h" #include "string_utils.h" +#include "platform.h" #include #include @@ -193,11 +194,9 @@ void editor_update(float dt) nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps); nk_group_end(context); } - static float main_editor_ratios[] = {0.2f, 0.6f, 0.2f}; - nk_layout_row(context, NK_DYNAMIC, win_height - editor_state.top_panel_height, sizeof(main_editor_ratios) / sizeof(float), main_editor_ratios); - + nk_layout_row(context, NK_DYNAMIC, win_height - editor_state.top_panel_height, sizeof(main_editor_ratios) / sizeof(float), main_editor_ratios); /* Left */ if(nk_group_begin(context, "Editor Left", NK_WINDOW_SCROLL_AUTO_HIDE)) { diff --git a/src/game.c b/src/game.c index bd7996e..f736330 100644 --- a/src/game.c +++ b/src/game.c @@ -39,7 +39,7 @@ #define MAX_FRAME_TIME 0.5f static int run(void); -static void update(float dt, int* window_should_close); +static void update(float dt, bool* window_should_close); static void render(void); static void debug(float dt); static void debug_gui(float dt); @@ -312,7 +312,7 @@ void debug(float dt) int run(void) { uint32 last_time = platform_ticks_get(); - int should_window_close = 0; + bool should_window_close = 0; while(!should_window_close) { uint32 curr_time = platform_ticks_get(); @@ -332,9 +332,9 @@ int run(void) return 1; } -void update(float dt, int* window_should_close) +void update(float dt, bool* window_should_close) { - if(input_is_key_pressed(KEY_ESCAPE)) *window_should_close = 1; + if(input_is_key_pressed(KEY_ESCAPE)) *window_should_close = true; if(input_map_state_get("Editor_Toggle", KS_RELEASED)) editor_toggle(); if(input_map_state_get("Window_Fullscreen", KS_RELEASED)) window_fullscreen_set(game_state->window, 1); if(input_map_state_get("Window_Maximize", KS_RELEASED)) window_fullscreen_set(game_state->window, 0); @@ -369,12 +369,12 @@ void debug_gui(float dt) /* window flags */ window_flags = 0; ctx->style.window.header.align = header_align; - if (border) window_flags |= NK_WINDOW_BORDER; - if (resize) window_flags |= NK_WINDOW_SCALABLE; - if (movable) window_flags |= NK_WINDOW_MOVABLE; - if (no_scrollbar) window_flags |= NK_WINDOW_NO_SCROLLBAR; - if (scale_left) window_flags |= NK_WINDOW_SCALE_LEFT; - if (minimizable) window_flags |= NK_WINDOW_MINIMIZABLE; + if(border) window_flags |= NK_WINDOW_BORDER; + if(resize) window_flags |= NK_WINDOW_SCALABLE; + if(movable) window_flags |= NK_WINDOW_MOVABLE; + if(no_scrollbar) window_flags |= NK_WINDOW_NO_SCROLLBAR; + if(scale_left) window_flags |= NK_WINDOW_SCALE_LEFT; + if(minimizable) window_flags |= NK_WINDOW_MINIMIZABLE; if (nk_begin(ctx, "Overview", nk_rect(70, 70, 400, 600), window_flags)) { diff --git a/src/game.h b/src/game.h index 5474e56..2ee0422 100644 --- a/src/game.h +++ b/src/game.h @@ -1,7 +1,9 @@ #ifndef GAME_H #define GAME_H -#include "platform.h" +#include + +struct Window; struct Game_State { diff --git a/src/linmath.h b/src/linmath.h index d9c065e..ffb6ceb 100644 --- a/src/linmath.h +++ b/src/linmath.h @@ -10,8 +10,10 @@ i'll make my own additions like SIMD etc later on. */ /* conversions */ +#ifndef M_PI + #define M_PI 3.14159265358979323846 +#endif #define EPSILON 0.0001 -#define M_PI 3.14159265358979323846 #define TO_RADIANS(degrees) ((degrees * M_PI) / 180.0) #define TO_DEGREES(radians) ((radians * 180.0) / M_PI) diff --git a/src/platform.c b/src/platform.c index 991f4fc..bf23b77 100644 --- a/src/platform.c +++ b/src/platform.c @@ -207,7 +207,7 @@ void platform_cleanup(void) SDL_Quit(); } -void platform_poll_events(int* out_quit) +void platform_poll_events(bool* out_quit) { static SDL_Event event; while(SDL_PollEvent(&event) != 0) diff --git a/src/platform.h b/src/platform.h index 1d0a4fc..c715f5d 100644 --- a/src/platform.h +++ b/src/platform.h @@ -29,7 +29,7 @@ int window_fullscreen_set(struct Window* window, int fullscreen); // Platform functions int platform_init(void); void platform_cleanup(void); -void platform_poll_events(int* out_quit); +void platform_poll_events(bool *out_quit); void platform_keyboard_callback_set(Keyboard_Event_Func func); void platform_mousebutton_callback_set(Mousebutton_Event_Func func); void platform_mousemotion_callback_set(Mousemotion_Event_Func func); diff --git a/src/sound.c b/src/sound.c index 8323508..9bd7b33 100644 --- a/src/sound.c +++ b/src/sound.c @@ -46,8 +46,7 @@ bool sound_init(void) if(!sound_state.context) alcDestroyContext(sound_state.context); alcCloseDevice(sound_state.device); log_error("sound:init", "Could not set sound context"); - return success; - + return success; } log_message("Opened %s", alcGetString(sound_state.device, ALC_DEVICE_SPECIFIER));