{"id":18048274,"url":"https://github.com/relintai/sfw","last_synced_at":"2025-04-10T09:51:01.952Z","repository":{"id":213140368,"uuid":"733120085","full_name":"Relintai/sfw","owner":"Relintai","description":"Simple c++ app / game framework.","archived":false,"fork":false,"pushed_at":"2025-03-23T17:57:42.000Z","size":5131,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T18:35:09.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Relintai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-18T15:55:34.000Z","updated_at":"2025-03-23T17:57:47.000Z","dependencies_parsed_at":"2024-01-18T02:09:55.603Z","dependency_job_id":"b1f71279-a860-4516-9cb4-35fc9a8475a1","html_url":"https://github.com/Relintai/sfw","commit_stats":null,"previous_names":["relintai/sfw"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fsfw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fsfw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fsfw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fsfw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Relintai","download_url":"https://codeload.github.com/Relintai/sfw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248197751,"owners_count":21063621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T20:12:17.075Z","updated_at":"2025-04-10T09:51:01.933Z","avatar_url":"https://github.com/Relintai.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SFW - Simple Framework\n\nSimple c++ app / game framework inspired by the single file c game engines \nand libraries, especially [FWK](https://github.com/r-lyeh/FWK).\n\nIt was designed to help with teaching programming, but it turns out it's pretty useful for other projects aswell.\n\nThis library / framework is:\n- Simple to compile.\n- Simple to initialize.\n- Simple to use.\n- Supports windowing and opengl (ES2).\n- Modular (within reason).\n- It is desktop only (Windows, Linux, OSX) for now (most code is multiplatform though).\n\nAlso:\n- The codebase is simple and easy to read.\n- Comes with it's own container classes and memory management.\n- Comes as 2 (or 3) merged files. (This way it's actually simpler to use and setup compared to if it was single header!)\n- It does not use exceptions.\n\nA lite version is also available (sfwl).\n\n## Modules\n\nCurrently the framework contains 5 modules, they are additive:\n\n### Core\n\nHas:\n- Typedefs\n- Math defines, and a class\n- Logging, and error macros\n- Math helper classes (like Vector2, Vector3, Projection, Transform etc.)\n- Containers\n- Memory management\n- Threading\n- Subprocess handling\n- Sockets\n- Strings\n- File and Directory handling\n\nDoes not depend on anything.\n\n### Object\n\nHas:\n- Object, Reference, Resource classes\n- Variant class that can store anything\n- Signal class\n\nDepends on Core.\n\n### Render Core\n\nA c++ abstraction over the opengl api.\n\nHas:\n- Shaders\n- Materials\n- Meshes\n- Windowing\n- Fonts\n- Images\n- Textures\n- FrameBuffers\n- Input handling\n- An Application and a Scene class for easier development\n\nDepends on Core and Object.\n\n### Render Immediate\n\nContains a simple immediate renderer class. (called Renderer.)\n\nDepends on Core, Object and Render Core.\n\n### Render Object\n\nContains a class based renerer api.\n\nHas classes like:\n- Camera2D\n- Camera3D\n- MeshInstance 2D/3D\n- Text2D\n- TileMap\n- Etc.\n\nDepends on Core, Object and Render Core.\n\n### GUI\n\nContains the Dear ImGui GUI toolkit.\n\nDepends on Core, Object and Render Core.\n\n## SFWL\n\nThe library's lite version.\n\nSame as the normal library except the math helper classes were removed (except for Vector2i, and Rect2i).\n\nIt only has 2 modules, Core, and Objects.\n\n## Compilation without the renderer\n\nIf you don't need the renderer then everything is extremely simple.\n\nFirst grab a version that does not have the renderer.\n\nNow you have 2 files: `sfw.h` and `sfw.cpp` or `sfwl.h` and `sfwl.cpp` depending on your choice.\n\nIf you use an ide, just add these files to your project (so the .cpp file gets compiled), and you are done.\n\nIf you are using a compiler directly, then just add `sfw.cpp` or `sfwl.cpp` to the list of files that you are compiling:\n\ng++ / mingw:\n\n```\ng++ -g sfwl.cpp main.cpp -o prog \n```\n\nNote: -g means add debug information to the executable.\n\nMSVC:\n\n```\ncl /Zi /EHsc /Feprog-vc.exe sfw.cpp main.cpp\n```\n\nNote: /Zi means add debug information to the executable.\n\nIf you are creating object files:\n\ng++ / mingw:\n\n```\ng++ -g -c sfw.cpp -o sfw.o\ng++ -g -c main.cpp -o main.o\n\ng++ -g sfw.o main.o -o prog\n```\n\nMSVC:\n\n```\ncl /EHsc /Zi /c sfw.cpp /Fo:sfw.obj\ncl /EHsc /Zi /c main.cpp /Fo:main.obj\n\ncl /Zi /EHsc /Feprog-vc.exe sfw.obj main.obj\n```\n\nNote: You might need to set c++14 level compatibility depending on your compiler. While the codebase is somwhere between \nc++89 and c++11, threads use classes from the std namespace that were added in c++14. Nowadays these are usually available \nwithout any special setting, but if your compiler is older (or set differently) you might need to add something like: \n`-std=c++14` to your compile commands.\n\n## Compilation with the renderer\n\nIf you also want the renderer, first set everything up exactly as in the \"Compilation without the renderer\" section, \nexcept you will have 3 files: `sfw.h` and `sfw.cpp`, and `sfw_3rd.m` (this is actually a c header file, it has \nthe extencion `.m` to make OSX builds easier).\n\nAs a second step we need to tell the linker to link to some of the libraries in the system dynamically in order to\nopen windows and use opengl.\n\n### MSVC (Windows)\n\nIf you are using MSVC you are actually done, no need to do anything else as MSVC has a nice feature where \nthis can be done automatically. Search the codebase for `#pragma comment` to see the libraries that get linked.\n\n### MingW\n\nIf you are using mingw (If you use the g++ command on windows, that is MingW!), this is how your last (linking) command changes:\n\n```\ng++ -g sfw.cpp main.cpp -lgdi32 -lShlwapi -lws2_32 -o prog \n```\n\nOr\n\n```\ng++ -g sfw.o main.o -lgdi32 -lShlwapi -lws2_32 -o prog\n```\n\nNote the position of the `-l` commands, add those after your object (or .cpp) files.\n\nAlso, you don't need to add these to the other steps that does not create the final executable.\n\nNote if you use clang, just replacing `g++` to `clang++` or `clang` should work.\n\n### Linux (G++ / clang)\n\nOn debian based distributions run the following command to make sure that dependencies are installed:\n\n```\nsudo apt-get install libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev\n```\n\nArch based systems should have these by default. For other distros consult the manual and / or the internet\nto see which packages are the equivalent of the ones listed above.\n\n\nThis is how your last (linking) command changes:\n\n```\ng++ -g sfw.cpp main.cpp -lX11 -o prog \n```\n\nOr\n\n```\ng++ -g sfw.o main.o -lX11 -o prog\n```\n\nNote the position of the `-l` command, add those after your object (or .cpp) files.\n\nSome g++ versions seem a lot more leanient, for example on Manjaro as of this writing \n`g++ -g -lX11 sfw.o main.o -o prog` works, but on the Raspberry pi (Raspian) it doesn't.\n\nAlso, you don't need to add these to the other steps that does not create the final executable.\n\nNote if you use clang, just replacing `g++` to `clang++` or `clang` should work.\n\n### OSX (clang)\n\nIf you need the renderer you will need to use clang on OSX.\n\nFirst we need to setup SDK paths:\n\n```\nexport SDKROOT=$(xcrun --show-sdk-path)\n```\n\nSet up some helper variables: \n\n```\nexport cpp_args=\"-std=c++14 -w -framework cocoa -framework iokit -framework CoreFoundation -framework CoreAudio -framework AudioToolbox \"\nexport m_args=\"-w -framework cocoa -framework iokit -framework CoreFoundation -framework CoreAudio -framework AudioToolbox \"\n```\n\nOn OSX sfw_3rd.m need to be compiled manually, separately:\n\n(This is a workaround, because Objective-C and C++ code doesn't mix in a single file, but Objective-C and C does.)\n\n```\nclang++ -w $m_args -g -c sfw_3rd.m -o sfw_3rd.o\n```\n\nNow just compile everything else to objects:\n\n```\nclang++ $cpp_args -g -c sfw.cpp -o sfw.o\nclang++ $cpp_args -g -c game_scene.cpp -o game_scene.o\nclang++ $cpp_args -g -c main.cpp -o main.o\n```\n\nThen just link them together:\n\n```\nclang++ $cpp_args -g sfw.o sfw_3rd.o game_scene.o main.o -o game \n```\n\n## CompileDB\n\nIf you want to edit the split version of the framework in the `sfw` or `sfwl` folder and you\nwant to generate a compiledb, currently the simples solution that I know of is to install \nthe `compiledb` python module and just use it with the makefile in the root of the project.\n\nCreate virtual env:\n\n``` python -m venv venv ```\n\nActivate it (This is for bash on linux).\n\nCommands for other shells: https://docs.python.org/3/library/venv.html#how-venvs-work\n\n``` . ./venv/bin/activate ```\n\nInstall:\n\n``` pip install compiledb ```\n\nRun compiledb with make to generate compile_commands.json\n\n``` compiledb make ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelintai%2Fsfw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frelintai%2Fsfw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelintai%2Fsfw/lists"}