├── .gitattributes ├── .github └── workflows │ └── build.yaml ├── .gitignore ├── .vscode ├── app.drawio ├── c_cpp_properties.json ├── commandbar.json ├── issues.todo ├── launch.json ├── settings.json ├── tasks.json └── todo.todo ├── LICENSE ├── Makefile ├── README.md ├── config.ini ├── imgui.ini ├── include ├── SDL.h ├── SDL_assert.h ├── SDL_atomic.h ├── SDL_audio.h ├── SDL_bits.h ├── SDL_blendmode.h ├── SDL_clipboard.h ├── SDL_config.h ├── SDL_cpuinfo.h ├── SDL_egl.h ├── SDL_endian.h ├── SDL_error.h ├── SDL_events.h ├── SDL_filesystem.h ├── SDL_gamecontroller.h ├── SDL_gesture.h ├── SDL_guid.h ├── SDL_haptic.h ├── SDL_hidapi.h ├── SDL_hints.h ├── SDL_image.h ├── SDL_joystick.h ├── SDL_keyboard.h ├── SDL_keycode.h ├── SDL_loadso.h ├── SDL_locale.h ├── SDL_log.h ├── SDL_main.h ├── SDL_messagebox.h ├── SDL_metal.h ├── SDL_misc.h ├── SDL_mouse.h ├── SDL_mutex.h ├── SDL_name.h ├── SDL_opengl.h ├── SDL_opengl_glext.h ├── SDL_opengles.h ├── SDL_opengles2.h ├── SDL_opengles2_gl2.h ├── SDL_opengles2_gl2ext.h ├── SDL_opengles2_gl2platform.h ├── SDL_opengles2_khrplatform.h ├── SDL_pixels.h ├── SDL_platform.h ├── SDL_power.h ├── SDL_quit.h ├── SDL_rect.h ├── SDL_render.h ├── SDL_revision.h ├── SDL_rwops.h ├── SDL_scancode.h ├── SDL_sensor.h ├── SDL_shape.h ├── SDL_stdinc.h ├── SDL_surface.h ├── SDL_system.h ├── SDL_syswm.h ├── SDL_test.h ├── SDL_test_assert.h ├── SDL_test_common.h ├── SDL_test_compare.h ├── SDL_test_crc32.h ├── SDL_test_font.h ├── SDL_test_fuzzer.h ├── SDL_test_harness.h ├── SDL_test_images.h ├── SDL_test_log.h ├── SDL_test_md5.h ├── SDL_test_memory.h ├── SDL_test_random.h ├── SDL_thread.h ├── SDL_timer.h ├── SDL_touch.h ├── SDL_ttf.h ├── SDL_types.h ├── SDL_version.h ├── SDL_video.h ├── SDL_vulkan.h ├── begin_code.h └── close_code.h ├── lib ├── cmake │ ├── SDL2 │ │ ├── sdl2-config-version.cmake │ │ └── sdl2-config.cmake │ ├── SDL2_image │ │ ├── sdl2_image-config-version.cmake │ │ └── sdl2_image-config.cmake │ └── SDL2_ttf │ │ ├── sdl2_ttf-config-version.cmake │ │ └── sdl2_ttf-config.cmake ├── libSDL2.a ├── libSDL2.dll.a ├── libSDL2.la ├── libSDL2_image.a ├── libSDL2_image.dll.a ├── libSDL2_image.la ├── libSDL2_test.a ├── libSDL2_test.la ├── libSDL2_ttf.a ├── libSDL2_ttf.dll.a ├── libSDL2_ttf.la ├── libSDL2main.a ├── libSDL2main.la └── pkgconfig │ ├── SDL2_image.pc │ ├── SDL2_ttf.pc │ └── sdl2.pc ├── media ├── $05151959.gif ├── commandbar.png └── interface.png ├── res ├── atlas.aseprite ├── font │ ├── arial.TTF │ ├── jetbrains.ttf │ └── pixolleta.ttf ├── icon │ ├── icon.ico │ ├── icon.rc │ └── icon.res ├── logo.aseprite ├── main.aseprite ├── main_scene.aseprite ├── new_scene.aseprite ├── sprites │ ├── Slice 1.png │ ├── core │ │ ├── logger.png │ │ └── logo.png │ ├── file.png │ ├── file_selected.png │ ├── folder.png │ ├── folder_selected.png │ ├── hover.png │ ├── main_scene.png │ ├── new_file.png │ ├── ready_bar.png │ ├── stop_bar.png │ └── stop_vfx.png └── spritesheet.aseprite ├── scripts_dlls ├── SDL2.dll ├── SDL2_image.dll ├── SDL2_ttf.dll ├── installer.nsi ├── modern_installer.nsi ├── setup.bat ├── ship.bat ├── update_res.bat └── windows_installer_translations.nsi ├── settings.ini └── src ├── Core ├── App.cpp ├── App.hpp ├── Assert.h ├── DataLoader.cpp ├── DataLoader.hpp ├── IniHandler.cpp ├── IniHandler.hpp └── main.cpp ├── Entity ├── Enemy.cpp ├── Enemy.hpp ├── Entity.cpp ├── Entity.hpp ├── FileEntity.cpp └── FileEntity.hpp ├── ImGui ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_demo.cpp ├── imgui_draw.cpp ├── imgui_impl_sdl.cpp ├── imgui_impl_sdl.h ├── imgui_impl_sdlrenderer.cpp ├── imgui_impl_sdlrenderer.h ├── imgui_internal.h ├── imgui_tables.cpp ├── imgui_widgets.cpp ├── imstb_rectpack.h ├── imstb_textedit.h ├── imstb_truetype.h ├── tinyfiledialogs.cpp └── tinyfiledialogs.h ├── Renderer ├── AppGui.cpp ├── AppGui.hpp ├── AssetsObject.hpp ├── Atlas.cpp ├── Atlas.hpp ├── Camera.cpp ├── Camera.hpp ├── EntityRenderer.cpp ├── EntityRenderer.hpp ├── ParticleSystem.cpp └── ParticleSystem.hpp ├── Resources ├── AssetData.cpp ├── AssetData.hpp ├── Resources.cpp └── Resources.hpp ├── Scenes ├── GameScene.cpp ├── GameScene.hpp ├── IntroScene.cpp ├── IntroScene.hpp ├── MainScene.cpp ├── MainScene.hpp ├── PartialScene.cpp ├── PartialScene.hpp ├── Scene.cpp ├── Scene.hpp ├── Scenes.hpp ├── TestPartialScene.cpp └── TestPartialScene.hpp ├── Tools ├── Cooldown.cpp ├── Cooldown.hpp ├── Logger.cpp ├── Logger.hpp ├── Reader.cpp └── Reader.hpp └── Utils ├── Common.hpp ├── Gizmos.cpp ├── Gizmos.hpp ├── Math.cpp ├── Math.hpp ├── Mouse.cpp ├── Mouse.hpp ├── Sprite.hpp ├── inicpp.h └── random.hpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: C++ SDL Build and Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | build: 13 | runs-on: windows-latest 14 | 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Build application 20 | run: make compile 21 | -------------------------------------------------------------------------------- /.vscode/app.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Win32", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "${workspaceFolder}/*", 8 | "${workspaceFolder}/include" 9 | ], 10 | "defines": [ 11 | "_DEBUG", 12 | "UNICODE", 13 | "_UNICODE" 14 | ], 15 | "windowsSdkVersion": "10.0.19041.0", 16 | "compilerPath": "C:/mingw64/bin/g++.exe", 17 | "cStandard": "c17", 18 | "cppStandard": "c++17", 19 | "intelliSenseMode": "windows-msvc-x64", 20 | "configurationProvider": "ms-vscode.makefile-tools" 21 | } 22 | ], 23 | "version": 4 24 | } -------------------------------------------------------------------------------- /.vscode/commandbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "skipTerminateQuickPick": true, 3 | "skipSwitchToOutput": false, 4 | "skipErrorMessage": true, 5 | "commands": [ 6 | { 7 | "text": "⚙️ First setup", 8 | "color": "#cfdd40", 9 | "command": "${workspaceFolder}/scripts_dlls/setup.bat", 10 | "alignment": "right", 11 | "skipTerminateQuickPick": false, 12 | "priority": 0 13 | }, 14 | { 15 | "text": "🚀 Update res", 16 | "color": "#cfdd40", 17 | "command": "${workspaceFolder}/scripts_dlls/update_res.bat", 18 | "alignment": "right", 19 | "skipTerminateQuickPick": false, 20 | "priority": 0 21 | }, 22 | { 23 | "text": "💼 Debug", 24 | "color": "#cfdd40", 25 | "command": "mingw32-make -j debug", 26 | "alignment": "right", 27 | "skipTerminateQuickPick": false, 28 | "priority": 0 29 | }, 30 | { 31 | "text": "💼 Build", 32 | "color": "#cfdd40", 33 | "command": "${workspaceFolder}/scripts_dlls/ship.bat", 34 | "alignment": "right", 35 | "skipTerminateQuickPick": false, 36 | "priority": 0 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /.vscode/issues.todo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/.vscode/issues.todo -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(Windows) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${workspaceFolder}/.build/twitter-gif-maker_debug.exe", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "sourceFileMap": { 12 | "${workspaceFolder}/.build": "${workspaceFolder}\\bin" 13 | }, 14 | "cwd": "${workspaceFolder}", 15 | "environment": [{ "name": "config", "value": "Debug" }], 16 | "miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe", 17 | "MIMode": "gdb", 18 | "setupCommands": [ 19 | { 20 | "description": "Enable pretty-printing for gdb", 21 | "text": "-enable-pretty-printing", 22 | "ignoreFailures": true 23 | }, 24 | { 25 | "description": "Set Disassembly Flavor to Intel", 26 | "text": "-gdb-set disassembly-flavor intel", 27 | "ignoreFailures": true 28 | } 29 | ], 30 | "externalConsole": false, 31 | "windows": { 32 | "program": "${workspaceFolder}/.build/twitter-gif-maker_debug.exe", 33 | "stopAtEntry": false 34 | }, 35 | "preLaunchTask": "build" 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "algorithm": "cpp", 4 | "atomic": "cpp", 5 | "bit": "cpp", 6 | "cctype": "cpp", 7 | "clocale": "cpp", 8 | "cmath": "cpp", 9 | "codecvt": "cpp", 10 | "compare": "cpp", 11 | "concepts": "cpp", 12 | "cstddef": "cpp", 13 | "cstdint": "cpp", 14 | "cstdio": "cpp", 15 | "cstdlib": "cpp", 16 | "cstring": "cpp", 17 | "ctime": "cpp", 18 | "cwchar": "cpp", 19 | "exception": "cpp", 20 | "fstream": "cpp", 21 | "functional": "cpp", 22 | "initializer_list": "cpp", 23 | "ios": "cpp", 24 | "iosfwd": "cpp", 25 | "iostream": "cpp", 26 | "istream": "cpp", 27 | "iterator": "cpp", 28 | "limits": "cpp", 29 | "list": "cpp", 30 | "locale": "cpp", 31 | "map": "cpp", 32 | "memory": "cpp", 33 | "new": "cpp", 34 | "optional": "cpp", 35 | "ostream": "cpp", 36 | "ratio": "cpp", 37 | "set": "cpp", 38 | "sstream": "cpp", 39 | "stdexcept": "cpp", 40 | "streambuf": "cpp", 41 | "string": "cpp", 42 | "system_error": "cpp", 43 | "tuple": "cpp", 44 | "type_traits": "cpp", 45 | "typeinfo": "cpp", 46 | "unordered_map": "cpp", 47 | "utility": "cpp", 48 | "vector": "cpp", 49 | "xfacet": "cpp", 50 | "xhash": "cpp", 51 | "xiosbase": "cpp", 52 | "xlocale": "cpp", 53 | "xlocbuf": "cpp", 54 | "xlocinfo": "cpp", 55 | "xlocmes": "cpp", 56 | "xlocmon": "cpp", 57 | "xlocnum": "cpp", 58 | "xloctime": "cpp", 59 | "xmemory": "cpp", 60 | "xstddef": "cpp", 61 | "xstring": "cpp", 62 | "xtr1common": "cpp", 63 | "xtree": "cpp", 64 | "xutility": "cpp", 65 | "filesystem": "cpp", 66 | "array": "cpp", 67 | "mutex": "cpp", 68 | "regex": "cpp", 69 | "stop_token": "cpp", 70 | "thread": "cpp", 71 | "charconv": "cpp", 72 | "format": "cpp", 73 | "chrono": "cpp", 74 | "forward_list": "cpp", 75 | "iomanip": "cpp", 76 | "random": "cpp", 77 | "*.tcc": "cpp", 78 | "cstdarg": "cpp", 79 | "cwctype": "cpp", 80 | "deque": "cpp", 81 | "memory_resource": "cpp", 82 | "numeric": "cpp", 83 | "string_view": "cpp", 84 | "numbers": "cpp", 85 | "span": "cpp", 86 | "cinttypes": "cpp", 87 | "variant": "cpp", 88 | "semaphore": "cpp" 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "type": "shell", 7 | "command": "mingw32-make", 8 | "args": ["-j", "debug", "DEBUG=true"], 9 | "group": "build", 10 | "problemMatcher": [] 11 | }, 12 | { 13 | "type": "cppbuild", 14 | "label": "C/C++: g++.exe build active file", 15 | "command": "C:/mingw64/bin/g++.exe", 16 | "args": [ 17 | "-fdiagnostics-color=always", 18 | "-g", 19 | "${file}", 20 | "-o", 21 | "${fileDirname}\\${fileBasenameNoExtension}.exe" 22 | ], 23 | "options": { 24 | "cwd": "C:/mingw64/bin" 25 | }, 26 | "problemMatcher": ["$gcc"], 27 | "group": { 28 | "kind": "build", 29 | "isDefault": true 30 | }, 31 | "detail": "Task generated by Debugger." 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /.vscode/todo.todo: -------------------------------------------------------------------------------- 1 | - App logo/visuals 2 | - Tinker the logo @done 3 | - Create the logo @done 4 | - File image for the drag and drop menu @done 5 | - Folder image for the destination menu @done 6 | - Export all the single assets in a spritesheet @done 7 | - Animation for the ready/stop state @done 8 | - Button to remove the selected file @done 9 | - Convert button @done 10 | 11 | - App architecture 12 | - Fix the .dlls for release @done 13 | - Fonts cleanup @done 14 | 15 | - App features 16 | - Button to select the file @done 17 | - Button to start the convert @done 18 | - Button to remove the current file @done 19 | - Show file name in the drag and drop menu @done 20 | - Show folder name in the dest menu like parent\\folder @done 21 | - Stop the program from working while converting @done 22 | - Change app name @done 23 | - Create and change icon for the app @done 24 | 25 | - App last touches 26 | - Features new screenshot 27 | - GIF 28 | - Link the badges to the repo 29 | - Write some tests to do 30 | - Clean the repo 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Gustavo Domingues 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # set the App name 2 | NAME = twitter-gif-maker 3 | # set compiler 4 | CC = g++ -std=c++17 5 | # set all the files needed 6 | #CPP = .\src\Entity/*.cpp .\src\Scenes/*.cpp 7 | # imgui dependencies 8 | BIN = bin/*.o 9 | DEBUG_FLAGS = -DF_ENABLE_ASSERTS -DF_ENABLE_DEBUG 10 | 11 | bin_dir: 12 | mkdir bin 13 | 14 | imgui_o: $(patsubst src/ImGui/%.cpp,bin/%.o,$(wildcard src/ImGui/*.cpp)) 15 | app_o: $(patsubst src/Core/%.cpp,bin/%.o,$(wildcard src/Core/*.cpp)) 16 | entity_o : $(patsubst src/Entity/%.cpp,bin/%.o,$(wildcard src/Entity/*.cpp)) 17 | renderer_o : $(patsubst src/Renderer/%.cpp,bin/%.o,$(wildcard src/Renderer/*.cpp)) 18 | resources_o : $(patsubst src/Resources/%.cpp,bin/%.o,$(wildcard src/Resources/*.cpp)) 19 | scenes_o : $(patsubst src/Scenes/%.cpp,bin/%.o,$(wildcard src/Scenes/*.cpp)) 20 | tools_o : $(patsubst src/Tools/%.cpp,bin/%.o,$(wildcard src/Tools/*.cpp)) 21 | utils_o : $(patsubst src/Utils/%.cpp,bin/%.o,$(wildcard src/Utils/*.cpp)) 22 | 23 | # Rule to build all .cpp files in the src/ImGui folder 24 | bin/%.o: src/ImGui/%.cpp 25 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 26 | 27 | bin/%.o: src/Core/%.cpp 28 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 29 | 30 | bin/%.o: src/Entity/%.cpp 31 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 32 | 33 | bin/%.o: src/Renderer/%.cpp 34 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 35 | 36 | bin/%.o: src/Resources/%.cpp 37 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 38 | 39 | bin/%.o: src/Scenes/%.cpp 40 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 41 | 42 | bin/%.o: src/Tools/%.cpp 43 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 44 | 45 | bin/%.o: src/Utils/%.cpp 46 | $(CC) $(if $(filter true,$(DEBUG)),-g $(DEBUG_FLAGS)) -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ 47 | 48 | debug: imgui_o app_o entity_o renderer_o resources_o scenes_o tools_o utils_o 49 | ${CC} -g -Wall -static-libstdc++ -static-libgcc -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -o .build/${NAME}_debug.exe ${BIN} res/icon/icon.res -lstdc++fs -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lole32 -mwindows -mconsole 50 | 51 | build: imgui_o app_o entity_o renderer_o resources_o scenes_o tools_o utils_o 52 | ${CC} -s -finline-functions -flto -static-libstdc++ -static-libgcc -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -o .release/${NAME}.exe ${BIN} res/icon/icon.res -lstdc++fs -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lole32 -mwindows -O2 53 | 54 | compile: bin_dir imgui_o app_o entity_o renderer_o resources_o scenes_o tools_o utils_o 55 | ${CC} -Wall -static-libstdc++ -static-libgcc -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -o ${NAME}_debug ${BIN} res/icon/icon.res -lstdc++fs -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lole32 -mwindows -mconsole -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |  Fortress logo 3 |

4 | 5 |

X-Gif-Maker

6 | 7 |
8 | 9 | ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/bigasdev/X-Gif-Maker/build.yaml) 10 | ![GitHub Release](https://img.shields.io/github/v/release/bigasdev/X-Gif-Maker) 11 | 12 |
13 | 14 | _Turn your videos into GIFs in a snap! Customize settings to shrink file sizes, suitable for sharing on social media platforms._ 15 | 16 | ## Introduction 17 | 18 | This is a revamped version of my [Twitter-Gif-Maker Tool](https://github.com/bigasdev/Twitter-Gif-Maker), which I originally created a while back to support my game development posts on Twitter. 19 | 20 | The purpose of this project was to refine and test my work-in-progress framework called Fortress, and to optimize the tool with an elegant interface for easier usability. 21 | 22 | 23 |
24 | This gif was created with X-Gif-Maker! 25 |
26 | 27 | ## Features 28 | 29 | 30 | 31 | - Straightforward usage: simply drag and drop your file or select it to convert it to a .gif format, saving it to any folder. 32 | - Options to adjust your .gif quality and width. 33 | - Shortcut keys provided for all actions for quick iterations. 34 | - Utilizes multithreading to prevent the program from becoming unresponsive during video conversion. 35 | - Beautiful pixel-art UI. 36 | 37 | ## Feedback 38 | 39 | Feel free to send feedback on [Twitter](https://x.com/bigasdev) or file an issue. Feature requests are always welcome. 40 | 41 | If there's anything you'd like to chat about, please feel free to message me at [Discord]()! 42 | 43 | ## Build Process 44 | 45 | You can grab the tool from the Releases section. However if you prefer to check the source code and compile it yourself its pretty simple. 46 | 47 | Currently, the tool is only compatible with Windows. If you are using Windows, ensure that you have [gcc 13.2.0+](https://gcc.gnu.org/gcc-13/) installed. 48 | 49 | After cloning the repository, execute the setup.bat file located in the scripts_dlls folder to configure your .debug and .release folders with the necessary DLLs and resources. 50 | 51 | The SDL and other libraries I use are included in the source code, so you only need to run the following commands to build from the Makefile: 52 | 53 | ``` 54 | mingw32-make -j debug 55 | or 56 | mingw32-make release DEBUG=false 57 | ``` 58 | 59 | For the release version, I recommend utilizing the **ship.bat** located within the _scripts_dlls folder_, which generates the complete .release folder for you. 60 | 61 | Following the release compilation, you can locate the **modern_installer.nsi** file inside the _scripts_dlls_ folder, which allows you to generate a nice NSIS installer. 62 | 63 | For VSCode users the project has a [commandbar](https://marketplace.visualstudio.com/items?itemName=gsppvo.vscode-commandbar) setup. 64 | 65 | 66 | ## Acknowledgments 67 | 68 | A huge thanks to [NabiKAZ](https://github.com/NabiKAZ) for creating [video2gif](https://github.com/NabiKAZ/video2gif?tab=readme-ov-file), which enables this quick and easy GIF conversion. 69 | 70 | And of course, thanks to the [FFmpeg project](https://github.com/FFmpeg/FFmpeg) 71 | -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | [ConvertOneButton] 2 | fileName=config.ini 3 | name=ConvertOneButton 4 | relative_name=null 5 | relative_x=583 6 | relative_y=252 7 | [ConvertionState] 8 | fileName=config.ini 9 | name=ConvertionState 10 | relative_name=null 11 | relative_x=352 12 | relative_y=17 13 | [FileName] 14 | fileName=config.ini 15 | name=FileName 16 | relative_name=null 17 | relative_x=40 18 | relative_y=298 19 | [FolderName] 20 | fileName=config.ini 21 | name=FolderName 22 | relative_name=null 23 | relative_x=562 24 | relative_y=145 25 | [PressE] 26 | fileName=config.ini 27 | name=PressE 28 | relative_name=null 29 | relative_x=70 30 | relative_y=315 31 | [PressF] 32 | fileName=config.ini 33 | name=PressF 34 | relative_name=null 35 | relative_x=590 36 | relative_y=165 37 | [RemoveFile] 38 | fileName=config.ini 39 | name=RemoveFile 40 | relative_name=null 41 | relative_x=115 42 | relative_y=161 43 | [SelectFile] 44 | fileName=config.ini 45 | name=SelectFile 46 | relative_name=null 47 | relative_x=31 48 | relative_y=305 49 | [SelectFolder] 50 | fileName=config.ini 51 | name=SelectFolder 52 | relative_name=null 53 | relative_x=650 54 | relative_y=100 55 | [SpriteTest] 56 | fileName=config.ini 57 | name=SpriteTest 58 | relative_name=null 59 | relative_x=8 60 | relative_y=16 61 | [VideoSettings] 62 | fileName=config.ini 63 | name=VideoSettings 64 | relative_name=null 65 | relative_x=340 66 | relative_y=160 67 | [config] 68 | lastWriteTime=-4720830621000000000 69 | [file] 70 | fileName=config.ini 71 | name=file 72 | relative_name=null 73 | relative_x=122 74 | relative_y=160 75 | [folder] 76 | fileName=config.ini 77 | name=folder 78 | relative_name=null 79 | relative_x=640 80 | relative_y=95 81 | [ready_bar] 82 | fileName=config.ini 83 | name=ready_bar 84 | relative_name=null 85 | relative_x=0 86 | relative_y=0 87 | -------------------------------------------------------------------------------- /imgui.ini: -------------------------------------------------------------------------------- 1 | [Window][Debug##Default] 2 | Pos=60,60 3 | Size=400,400 4 | Collapsed=0 5 | 6 | [Window][Main Scene] 7 | Pos=250,460 8 | Size=202,32 9 | Collapsed=0 10 | 11 | [Window][Status Bar UI] 12 | Pos=0,364 13 | Size=804,32 14 | Collapsed=0 15 | 16 | [Window][Video Settings] 17 | Pos=340,160 18 | Size=200,600 19 | Collapsed=0 20 | 21 | -------------------------------------------------------------------------------- /include/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_bits.h 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef SDL_bits_h_ 29 | #define SDL_bits_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return the index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | #if defined(__WATCOMC__) && defined(__386__) 51 | extern __inline int _SDL_bsr_watcom(Uint32); 52 | #pragma aux _SDL_bsr_watcom = \ 53 | "bsr eax, eax" \ 54 | parm [eax] nomemory \ 55 | value [eax] \ 56 | modify exact [eax] nomemory; 57 | #endif 58 | 59 | SDL_FORCE_INLINE int 60 | SDL_MostSignificantBitIndex32(Uint32 x) 61 | { 62 | #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 63 | /* Count Leading Zeroes builtin in GCC. 64 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 65 | */ 66 | if (x == 0) { 67 | return -1; 68 | } 69 | return 31 - __builtin_clz(x); 70 | #elif defined(__WATCOMC__) && defined(__386__) 71 | if (x == 0) { 72 | return -1; 73 | } 74 | return _SDL_bsr_watcom(x); 75 | #elif defined(_MSC_VER) 76 | unsigned long index; 77 | if (_BitScanReverse(&index, x)) { 78 | return index; 79 | } 80 | return -1; 81 | #else 82 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 83 | * , released in the public domain. 84 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 85 | */ 86 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 87 | const int S[] = {1, 2, 4, 8, 16}; 88 | 89 | int msbIndex = 0; 90 | int i; 91 | 92 | if (x == 0) { 93 | return -1; 94 | } 95 | 96 | for (i = 4; i >= 0; i--) 97 | { 98 | if (x & b[i]) 99 | { 100 | x >>= S[i]; 101 | msbIndex |= S[i]; 102 | } 103 | } 104 | 105 | return msbIndex; 106 | #endif 107 | } 108 | 109 | SDL_FORCE_INLINE SDL_bool 110 | SDL_HasExactlyOneBitSet32(Uint32 x) 111 | { 112 | if (x && !(x & (x - 1))) { 113 | return SDL_TRUE; 114 | } 115 | return SDL_FALSE; 116 | } 117 | 118 | /* Ends C function definitions when using C++ */ 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | #include "close_code.h" 123 | 124 | #endif /* SDL_bits_h_ */ 125 | 126 | /* vi: set ts=4 sw=4 expandtab: */ 127 | -------------------------------------------------------------------------------- /include/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef SDL_clipboard_h_ 29 | #define SDL_clipboard_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | /** 42 | * Put UTF-8 text into the clipboard. 43 | * 44 | * \param text the text to store in the clipboard 45 | * \returns 0 on success or a negative error code on failure; call 46 | * SDL_GetError() for more information. 47 | * 48 | * \since This function is available since SDL 2.0.0. 49 | * 50 | * \sa SDL_GetClipboardText 51 | * \sa SDL_HasClipboardText 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 54 | 55 | /** 56 | * Get UTF-8 text from the clipboard, which must be freed with SDL_free(). 57 | * 58 | * This functions returns empty string if there was not enough memory left for 59 | * a copy of the clipboard's content. 60 | * 61 | * \returns the clipboard text on success or an empty string on failure; call 62 | * SDL_GetError() for more information. Caller must call SDL_free() 63 | * on the returned pointer when done with it (even if there was an 64 | * error). 65 | * 66 | * \since This function is available since SDL 2.0.0. 67 | * 68 | * \sa SDL_HasClipboardText 69 | * \sa SDL_SetClipboardText 70 | */ 71 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 72 | 73 | /** 74 | * Query whether the clipboard exists and contains a non-empty text string. 75 | * 76 | * \returns SDL_TRUE if the clipboard has text, or SDL_FALSE if it does not. 77 | * 78 | * \since This function is available since SDL 2.0.0. 79 | * 80 | * \sa SDL_GetClipboardText 81 | * \sa SDL_SetClipboardText 82 | */ 83 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 84 | 85 | /** 86 | * Put UTF-8 text into the primary selection. 87 | * 88 | * \param text the text to store in the primary selection 89 | * \returns 0 on success or a negative error code on failure; call 90 | * SDL_GetError() for more information. 91 | * 92 | * \since This function is available since SDL 2.26.0. 93 | * 94 | * \sa SDL_GetPrimarySelectionText 95 | * \sa SDL_HasPrimarySelectionText 96 | */ 97 | extern DECLSPEC int SDLCALL SDL_SetPrimarySelectionText(const char *text); 98 | 99 | /** 100 | * Get UTF-8 text from the primary selection, which must be freed with 101 | * SDL_free(). 102 | * 103 | * This functions returns empty string if there was not enough memory left for 104 | * a copy of the primary selection's content. 105 | * 106 | * \returns the primary selection text on success or an empty string on 107 | * failure; call SDL_GetError() for more information. Caller must 108 | * call SDL_free() on the returned pointer when done with it (even if 109 | * there was an error). 110 | * 111 | * \since This function is available since SDL 2.26.0. 112 | * 113 | * \sa SDL_HasPrimarySelectionText 114 | * \sa SDL_SetPrimarySelectionText 115 | */ 116 | extern DECLSPEC char * SDLCALL SDL_GetPrimarySelectionText(void); 117 | 118 | /** 119 | * Query whether the primary selection exists and contains a non-empty text 120 | * string. 121 | * 122 | * \returns SDL_TRUE if the primary selection has text, or SDL_FALSE if it 123 | * does not. 124 | * 125 | * \since This function is available since SDL 2.26.0. 126 | * 127 | * \sa SDL_GetPrimarySelectionText 128 | * \sa SDL_SetPrimarySelectionText 129 | */ 130 | extern DECLSPEC SDL_bool SDLCALL SDL_HasPrimarySelectionText(void); 131 | 132 | 133 | /* Ends C function definitions when using C++ */ 134 | #ifdef __cplusplus 135 | } 136 | #endif 137 | #include "close_code.h" 138 | 139 | #endif /* SDL_clipboard_h_ */ 140 | 141 | /* vi: set ts=4 sw=4 expandtab: */ 142 | -------------------------------------------------------------------------------- /include/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_error.h 24 | * 25 | * Simple error message routines for SDL. 26 | */ 27 | 28 | #ifndef SDL_error_h_ 29 | #define SDL_error_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Public functions */ 40 | 41 | 42 | /** 43 | * Set the SDL error message for the current thread. 44 | * 45 | * Calling this function will replace any previous error message that was set. 46 | * 47 | * This function always returns -1, since SDL frequently uses -1 to signify an 48 | * failing result, leading to this idiom: 49 | * 50 | * ```c 51 | * if (error_code) { 52 | * return SDL_SetError("This operation has failed: %d", error_code); 53 | * } 54 | * ``` 55 | * 56 | * \param fmt a printf()-style message format string 57 | * \param ... additional parameters matching % tokens in the `fmt` string, if 58 | * any 59 | * \returns always -1. 60 | * 61 | * \since This function is available since SDL 2.0.0. 62 | * 63 | * \sa SDL_ClearError 64 | * \sa SDL_GetError 65 | */ 66 | extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 67 | 68 | /** 69 | * Retrieve a message about the last error that occurred on the current 70 | * thread. 71 | * 72 | * It is possible for multiple errors to occur before calling SDL_GetError(). 73 | * Only the last error is returned. 74 | * 75 | * The message is only applicable when an SDL function has signaled an error. 76 | * You must check the return values of SDL function calls to determine when to 77 | * appropriately call SDL_GetError(). You should *not* use the results of 78 | * SDL_GetError() to decide if an error has occurred! Sometimes SDL will set 79 | * an error string even when reporting success. 80 | * 81 | * SDL will *not* clear the error string for successful API calls. You *must* 82 | * check return values for failure cases before you can assume the error 83 | * string applies. 84 | * 85 | * Error strings are set per-thread, so an error set in a different thread 86 | * will not interfere with the current thread's operation. 87 | * 88 | * The returned string is internally allocated and must not be freed by the 89 | * application. 90 | * 91 | * \returns a message with information about the specific error that occurred, 92 | * or an empty string if there hasn't been an error message set since 93 | * the last call to SDL_ClearError(). The message is only applicable 94 | * when an SDL function has signaled an error. You must check the 95 | * return values of SDL function calls to determine when to 96 | * appropriately call SDL_GetError(). 97 | * 98 | * \since This function is available since SDL 2.0.0. 99 | * 100 | * \sa SDL_ClearError 101 | * \sa SDL_SetError 102 | */ 103 | extern DECLSPEC const char *SDLCALL SDL_GetError(void); 104 | 105 | /** 106 | * Get the last error message that was set for the current thread. 107 | * 108 | * This allows the caller to copy the error string into a provided buffer, but 109 | * otherwise operates exactly the same as SDL_GetError(). 110 | * 111 | * \param errstr A buffer to fill with the last error message that was set for 112 | * the current thread 113 | * \param maxlen The size of the buffer pointed to by the errstr parameter 114 | * \returns the pointer passed in as the `errstr` parameter. 115 | * 116 | * \since This function is available since SDL 2.0.14. 117 | * 118 | * \sa SDL_GetError 119 | */ 120 | extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen); 121 | 122 | /** 123 | * Clear any previous error message for this thread. 124 | * 125 | * \since This function is available since SDL 2.0.0. 126 | * 127 | * \sa SDL_GetError 128 | * \sa SDL_SetError 129 | */ 130 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 131 | 132 | /** 133 | * \name Internal error functions 134 | * 135 | * \internal 136 | * Private error reporting function - used internally. 137 | */ 138 | /* @{ */ 139 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 140 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 141 | #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) 142 | typedef enum 143 | { 144 | SDL_ENOMEM, 145 | SDL_EFREAD, 146 | SDL_EFWRITE, 147 | SDL_EFSEEK, 148 | SDL_UNSUPPORTED, 149 | SDL_LASTERROR 150 | } SDL_errorcode; 151 | /* SDL_Error() unconditionally returns -1. */ 152 | extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); 153 | /* @} *//* Internal error functions */ 154 | 155 | /* Ends C function definitions when using C++ */ 156 | #ifdef __cplusplus 157 | } 158 | #endif 159 | #include "close_code.h" 160 | 161 | #endif /* SDL_error_h_ */ 162 | 163 | /* vi: set ts=4 sw=4 expandtab: */ 164 | -------------------------------------------------------------------------------- /include/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef SDL_gesture_h_ 29 | #define SDL_gesture_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * Begin recording a gesture on a specified touch device or all touch devices. 50 | * 51 | * If the parameter `touchId` is -1 (i.e., all devices), this function will 52 | * always return 1, regardless of whether there actually are any devices. 53 | * 54 | * \param touchId the touch device id, or -1 for all touch devices 55 | * \returns 1 on success or 0 if the specified device could not be found. 56 | * 57 | * \since This function is available since SDL 2.0.0. 58 | * 59 | * \sa SDL_GetTouchDevice 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 62 | 63 | 64 | /** 65 | * Save all currently loaded Dollar Gesture templates. 66 | * 67 | * \param dst a SDL_RWops to save to 68 | * \returns the number of saved templates on success or 0 on failure; call 69 | * SDL_GetError() for more information. 70 | * 71 | * \since This function is available since SDL 2.0.0. 72 | * 73 | * \sa SDL_LoadDollarTemplates 74 | * \sa SDL_SaveDollarTemplate 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 77 | 78 | /** 79 | * Save a currently loaded Dollar Gesture template. 80 | * 81 | * \param gestureId a gesture id 82 | * \param dst a SDL_RWops to save to 83 | * \returns 1 on success or 0 on failure; call SDL_GetError() for more 84 | * information. 85 | * 86 | * \since This function is available since SDL 2.0.0. 87 | * 88 | * \sa SDL_LoadDollarTemplates 89 | * \sa SDL_SaveAllDollarTemplates 90 | */ 91 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 92 | 93 | 94 | /** 95 | * Load Dollar Gesture templates from a file. 96 | * 97 | * \param touchId a touch id 98 | * \param src a SDL_RWops to load from 99 | * \returns the number of loaded templates on success or a negative error code 100 | * (or 0) on failure; call SDL_GetError() for more information. 101 | * 102 | * \since This function is available since SDL 2.0.0. 103 | * 104 | * \sa SDL_SaveAllDollarTemplates 105 | * \sa SDL_SaveDollarTemplate 106 | */ 107 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 108 | 109 | /* Ends C function definitions when using C++ */ 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | #include "close_code.h" 114 | 115 | #endif /* SDL_gesture_h_ */ 116 | 117 | /* vi: set ts=4 sw=4 expandtab: */ 118 | -------------------------------------------------------------------------------- /include/SDL_guid.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_guid.h 24 | * 25 | * Include file for handling ::SDL_GUID values. 26 | */ 27 | 28 | #ifndef SDL_guid_h_ 29 | #define SDL_guid_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * An SDL_GUID is a 128-bit identifier for an input device that 42 | * identifies that device across runs of SDL programs on the same 43 | * platform. If the device is detached and then re-attached to a 44 | * different port, or if the base system is rebooted, the device 45 | * should still report the same GUID. 46 | * 47 | * GUIDs are as precise as possible but are not guaranteed to 48 | * distinguish physically distinct but equivalent devices. For 49 | * example, two game controllers from the same vendor with the same 50 | * product ID and revision may have the same GUID. 51 | * 52 | * GUIDs may be platform-dependent (i.e., the same device may report 53 | * different GUIDs on different operating systems). 54 | */ 55 | typedef struct { 56 | Uint8 data[16]; 57 | } SDL_GUID; 58 | 59 | /* Function prototypes */ 60 | 61 | /** 62 | * Get an ASCII string representation for a given ::SDL_GUID. 63 | * 64 | * You should supply at least 33 bytes for pszGUID. 65 | * 66 | * \param guid the ::SDL_GUID you wish to convert to string 67 | * \param pszGUID buffer in which to write the ASCII string 68 | * \param cbGUID the size of pszGUID 69 | * 70 | * \since This function is available since SDL 2.24.0. 71 | * 72 | * \sa SDL_GUIDFromString 73 | */ 74 | extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID); 75 | 76 | /** 77 | * Convert a GUID string into a ::SDL_GUID structure. 78 | * 79 | * Performs no error checking. If this function is given a string containing 80 | * an invalid GUID, the function will silently succeed, but the GUID generated 81 | * will not be useful. 82 | * 83 | * \param pchGUID string containing an ASCII representation of a GUID 84 | * \returns a ::SDL_GUID structure. 85 | * 86 | * \since This function is available since SDL 2.24.0. 87 | * 88 | * \sa SDL_GUIDToString 89 | */ 90 | extern DECLSPEC SDL_GUID SDLCALL SDL_GUIDFromString(const char *pchGUID); 91 | 92 | /* Ends C function definitions when using C++ */ 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | #include "close_code.h" 97 | 98 | #endif /* SDL_guid_h_ */ 99 | 100 | /* vi: set ts=4 sw=4 expandtab: */ 101 | -------------------------------------------------------------------------------- /include/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_loadso.h 24 | * 25 | * System dependent library loading routines 26 | * 27 | * Some things to keep in mind: 28 | * \li These functions only work on C function names. Other languages may 29 | * have name mangling and intrinsic language support that varies from 30 | * compiler to compiler. 31 | * \li Make sure you declare your function pointers with the same calling 32 | * convention as the actual library function. Your code will crash 33 | * mysteriously if you do not do this. 34 | * \li Avoid namespace collisions. If you load a symbol from the library, 35 | * it is not defined whether or not it goes into the global symbol 36 | * namespace for the application. If it does and it conflicts with 37 | * symbols in your code or other shared libraries, you will not get 38 | * the results you expect. :) 39 | */ 40 | 41 | #ifndef SDL_loadso_h_ 42 | #define SDL_loadso_h_ 43 | 44 | #include "SDL_stdinc.h" 45 | #include "SDL_error.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /** 54 | * Dynamically load a shared object. 55 | * 56 | * \param sofile a system-dependent name of the object file 57 | * \returns an opaque pointer to the object handle or NULL if there was an 58 | * error; call SDL_GetError() for more information. 59 | * 60 | * \since This function is available since SDL 2.0.0. 61 | * 62 | * \sa SDL_LoadFunction 63 | * \sa SDL_UnloadObject 64 | */ 65 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); 66 | 67 | /** 68 | * Look up the address of the named function in a shared object. 69 | * 70 | * This function pointer is no longer valid after calling SDL_UnloadObject(). 71 | * 72 | * This function can only look up C function names. Other languages may have 73 | * name mangling and intrinsic language support that varies from compiler to 74 | * compiler. 75 | * 76 | * Make sure you declare your function pointers with the same calling 77 | * convention as the actual library function. Your code will crash 78 | * mysteriously if you do not do this. 79 | * 80 | * If the requested function doesn't exist, NULL is returned. 81 | * 82 | * \param handle a valid shared object handle returned by SDL_LoadObject() 83 | * \param name the name of the function to look up 84 | * \returns a pointer to the function or NULL if there was an error; call 85 | * SDL_GetError() for more information. 86 | * 87 | * \since This function is available since SDL 2.0.0. 88 | * 89 | * \sa SDL_LoadObject 90 | * \sa SDL_UnloadObject 91 | */ 92 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, 93 | const char *name); 94 | 95 | /** 96 | * Unload a shared object from memory. 97 | * 98 | * \param handle a valid shared object handle returned by SDL_LoadObject() 99 | * 100 | * \since This function is available since SDL 2.0.0. 101 | * 102 | * \sa SDL_LoadFunction 103 | * \sa SDL_LoadObject 104 | */ 105 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* SDL_loadso_h_ */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /include/SDL_locale.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_locale.h 24 | * 25 | * Include file for SDL locale services 26 | */ 27 | 28 | #ifndef _SDL_locale_h 29 | #define _SDL_locale_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | /* *INDENT-OFF* */ 38 | extern "C" { 39 | /* *INDENT-ON* */ 40 | #endif 41 | 42 | 43 | typedef struct SDL_Locale 44 | { 45 | const char *language; /**< A language name, like "en" for English. */ 46 | const char *country; /**< A country, like "US" for America. Can be NULL. */ 47 | } SDL_Locale; 48 | 49 | /** 50 | * Report the user's preferred locale. 51 | * 52 | * This returns an array of SDL_Locale structs, the final item zeroed out. 53 | * When the caller is done with this array, it should call SDL_free() on the 54 | * returned value; all the memory involved is allocated in a single block, so 55 | * a single SDL_free() will suffice. 56 | * 57 | * Returned language strings are in the format xx, where 'xx' is an ISO-639 58 | * language specifier (such as "en" for English, "de" for German, etc). 59 | * Country strings are in the format YY, where "YY" is an ISO-3166 country 60 | * code (such as "US" for the United States, "CA" for Canada, etc). Country 61 | * might be NULL if there's no specific guidance on them (so you might get { 62 | * "en", "US" } for American English, but { "en", NULL } means "English 63 | * language, generically"). Language strings are never NULL, except to 64 | * terminate the array. 65 | * 66 | * Please note that not all of these strings are 2 characters; some are three 67 | * or more. 68 | * 69 | * The returned list of locales are in the order of the user's preference. For 70 | * example, a German citizen that is fluent in US English and knows enough 71 | * Japanese to navigate around Tokyo might have a list like: { "de", "en_US", 72 | * "jp", NULL }. Someone from England might prefer British English (where 73 | * "color" is spelled "colour", etc), but will settle for anything like it: { 74 | * "en_GB", "en", NULL }. 75 | * 76 | * This function returns NULL on error, including when the platform does not 77 | * supply this information at all. 78 | * 79 | * This might be a "slow" call that has to query the operating system. It's 80 | * best to ask for this once and save the results. However, this list can 81 | * change, usually because the user has changed a system preference outside of 82 | * your program; SDL will send an SDL_LOCALECHANGED event in this case, if 83 | * possible, and you can call this function again to get an updated copy of 84 | * preferred locales. 85 | * 86 | * \return array of locales, terminated with a locale with a NULL language 87 | * field. Will return NULL on error. 88 | * 89 | * \since This function is available since SDL 2.0.14. 90 | */ 91 | extern DECLSPEC SDL_Locale * SDLCALL SDL_GetPreferredLocales(void); 92 | 93 | /* Ends C function definitions when using C++ */ 94 | #ifdef __cplusplus 95 | /* *INDENT-OFF* */ 96 | } 97 | /* *INDENT-ON* */ 98 | #endif 99 | #include "close_code.h" 100 | 101 | #endif /* _SDL_locale_h */ 102 | 103 | /* vi: set ts=4 sw=4 expandtab: */ 104 | -------------------------------------------------------------------------------- /include/SDL_metal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_metal.h 24 | * 25 | * Header file for functions to creating Metal layers and views on SDL windows. 26 | */ 27 | 28 | #ifndef SDL_metal_h_ 29 | #define SDL_metal_h_ 30 | 31 | #include "SDL_video.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). 41 | * 42 | * \note This can be cast directly to an NSView or UIView. 43 | */ 44 | typedef void *SDL_MetalView; 45 | 46 | /** 47 | * \name Metal support functions 48 | */ 49 | /* @{ */ 50 | 51 | /** 52 | * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified 53 | * window. 54 | * 55 | * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on 56 | * its own. It is up to user code to do that. 57 | * 58 | * The returned handle can be casted directly to a NSView or UIView. To access 59 | * the backing CAMetalLayer, call SDL_Metal_GetLayer(). 60 | * 61 | * \since This function is available since SDL 2.0.12. 62 | * 63 | * \sa SDL_Metal_DestroyView 64 | * \sa SDL_Metal_GetLayer 65 | */ 66 | extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window); 67 | 68 | /** 69 | * Destroy an existing SDL_MetalView object. 70 | * 71 | * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was 72 | * called after SDL_CreateWindow. 73 | * 74 | * \since This function is available since SDL 2.0.12. 75 | * 76 | * \sa SDL_Metal_CreateView 77 | */ 78 | extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); 79 | 80 | /** 81 | * Get a pointer to the backing CAMetalLayer for the given view. 82 | * 83 | * \since This function is available since SDL 2.0.14. 84 | * 85 | * \sa SDL_Metal_CreateView 86 | */ 87 | extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view); 88 | 89 | /** 90 | * Get the size of a window's underlying drawable in pixels (for use with 91 | * setting viewport, scissor & etc). 92 | * 93 | * \param window SDL_Window from which the drawable size should be queried 94 | * \param w Pointer to variable for storing the width in pixels, may be NULL 95 | * \param h Pointer to variable for storing the height in pixels, may be NULL 96 | * 97 | * \since This function is available since SDL 2.0.14. 98 | * 99 | * \sa SDL_GetWindowSize 100 | * \sa SDL_CreateWindow 101 | */ 102 | extern DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize(SDL_Window* window, int *w, 103 | int *h); 104 | 105 | /* @} *//* Metal support functions */ 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* SDL_metal_h_ */ 114 | -------------------------------------------------------------------------------- /include/SDL_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_misc.h 24 | * 25 | * \brief Include file for SDL API functions that don't fit elsewhere. 26 | */ 27 | 28 | #ifndef SDL_misc_h_ 29 | #define SDL_misc_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * Open a URL/URI in the browser or other appropriate external application. 42 | * 43 | * Open a URL in a separate, system-provided application. How this works will 44 | * vary wildly depending on the platform. This will likely launch what makes 45 | * sense to handle a specific URL's protocol (a web browser for `http://`, 46 | * etc), but it might also be able to launch file managers for directories and 47 | * other things. 48 | * 49 | * What happens when you open a URL varies wildly as well: your game window 50 | * may lose focus (and may or may not lose focus if your game was fullscreen 51 | * or grabbing input at the time). On mobile devices, your app will likely 52 | * move to the background or your process might be paused. Any given platform 53 | * may or may not handle a given URL. 54 | * 55 | * If this is unimplemented (or simply unavailable) for a platform, this will 56 | * fail with an error. A successful result does not mean the URL loaded, just 57 | * that we launched _something_ to handle it (or at least believe we did). 58 | * 59 | * All this to say: this function can be useful, but you should definitely 60 | * test it on every platform you target. 61 | * 62 | * \param url A valid URL/URI to open. Use `file:///full/path/to/file` for 63 | * local files, if supported. 64 | * \returns 0 on success, or -1 on error; call SDL_GetError() for more 65 | * information. 66 | * 67 | * \since This function is available since SDL 2.0.14. 68 | */ 69 | extern DECLSPEC int SDLCALL SDL_OpenURL(const char *url); 70 | 71 | /* Ends C function definitions when using C++ */ 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | #include "close_code.h" 76 | 77 | #endif /* SDL_misc_h_ */ 78 | 79 | /* vi: set ts=4 sw=4 expandtab: */ 80 | -------------------------------------------------------------------------------- /include/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDLname_h_ 23 | #define SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /include/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | #include "SDL_config.h" 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #endif 36 | 37 | #ifndef APIENTRY 38 | #define APIENTRY 39 | #endif 40 | -------------------------------------------------------------------------------- /include/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles2.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | #include "SDL_config.h" 28 | 29 | #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) 30 | 31 | #ifdef __IPHONEOS__ 32 | #include 33 | #include 34 | #else 35 | #include 36 | #include 37 | #include 38 | #endif 39 | 40 | #else /* _MSC_VER */ 41 | 42 | /* OpenGL ES2 headers for Visual Studio */ 43 | #include "SDL_opengles2_khrplatform.h" 44 | #include "SDL_opengles2_gl2platform.h" 45 | #include "SDL_opengles2_gl2.h" 46 | #include "SDL_opengles2_gl2ext.h" 47 | 48 | #endif /* _MSC_VER */ 49 | 50 | #ifndef APIENTRY 51 | #define APIENTRY GL_APIENTRY 52 | #endif 53 | -------------------------------------------------------------------------------- /include/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* 5 | ** Copyright 2017-2020 The Khronos Group Inc. 6 | ** SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 10 | * 11 | * Adopters may modify khrplatform.h and this file to suit their platform. 12 | * Please contribute modifications back to Khronos as pull requests on the 13 | * public github repository: 14 | * https://github.com/KhronosGroup/OpenGL-Registry 15 | */ 16 | 17 | /*#include */ 18 | 19 | #ifndef GL_APICALL 20 | #define GL_APICALL KHRONOS_APICALL 21 | #endif 22 | 23 | #ifndef GL_APIENTRY 24 | #define GL_APIENTRY KHRONOS_APIENTRY 25 | #endif 26 | 27 | #endif /* __gl2platform_h_ */ 28 | -------------------------------------------------------------------------------- /include/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_power_h_ 23 | #define SDL_power_h_ 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * The basic state for the system's power supply. 41 | */ 42 | typedef enum 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | /** 52 | * Get the current power supply details. 53 | * 54 | * You should never take a battery status as absolute truth. Batteries 55 | * (especially failing batteries) are delicate hardware, and the values 56 | * reported here are best estimates based on what that hardware reports. It's 57 | * not uncommon for older batteries to lose stored power much faster than it 58 | * reports, or completely drain when reporting it has 20 percent left, etc. 59 | * 60 | * Battery status can change at any time; if you are concerned with power 61 | * state, you should call this function frequently, and perhaps ignore changes 62 | * until they seem to be stable for a few seconds. 63 | * 64 | * It's possible a platform can only report battery percentage or time left 65 | * but not both. 66 | * 67 | * \param seconds seconds of battery life left, you can pass a NULL here if 68 | * you don't care, will return -1 if we can't determine a 69 | * value, or we're not running on a battery 70 | * \param percent percentage of battery life left, between 0 and 100, you can 71 | * pass a NULL here if you don't care, will return -1 if we 72 | * can't determine a value, or we're not running on a battery 73 | * \returns an SDL_PowerState enum representing the current battery state. 74 | * 75 | * \since This function is available since SDL 2.0.0. 76 | */ 77 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent); 78 | 79 | /* Ends C function definitions when using C++ */ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* SDL_power_h_ */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef SDL_quit_h_ 29 | #define SDL_quit_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* SDL_quit_h_ */ 59 | -------------------------------------------------------------------------------- /include/SDL_revision.h: -------------------------------------------------------------------------------- 1 | /* Generated by updaterev.sh, do not edit */ 2 | #ifdef SDL_VENDOR_INFO 3 | #define SDL_REVISION "SDL-release-2.28.4-0-gcc016b004 (" SDL_VENDOR_INFO ")" 4 | #else 5 | #define SDL_REVISION "SDL-release-2.28.4-0-gcc016b004" 6 | #endif 7 | #define SDL_REVISION_NUMBER 0 8 | -------------------------------------------------------------------------------- /include/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_h_ 31 | #define SDL_test_h_ 32 | 33 | #include "SDL.h" 34 | #include "SDL_test_assert.h" 35 | #include "SDL_test_common.h" 36 | #include "SDL_test_compare.h" 37 | #include "SDL_test_crc32.h" 38 | #include "SDL_test_font.h" 39 | #include "SDL_test_fuzzer.h" 40 | #include "SDL_test_harness.h" 41 | #include "SDL_test_images.h" 42 | #include "SDL_test_log.h" 43 | #include "SDL_test_md5.h" 44 | #include "SDL_test_memory.h" 45 | #include "SDL_test_random.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /* Global definitions */ 54 | 55 | /* 56 | * Note: Maximum size of SDLTest log message is less than SDL's limit 57 | * to ensure we can fit additional information such as the timestamp. 58 | */ 59 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /include/SDL_test_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_assert.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Assert API for test code and test cases 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_assert_h_ 37 | #define SDL_test_assert_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Fails the assert. 47 | */ 48 | #define ASSERT_FAIL 0 49 | 50 | /** 51 | * \brief Passes the assert. 52 | */ 53 | #define ASSERT_PASS 1 54 | 55 | /** 56 | * \brief Assert that logs and break execution flow on failures. 57 | * 58 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 59 | * \param assertDescription Message to log with the assert describing it. 60 | */ 61 | void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 62 | 63 | /** 64 | * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. 65 | * 66 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 67 | * \param assertDescription Message to log with the assert describing it. 68 | * 69 | * \returns the assertCondition so it can be used to externally to break execution flow if desired. 70 | */ 71 | int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 72 | 73 | /** 74 | * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. 75 | * 76 | * \param assertDescription Message to log with the assert describing it. 77 | */ 78 | void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); 79 | 80 | /** 81 | * \brief Resets the assert summary counters to zero. 82 | */ 83 | void SDLTest_ResetAssertSummary(void); 84 | 85 | /** 86 | * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. 87 | */ 88 | void SDLTest_LogAssertSummary(void); 89 | 90 | 91 | /** 92 | * \brief Converts the current assert summary state to a test result. 93 | * 94 | * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT 95 | */ 96 | int SDLTest_AssertSummaryToTestResult(void); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | #include "close_code.h" 102 | 103 | #endif /* SDL_test_assert_h_ */ 104 | 105 | /* vi: set ts=4 sw=4 expandtab: */ 106 | -------------------------------------------------------------------------------- /include/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_compare.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines comparison functions (i.e. for surfaces). 33 | 34 | */ 35 | 36 | #ifndef SDL_test_compare_h_ 37 | #define SDL_test_compare_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "SDL_test_images.h" 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * \brief Compares a surface and with reference image data for equality 51 | * 52 | * \param surface Surface used in comparison 53 | * \param referenceSurface Test Surface used in comparison 54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. 55 | * 56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. 57 | */ 58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); 59 | 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_compare_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /include/SDL_test_crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_crc32.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Implements CRC32 calculations (default output is Perl String::CRC32 compatible). 33 | 34 | */ 35 | 36 | #ifndef SDL_test_crc32_h_ 37 | #define SDL_test_crc32_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /* ------------ Definitions --------- */ 47 | 48 | /* Definition shared by all CRC routines */ 49 | 50 | #ifndef CrcUint32 51 | #define CrcUint32 unsigned int 52 | #endif 53 | #ifndef CrcUint8 54 | #define CrcUint8 unsigned char 55 | #endif 56 | 57 | #ifdef ORIGINAL_METHOD 58 | #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ 59 | #else 60 | #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ 61 | #endif 62 | 63 | /** 64 | * Data structure for CRC32 (checksum) computation 65 | */ 66 | typedef struct { 67 | CrcUint32 crc32_table[256]; /* CRC table */ 68 | } SDLTest_Crc32Context; 69 | 70 | /* ---------- Function Prototypes ------------- */ 71 | 72 | /** 73 | * \brief Initialize the CRC context 74 | * 75 | * Note: The function initializes the crc table required for all crc calculations. 76 | * 77 | * \param crcContext pointer to context variable 78 | * 79 | * \returns 0 for OK, -1 on error 80 | * 81 | */ 82 | int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); 83 | 84 | 85 | /** 86 | * \brief calculate a crc32 from a data block 87 | * 88 | * \param crcContext pointer to context variable 89 | * \param inBuf input buffer to checksum 90 | * \param inLen length of input buffer 91 | * \param crc32 pointer to Uint32 to store the final CRC into 92 | * 93 | * \returns 0 for OK, -1 on error 94 | * 95 | */ 96 | int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 97 | 98 | /* Same routine broken down into three steps */ 99 | int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 100 | int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 101 | int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 102 | 103 | 104 | /** 105 | * \brief clean up CRC context 106 | * 107 | * \param crcContext pointer to context variable 108 | * 109 | * \returns 0 for OK, -1 on error 110 | * 111 | */ 112 | 113 | int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); 114 | 115 | 116 | /* Ends C function definitions when using C++ */ 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | #include "close_code.h" 121 | 122 | #endif /* SDL_test_crc32_h_ */ 123 | 124 | /* vi: set ts=4 sw=4 expandtab: */ 125 | -------------------------------------------------------------------------------- /include/SDL_test_harness.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_harness.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | Defines types for test case definitions and the test execution harness API. 32 | 33 | Based on original GSOC code by Markus Kauppila 34 | */ 35 | 36 | #ifndef SDL_test_h_arness_h 37 | #define SDL_test_h_arness_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /* ! Definitions for test case structures */ 47 | #define TEST_ENABLED 1 48 | #define TEST_DISABLED 0 49 | 50 | /* ! Definition of all the possible test return values of the test case method */ 51 | #define TEST_ABORTED -1 52 | #define TEST_STARTED 0 53 | #define TEST_COMPLETED 1 54 | #define TEST_SKIPPED 2 55 | 56 | /* ! Definition of all the possible test results for the harness */ 57 | #define TEST_RESULT_PASSED 0 58 | #define TEST_RESULT_FAILED 1 59 | #define TEST_RESULT_NO_ASSERT 2 60 | #define TEST_RESULT_SKIPPED 3 61 | #define TEST_RESULT_SETUP_FAILURE 4 62 | 63 | /* !< Function pointer to a test case setup function (run before every test) */ 64 | typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); 65 | 66 | /* !< Function pointer to a test case function */ 67 | typedef int (*SDLTest_TestCaseFp)(void *arg); 68 | 69 | /* !< Function pointer to a test case teardown function (run after every test) */ 70 | typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); 71 | 72 | /** 73 | * Holds information about a single test case. 74 | */ 75 | typedef struct SDLTest_TestCaseReference { 76 | /* !< Func2Stress */ 77 | SDLTest_TestCaseFp testCase; 78 | /* !< Short name (or function name) "Func2Stress" */ 79 | const char *name; 80 | /* !< Long name or full description "This test pushes func2() to the limit." */ 81 | const char *description; 82 | /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ 83 | int enabled; 84 | } SDLTest_TestCaseReference; 85 | 86 | /** 87 | * Holds information about a test suite (multiple test cases). 88 | */ 89 | typedef struct SDLTest_TestSuiteReference { 90 | /* !< "PlatformSuite" */ 91 | const char *name; 92 | /* !< The function that is run before each test. NULL skips. */ 93 | SDLTest_TestCaseSetUpFp testSetUp; 94 | /* !< The test cases that are run as part of the suite. Last item should be NULL. */ 95 | const SDLTest_TestCaseReference **testCases; 96 | /* !< The function that is run after each test. NULL skips. */ 97 | SDLTest_TestCaseTearDownFp testTearDown; 98 | } SDLTest_TestSuiteReference; 99 | 100 | 101 | /** 102 | * \brief Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z). 103 | * 104 | * Note: The returned string needs to be deallocated by the caller. 105 | * 106 | * \param length The length of the seed string to generate 107 | * 108 | * \returns the generated seed string 109 | */ 110 | char *SDLTest_GenerateRunSeed(const int length); 111 | 112 | /** 113 | * \brief Execute a test suite using the given run seed and execution key. 114 | * 115 | * \param testSuites Suites containing the test case. 116 | * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. 117 | * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. 118 | * \param filter Filter specification. NULL disables. Case sensitive. 119 | * \param testIterations Number of iterations to run each test case. 120 | * 121 | * \returns the test run result: 0 when all tests passed, 1 if any tests failed. 122 | */ 123 | int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); 124 | 125 | 126 | /* Ends C function definitions when using C++ */ 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | #include "close_code.h" 131 | 132 | #endif /* SDL_test_h_arness_h */ 133 | 134 | /* vi: set ts=4 sw=4 expandtab: */ 135 | -------------------------------------------------------------------------------- /include/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_images.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines some images for tests. 33 | 34 | */ 35 | 36 | #ifndef SDL_test_images_h_ 37 | #define SDL_test_images_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** 48 | *Type for test images. 49 | */ 50 | typedef struct SDLTest_SurfaceImage_s { 51 | int width; 52 | int height; 53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ 54 | const char *pixel_data; 55 | } SDLTest_SurfaceImage_t; 56 | 57 | /* Test images */ 58 | SDL_Surface *SDLTest_ImageBlit(void); 59 | SDL_Surface *SDLTest_ImageBlitColor(void); 60 | SDL_Surface *SDLTest_ImageBlitAlpha(void); 61 | SDL_Surface *SDLTest_ImageBlitBlendAdd(void); 62 | SDL_Surface *SDLTest_ImageBlitBlend(void); 63 | SDL_Surface *SDLTest_ImageBlitBlendMod(void); 64 | SDL_Surface *SDLTest_ImageBlitBlendNone(void); 65 | SDL_Surface *SDLTest_ImageBlitBlendAll(void); 66 | SDL_Surface *SDLTest_ImageFace(void); 67 | SDL_Surface *SDLTest_ImagePrimitives(void); 68 | SDL_Surface *SDLTest_ImagePrimitivesBlend(void); 69 | 70 | /* Ends C function definitions when using C++ */ 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #include "close_code.h" 75 | 76 | #endif /* SDL_test_images_h_ */ 77 | 78 | /* vi: set ts=4 sw=4 expandtab: */ 79 | -------------------------------------------------------------------------------- /include/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_log.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Wrapper to log in the TEST category 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_log_h_ 37 | #define SDL_test_log_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority. 47 | * 48 | * \param fmt Message to be logged 49 | */ 50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 51 | 52 | /** 53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. 54 | * 55 | * \param fmt Message to be logged 56 | */ 57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 58 | 59 | /* Ends C function definitions when using C++ */ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #include "close_code.h" 64 | 65 | #endif /* SDL_test_log_h_ */ 66 | 67 | /* vi: set ts=4 sw=4 expandtab: */ 68 | -------------------------------------------------------------------------------- /include/SDL_test_md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_md5.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | *********************************************************************** 32 | ** Header file for implementation of MD5 ** 33 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** 34 | ** Created: 2/17/90 RLR ** 35 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** 36 | ** Revised (for MD5): RLR 4/27/91 ** 37 | ** -- G modified to have y&~z instead of y&z ** 38 | ** -- FF, GG, HH modified to add in last register done ** 39 | ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** 40 | ** -- distinct additive constant for each step ** 41 | ** -- round 4 added, working mod 7 ** 42 | *********************************************************************** 43 | */ 44 | 45 | /* 46 | *********************************************************************** 47 | ** Message-digest routines: ** 48 | ** To form the message digest for a message M ** 49 | ** (1) Initialize a context buffer mdContext using MD5Init ** 50 | ** (2) Call MD5Update on mdContext and M ** 51 | ** (3) Call MD5Final on mdContext ** 52 | ** The message digest is now in mdContext->digest[0...15] ** 53 | *********************************************************************** 54 | */ 55 | 56 | #ifndef SDL_test_md5_h_ 57 | #define SDL_test_md5_h_ 58 | 59 | #include "begin_code.h" 60 | /* Set up for C function definitions, even when using C++ */ 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | /* ------------ Definitions --------- */ 66 | 67 | /* typedef a 32-bit type */ 68 | typedef unsigned long int MD5UINT4; 69 | 70 | /* Data structure for MD5 (Message-Digest) computation */ 71 | typedef struct { 72 | MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ 73 | MD5UINT4 buf[4]; /* scratch buffer */ 74 | unsigned char in[64]; /* input buffer */ 75 | unsigned char digest[16]; /* actual digest after Md5Final call */ 76 | } SDLTest_Md5Context; 77 | 78 | /* ---------- Function Prototypes ------------- */ 79 | 80 | /** 81 | * \brief initialize the context 82 | * 83 | * \param mdContext pointer to context variable 84 | * 85 | * Note: The function initializes the message-digest context 86 | * mdContext. Call before each new use of the context - 87 | * all fields are set to zero. 88 | */ 89 | void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); 90 | 91 | 92 | /** 93 | * \brief update digest from variable length data 94 | * 95 | * \param mdContext pointer to context variable 96 | * \param inBuf pointer to data array/string 97 | * \param inLen length of data array/string 98 | * 99 | * Note: The function updates the message-digest context to account 100 | * for the presence of each of the characters inBuf[0..inLen-1] 101 | * in the message whose digest is being computed. 102 | */ 103 | 104 | void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, 105 | unsigned int inLen); 106 | 107 | 108 | /** 109 | * \brief complete digest computation 110 | * 111 | * \param mdContext pointer to context variable 112 | * 113 | * Note: The function terminates the message-digest computation and 114 | * ends with the desired message digest in mdContext.digest[0..15]. 115 | * Always call before using the digest[] variable. 116 | */ 117 | 118 | void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); 119 | 120 | 121 | /* Ends C function definitions when using C++ */ 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | #include "close_code.h" 126 | 127 | #endif /* SDL_test_md5_h_ */ 128 | 129 | /* vi: set ts=4 sw=4 expandtab: */ 130 | -------------------------------------------------------------------------------- /include/SDL_test_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_memory.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_memory_h_ 31 | #define SDL_test_memory_h_ 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | 40 | /** 41 | * \brief Start tracking SDL memory allocations 42 | * 43 | * \note This should be called before any other SDL functions for complete tracking coverage 44 | */ 45 | int SDLTest_TrackAllocations(void); 46 | 47 | /** 48 | * \brief Print a log of any outstanding allocations 49 | * 50 | * \note This can be called after SDL_Quit() 51 | */ 52 | void SDLTest_LogAllocations(void); 53 | 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* SDL_test_memory_h_ */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /include/SDL_test_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_random.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | A "32-bit Multiply with carry random number generator. Very fast. 33 | Includes a list of recommended multipliers. 34 | 35 | multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. 36 | period: (a*2^31)-1 37 | 38 | */ 39 | 40 | #ifndef SDL_test_random_h_ 41 | #define SDL_test_random_h_ 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* --- Definitions */ 50 | 51 | /* 52 | * Macros that return a random number in a specific format. 53 | */ 54 | #define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) 55 | 56 | /* 57 | * Context structure for the random number generator state. 58 | */ 59 | typedef struct { 60 | unsigned int a; 61 | unsigned int x; 62 | unsigned int c; 63 | unsigned int ah; 64 | unsigned int al; 65 | } SDLTest_RandomContext; 66 | 67 | 68 | /* --- Function prototypes */ 69 | 70 | /** 71 | * \brief Initialize random number generator with two integers. 72 | * 73 | * Note: The random sequence of numbers returned by ...Random() is the 74 | * same for the same two integers and has a period of 2^31. 75 | * 76 | * \param rndContext pointer to context structure 77 | * \param xi integer that defines the random sequence 78 | * \param ci integer that defines the random sequence 79 | * 80 | */ 81 | void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, 82 | unsigned int ci); 83 | 84 | /** 85 | * \brief Initialize random number generator based on current system time. 86 | * 87 | * \param rndContext pointer to context structure 88 | * 89 | */ 90 | void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); 91 | 92 | 93 | /** 94 | * \brief Initialize random number generator based on current system time. 95 | * 96 | * Note: ...RandomInit() or ...RandomInitTime() must have been called 97 | * before using this function. 98 | * 99 | * \param rndContext pointer to context structure 100 | * 101 | * \returns a random number (32bit unsigned integer) 102 | * 103 | */ 104 | unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* SDL_test_random_h_ */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /include/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_touch.h 24 | * 25 | * Include file for SDL touch event handling. 26 | */ 27 | 28 | #ifndef SDL_touch_h_ 29 | #define SDL_touch_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "begin_code.h" 36 | /* Set up for C function definitions, even when using C++ */ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef Sint64 SDL_TouchID; 42 | typedef Sint64 SDL_FingerID; 43 | 44 | typedef enum 45 | { 46 | SDL_TOUCH_DEVICE_INVALID = -1, 47 | SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */ 48 | SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */ 49 | SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */ 50 | } SDL_TouchDeviceType; 51 | 52 | typedef struct SDL_Finger 53 | { 54 | SDL_FingerID id; 55 | float x; 56 | float y; 57 | float pressure; 58 | } SDL_Finger; 59 | 60 | /* Used as the device ID for mouse events simulated with touch input */ 61 | #define SDL_TOUCH_MOUSEID ((Uint32)-1) 62 | 63 | /* Used as the SDL_TouchID for touch events simulated with mouse input */ 64 | #define SDL_MOUSE_TOUCHID ((Sint64)-1) 65 | 66 | 67 | /** 68 | * Get the number of registered touch devices. 69 | * 70 | * On some platforms SDL first sees the touch device if it was actually used. 71 | * Therefore SDL_GetNumTouchDevices() may return 0 although devices are 72 | * available. After using all devices at least once the number will be 73 | * correct. 74 | * 75 | * This was fixed for Android in SDL 2.0.1. 76 | * 77 | * \returns the number of registered touch devices. 78 | * 79 | * \since This function is available since SDL 2.0.0. 80 | * 81 | * \sa SDL_GetTouchDevice 82 | */ 83 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); 84 | 85 | /** 86 | * Get the touch ID with the given index. 87 | * 88 | * \param index the touch device index 89 | * \returns the touch ID with the given index on success or 0 if the index is 90 | * invalid; call SDL_GetError() for more information. 91 | * 92 | * \since This function is available since SDL 2.0.0. 93 | * 94 | * \sa SDL_GetNumTouchDevices 95 | */ 96 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); 97 | 98 | /** 99 | * Get the touch device name as reported from the driver or NULL if the index 100 | * is invalid. 101 | * 102 | * \since This function is available since SDL 2.0.22. 103 | */ 104 | extern DECLSPEC const char* SDLCALL SDL_GetTouchName(int index); 105 | 106 | /** 107 | * Get the type of the given touch device. 108 | * 109 | * \since This function is available since SDL 2.0.10. 110 | */ 111 | extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); 112 | 113 | /** 114 | * Get the number of active fingers for a given touch device. 115 | * 116 | * \param touchID the ID of a touch device 117 | * \returns the number of active fingers for a given touch device on success 118 | * or 0 on failure; call SDL_GetError() for more information. 119 | * 120 | * \since This function is available since SDL 2.0.0. 121 | * 122 | * \sa SDL_GetTouchFinger 123 | */ 124 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); 125 | 126 | /** 127 | * Get the finger object for specified touch device ID and finger index. 128 | * 129 | * The returned resource is owned by SDL and should not be deallocated. 130 | * 131 | * \param touchID the ID of the requested touch device 132 | * \param index the index of the requested finger 133 | * \returns a pointer to the SDL_Finger object or NULL if no object at the 134 | * given ID and index could be found. 135 | * 136 | * \since This function is available since SDL 2.0.0. 137 | * 138 | * \sa SDL_RecordGesture 139 | */ 140 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); 141 | 142 | /* Ends C function definitions when using C++ */ 143 | #ifdef __cplusplus 144 | } 145 | #endif 146 | #include "close_code.h" 147 | 148 | #endif /* SDL_touch_h_ */ 149 | 150 | /* vi: set ts=4 sw=4 expandtab: */ 151 | -------------------------------------------------------------------------------- /include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /include/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2023 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #ifndef SDL_begin_code_h 30 | #error close_code.h included without matching begin_code.h 31 | #endif 32 | #undef SDL_begin_code_h 33 | 34 | /* Reset structure packing at previous byte alignment */ 35 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 36 | #ifdef __BORLANDC__ 37 | #pragma nopackwarning 38 | #endif 39 | #pragma pack(pop) 40 | #endif /* Compiler needs structure packing set */ 41 | -------------------------------------------------------------------------------- /lib/cmake/SDL2/sdl2-config-version.cmake: -------------------------------------------------------------------------------- 1 | # sdl2 cmake project-config-version input for ./configure scripts 2 | 3 | set(PACKAGE_VERSION "2.28.4") 4 | 5 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 6 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 7 | else() 8 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 9 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 10 | set(PACKAGE_VERSION_EXACT TRUE) 11 | endif() 12 | endif() 13 | -------------------------------------------------------------------------------- /lib/cmake/SDL2_image/sdl2_image-config-version.cmake: -------------------------------------------------------------------------------- 1 | # sdl2_image cmake project-config-version input for ./configure scripts 2 | 3 | set(PACKAGE_VERSION "@MAJOR_VERSION_MACRO@.@MINOR_VERSION_MACRO@.@MICRO_VERSION_MACRO@") 4 | 5 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 6 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 7 | else() 8 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 9 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 10 | set(PACKAGE_VERSION_EXACT TRUE) 11 | endif() 12 | endif() 13 | 14 | -------------------------------------------------------------------------------- /lib/cmake/SDL2_image/sdl2_image-config.cmake: -------------------------------------------------------------------------------- 1 | # sdl2_image cmake project-config input for ./configure scripts 2 | 3 | include(FeatureSummary) 4 | set_package_properties(SDL2_image PROPERTIES 5 | URL "https://www.libsdl.org/projects/SDL_image/" 6 | DESCRIPTION "SDL_image is an image file loading library" 7 | ) 8 | 9 | set(SDL2_image_FOUND TRUE) 10 | 11 | set(SDL2IMAGE_AVIF 0) 12 | set(SDL2IMAGE_BMP 1) 13 | set(SDL2IMAGE_GIF 1) 14 | set(SDL2IMAGE_JPG 1) 15 | set(SDL2IMAGE_JXL 0) 16 | set(SDL2IMAGE_LBM 1) 17 | set(SDL2IMAGE_PCX 1) 18 | set(SDL2IMAGE_PNG 1) 19 | set(SDL2IMAGE_PNM 1) 20 | set(SDL2IMAGE_QOI 1) 21 | set(SDL2IMAGE_SVG 1) 22 | set(SDL2IMAGE_TGA 1) 23 | set(SDL2IMAGE_TIF 0) 24 | set(SDL2IMAGE_XCF 1) 25 | set(SDL2IMAGE_XPM 1) 26 | set(SDL2IMAGE_XV 1) 27 | set(SDL2IMAGE_WEBP 0) 28 | 29 | set(SDL2IMAGE_JPG_SAVE 1) 30 | set(SDL2IMAGE_PNG_SAVE 1) 31 | 32 | set(SDL2IMAGE_VENDORED FALSE) 33 | 34 | set(SDL2IMAGE_BACKEND_IMAGEIO 0) 35 | set(SDL2IMAGE_BACKEND_STB 1) 36 | set(SDL2IMAGE_BACKEND_WIC 0) 37 | 38 | get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) 39 | set(exec_prefix "${prefix}") 40 | set(bindir "${exec_prefix}/bin") 41 | set(includedir "${prefix}/include") 42 | set(libdir "${exec_prefix}/lib") 43 | set(_sdl2image_extra_static_libraries " ") 44 | string(STRIP "${_sdl2image_extra_static_libraries}" _sdl2image_extra_static_libraries) 45 | 46 | set(_sdl2image_bindir "${bindir}") 47 | set(_sdl2image_libdir "${libdir}") 48 | set(_sdl2image_incdir "${includedir}/SDL2") 49 | 50 | # Convert _sdl2image_extra_static_libraries to list and keep only libraries 51 | string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2image_extra_static_libraries "${_sdl2image_extra_static_libraries}") 52 | string(REGEX REPLACE "^-l" "" _sdl2image_extra_static_libraries "${_sdl2image_extra_static_libraries}") 53 | string(REGEX REPLACE ";-l" ";" _sdl2image_extra_static_libraries "${_sdl2image_extra_static_libraries}") 54 | 55 | unset(prefix) 56 | unset(exec_prefix) 57 | unset(bindir) 58 | unset(includedir) 59 | unset(libdir) 60 | 61 | include(CMakeFindDependencyMacro) 62 | 63 | if(NOT TARGET SDL2_image::SDL2_image) 64 | add_library(SDL2_image::SDL2_image SHARED IMPORTED) 65 | set_target_properties(SDL2_image::SDL2_image 66 | PROPERTIES 67 | INTERFACE_INCLUDE_DIRECTORIES "${_sdl2image_incdir}" 68 | COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" 69 | INTERFACE_SDL2_SHARED "ON" 70 | ) 71 | if(WIN32) 72 | set_target_properties(SDL2_image::SDL2_image 73 | PROPERTIES 74 | IMPORTED_LOCATION "${_sdl2image_bindir}/SDL2_image.dll" 75 | IMPORTED_IMPLIB "${_sdl2image_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_image.dll${CMAKE_STATIC_LIBRARY_SUFFIX}" 76 | ) 77 | else() 78 | set_target_properties(SDL2_image::SDL2_image 79 | PROPERTIES 80 | IMPORTED_LOCATION "${_sdl2image_libdir}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2_image${CMAKE_SHARED_LIBRARY_SUFFIX}" 81 | ) 82 | endif() 83 | endif() 84 | 85 | if(NOT TARGET SDL2_image::SDL2_image-static) 86 | add_library(SDL2_image::SDL2_image-static STATIC IMPORTED) 87 | 88 | set_target_properties(SDL2_image::SDL2_image-static 89 | PROPERTIES 90 | INTERFACE_INCLUDE_DIRECTORIES "${_sdl2image_incdir}" 91 | IMPORTED_LOCATION "${_sdl2image_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_image${CMAKE_STATIC_LIBRARY_SUFFIX}" 92 | INTERFACE_LINK_LIBRARIES "${_sdl2image_extra_static_libraries}" 93 | ) 94 | endif() 95 | 96 | unset(_sdl2image_extra_static_libraries) 97 | unset(_sdl2image_bindir) 98 | unset(_sdl2image_libdir) 99 | unset(_sdl2image_incdir) 100 | -------------------------------------------------------------------------------- /lib/cmake/SDL2_ttf/sdl2_ttf-config-version.cmake: -------------------------------------------------------------------------------- 1 | # sdl2_ttf cmake project-config-version input for ./configure scripts 2 | 3 | set(PACKAGE_VERSION "2.20.2") 4 | 5 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 6 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 7 | else() 8 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 9 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 10 | set(PACKAGE_VERSION_EXACT TRUE) 11 | endif() 12 | endif() 13 | -------------------------------------------------------------------------------- /lib/cmake/SDL2_ttf/sdl2_ttf-config.cmake: -------------------------------------------------------------------------------- 1 | # sdl2_ttf cmake project-config input for ./configure scripts 2 | 3 | include(FeatureSummary) 4 | set_package_properties(SDL2_ttf PROPERTIES 5 | URL "https://www.libsdl.org/projects/SDL_ttf/" 6 | DESCRIPTION "Support for TrueType (.ttf) font files with Simple Directmedia Layer" 7 | ) 8 | 9 | set(SDL2_ttf_FOUND TRUE) 10 | 11 | set(SDL2TTF_HARFBUZZ 1) 12 | set(SDL2TTF_FREETYPE TRUE) 13 | 14 | set(SDL2TTF_VENDORED 1) 15 | 16 | set(SDL2TTF_SDL2_REQUIRED_VERSION 2.0.10) 17 | 18 | get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) 19 | set(exec_prefix "${prefix}") 20 | set(bindir "${exec_prefix}/bin") 21 | set(includedir "${prefix}/include") 22 | set(libdir "${exec_prefix}/lib") 23 | set(_sdl2ttf_extra_static_libraries " -lusp10 -lgdi32 -lrpcrt4 -lusp10 -lgdi32 -lrpcrt4") 24 | string(STRIP "${_sdl2ttf_extra_static_libraries}" _sdl2ttf_extra_static_libraries) 25 | 26 | set(_sdl2ttf_bindir "${bindir}") 27 | set(_sdl2ttf_libdir "${libdir}") 28 | set(_sdl2ttf_incdir "${includedir}/SDL2") 29 | 30 | # Convert _sdl2ttf_extra_static_libraries to list and keep only libraries 31 | string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") 32 | string(REGEX REPLACE "^-l" "" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") 33 | string(REGEX REPLACE ";-l" ";" _sdl2ttf_extra_static_libraries "${_sdl2ttf_extra_static_libraries}") 34 | 35 | unset(prefix) 36 | unset(exec_prefix) 37 | unset(bindir) 38 | unset(includedir) 39 | unset(libdir) 40 | 41 | include(CMakeFindDependencyMacro) 42 | 43 | if(NOT TARGET SDL2_ttf::SDL2_ttf) 44 | if(WIN32) 45 | set(_sdl2ttf_dll "${_sdl2ttf_bindir}/SDL2_ttf.dll") 46 | set(_sdl2ttf_imp "${_sdl2ttf_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf.dll${CMAKE_STATIC_LIBRARY_SUFFIX}") 47 | if(EXISTS "${_sdl2ttf_dll}" AND EXISTS "${_sdl2ttf_imp}") 48 | add_library(SDL2_ttf::SDL2_ttf SHARED IMPORTED) 49 | set_target_properties(SDL2_ttf::SDL2_ttf 50 | PROPERTIES 51 | IMPORTED_LOCATION "${_sdl2ttf_dll}" 52 | IMPORTED_IMPLIB "${_sdl2ttf_imp}" 53 | ) 54 | endif() 55 | unset(_sdl2ttf_dll) 56 | unset(_sdl2ttf_imp) 57 | else() 58 | set(_sdl2ttf_shl "${_sdl2ttf_libdir}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2_ttf${CMAKE_SHARED_LIBRARY_SUFFIX}") 59 | if(EXISTS "${_sdl2ttf_shl}") 60 | add_library(SDL2_ttf::SDL2_ttf SHARED IMPORTED) 61 | set_target_properties(SDL2_ttf::SDL2_ttf 62 | PROPERTIES 63 | IMPORTED_LOCATION "${_sdl2ttf_shl}" 64 | ) 65 | endif() 66 | endif() 67 | if(TARGET SDL2_ttf::SDL2_ttf) 68 | set_target_properties(SDL2_ttf::SDL2_ttf 69 | PROPERTIES 70 | INTERFACE_INCLUDE_DIRECTORIES "${_sdl2ttf_incdir}" 71 | COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" 72 | INTERFACE_SDL2_SHARED "ON" 73 | ) 74 | endif() 75 | endif() 76 | 77 | if(NOT TARGET SDL2_ttf::SDL2_ttf-static) 78 | set(_sdl2ttf_stl "${_sdl2ttf_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf${CMAKE_STATIC_LIBRARY_SUFFIX}") 79 | if(EXISTS "${_sdl2ttf_stl}") 80 | add_library(SDL2_ttf::SDL2_ttf-static STATIC IMPORTED) 81 | set_target_properties(SDL2_ttf::SDL2_ttf-static 82 | PROPERTIES 83 | INTERFACE_INCLUDE_DIRECTORIES "${_sdl2ttf_incdir}" 84 | IMPORTED_LOCATION "${_sdl2ttf_stl}" 85 | INTERFACE_LINK_LIBRARIES "${_sdl2ttf_extra_static_libraries}" 86 | ) 87 | endif() 88 | unset(_sdl2ttf_stl) 89 | endif() 90 | 91 | unset(_sdl2ttf_extra_static_libraries) 92 | unset(_sdl2ttf_bindir) 93 | unset(_sdl2ttf_libdir) 94 | unset(_sdl2ttf_incdir) 95 | -------------------------------------------------------------------------------- /lib/libSDL2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2.a -------------------------------------------------------------------------------- /lib/libSDL2.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2.dll.a -------------------------------------------------------------------------------- /lib/libSDL2.la: -------------------------------------------------------------------------------- 1 | # libSDL2.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='../bin/SDL2.dll' 9 | 10 | # Names of this library. 11 | library_names='libSDL2.dll.a' 12 | 13 | # The name of the static archive. 14 | old_library='libSDL2.a' 15 | 16 | # Linker flags that cannot go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs=' -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libSDL2. 26 | current=2800 27 | age=2800 28 | revision=4 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/Users/valve/release/SDL2/SDL2-2.28.4/x86_64-w64-mingw32/lib' 42 | -------------------------------------------------------------------------------- /lib/libSDL2_image.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2_image.a -------------------------------------------------------------------------------- /lib/libSDL2_image.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2_image.dll.a -------------------------------------------------------------------------------- /lib/libSDL2_image.la: -------------------------------------------------------------------------------- 1 | # libSDL2_image.la - a libtool library file 2 | # Generated by ltmain.sh (GNU libtool) 2.2.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='../bin/SDL2_image.dll' 9 | 10 | # Names of this library. 11 | library_names='libSDL2_image.dll.a' 12 | 13 | # The name of the static archive. 14 | old_library='libSDL2_image.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs=' -L/usr/local/x86_64-w64-mingw32/lib -lmingw32 /usr/local/x86_64-w64-mingw32/lib/libSDL2.la -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libSDL2_image. 26 | current=600 27 | age=600 28 | revision=3 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/Users/valve/release/SDL_image/SDL2_image-2.6.3/x86_64-w64-mingw32/lib' 42 | -------------------------------------------------------------------------------- /lib/libSDL2_test.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2_test.a -------------------------------------------------------------------------------- /lib/libSDL2_test.la: -------------------------------------------------------------------------------- 1 | # libSDL2_test.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='' 9 | 10 | # Names of this library. 11 | library_names='' 12 | 13 | # The name of the static archive. 14 | old_library='libSDL2_test.a' 15 | 16 | # Linker flags that cannot go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs='' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libSDL2_test. 26 | current=0 27 | age=0 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/Users/valve/release/SDL2/SDL2-2.28.4/x86_64-w64-mingw32/lib' 42 | -------------------------------------------------------------------------------- /lib/libSDL2_ttf.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2_ttf.a -------------------------------------------------------------------------------- /lib/libSDL2_ttf.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2_ttf.dll.a -------------------------------------------------------------------------------- /lib/libSDL2_ttf.la: -------------------------------------------------------------------------------- 1 | # libSDL2_ttf.la - a libtool library file 2 | # Generated by ltmain.sh (GNU libtool) 2.2.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='../bin/SDL2_ttf.dll' 9 | 10 | # Names of this library. 11 | library_names='libSDL2_ttf.dll.a' 12 | 13 | # The name of the static archive. 14 | old_library='libSDL2_ttf.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs=' -lusp10 -lrpcrt4 -L/usr/local/x86_64-w64-mingw32/lib /usr/local/x86_64-w64-mingw32/lib/libSDL2.la -ldinput8 -ldxguid -ldxerr8 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lsetupapi -lversion -luuid /opt/homebrew/Cellar/mingw-w64/10.0.0_4/toolchain-x86_64/x86_64-w64-mingw32/lib/../lib/libstdc++.la' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libSDL2_ttf. 26 | current=2000 27 | age=2000 28 | revision=2 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/Users/valve/release/SDL_ttf/SDL2_ttf-2.20.2/x86_64-w64-mingw32/lib' 42 | -------------------------------------------------------------------------------- /lib/libSDL2main.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/lib/libSDL2main.a -------------------------------------------------------------------------------- /lib/libSDL2main.la: -------------------------------------------------------------------------------- 1 | # libSDL2main.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='' 9 | 10 | # Names of this library. 11 | library_names='' 12 | 13 | # The name of the static archive. 14 | old_library='libSDL2main.a' 15 | 16 | # Linker flags that cannot go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs='' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libSDL2main. 26 | current=0 27 | age=0 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/Users/valve/release/SDL2/SDL2-2.28.4/x86_64-w64-mingw32/lib' 42 | -------------------------------------------------------------------------------- /lib/pkgconfig/SDL2_image.pc: -------------------------------------------------------------------------------- 1 | prefix=/x86_64-w64-mingw32 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: SDL2_image 7 | Description: image loading library for Simple DirectMedia Layer 8 | Version: 2.6.3 9 | Requires: sdl2 >= 2.0.9 10 | Libs: -L${libdir} -lSDL2_image 11 | Requires.private: 12 | Libs.private: 13 | Cflags: -I${includedir}/SDL2 14 | 15 | -------------------------------------------------------------------------------- /lib/pkgconfig/SDL2_ttf.pc: -------------------------------------------------------------------------------- 1 | prefix=/x86_64-w64-mingw32 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: SDL2_ttf 7 | Description: ttf library for Simple DirectMedia Layer with FreeType 2 support 8 | Version: 2.20.2 9 | Requires: sdl2 >= 2.0.10 10 | Libs: -L${libdir} -lSDL2_ttf 11 | Cflags: -I${includedir}/SDL2 12 | Requires.private: 13 | Libs.private: -lusp10 -lgdi32 -lrpcrt4 14 | -------------------------------------------------------------------------------- /lib/pkgconfig/sdl2.pc: -------------------------------------------------------------------------------- 1 | # sdl pkg-config source file 2 | 3 | prefix=/x86_64-w64-mingw32 4 | exec_prefix=${prefix} 5 | libdir=${exec_prefix}/lib 6 | includedir=${prefix}/include 7 | 8 | Name: sdl2 9 | Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. 10 | Version: 2.28.4 11 | Requires.private: 12 | Conflicts: 13 | Libs: -L${libdir} -lmingw32 -lSDL2main -lSDL2 -mwindows 14 | Libs.private: -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid 15 | Cflags: -I${includedir} -I${includedir}/SDL2 -Dmain=SDL_main 16 | -------------------------------------------------------------------------------- /media/$05151959.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/media/$05151959.gif -------------------------------------------------------------------------------- /media/commandbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/media/commandbar.png -------------------------------------------------------------------------------- /media/interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/media/interface.png -------------------------------------------------------------------------------- /res/atlas.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/atlas.aseprite -------------------------------------------------------------------------------- /res/font/arial.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/font/arial.TTF -------------------------------------------------------------------------------- /res/font/jetbrains.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/font/jetbrains.ttf -------------------------------------------------------------------------------- /res/font/pixolleta.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/font/pixolleta.ttf -------------------------------------------------------------------------------- /res/icon/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/icon/icon.ico -------------------------------------------------------------------------------- /res/icon/icon.rc: -------------------------------------------------------------------------------- 1 | id ICON "icon.ico" -------------------------------------------------------------------------------- /res/icon/icon.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/icon/icon.res -------------------------------------------------------------------------------- /res/logo.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/logo.aseprite -------------------------------------------------------------------------------- /res/main.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/main.aseprite -------------------------------------------------------------------------------- /res/main_scene.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/main_scene.aseprite -------------------------------------------------------------------------------- /res/new_scene.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/new_scene.aseprite -------------------------------------------------------------------------------- /res/sprites/Slice 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/Slice 1.png -------------------------------------------------------------------------------- /res/sprites/core/logger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/core/logger.png -------------------------------------------------------------------------------- /res/sprites/core/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/core/logo.png -------------------------------------------------------------------------------- /res/sprites/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/file.png -------------------------------------------------------------------------------- /res/sprites/file_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/file_selected.png -------------------------------------------------------------------------------- /res/sprites/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/folder.png -------------------------------------------------------------------------------- /res/sprites/folder_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/folder_selected.png -------------------------------------------------------------------------------- /res/sprites/hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/hover.png -------------------------------------------------------------------------------- /res/sprites/main_scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/main_scene.png -------------------------------------------------------------------------------- /res/sprites/new_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/new_file.png -------------------------------------------------------------------------------- /res/sprites/ready_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/ready_bar.png -------------------------------------------------------------------------------- /res/sprites/stop_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/stop_bar.png -------------------------------------------------------------------------------- /res/sprites/stop_vfx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/sprites/stop_vfx.png -------------------------------------------------------------------------------- /res/spritesheet.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/res/spritesheet.aseprite -------------------------------------------------------------------------------- /scripts_dlls/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/scripts_dlls/SDL2.dll -------------------------------------------------------------------------------- /scripts_dlls/SDL2_image.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/scripts_dlls/SDL2_image.dll -------------------------------------------------------------------------------- /scripts_dlls/SDL2_ttf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigasdev/X-Gif-Maker/876258782a284a92d96323014ee0d3ddf49e0742/scripts_dlls/SDL2_ttf.dll -------------------------------------------------------------------------------- /scripts_dlls/installer.nsi: -------------------------------------------------------------------------------- 1 | ; Set the name of your application 2 | Name "Twitter-Gif-Maker" 3 | 4 | ; Set the default installation directory (e.g., Program Files) 5 | InstallDir "$PROGRAMFILES\Twitter-Gif-Maker" 6 | 7 | ; Define the components 8 | Section "Twitter-Gif-Maker" SEC01 9 | ; Set output path to the installation directory 10 | SetOutPath $INSTDIR 11 | 12 | ; Add all files and subdirectories from your source folder 13 | File /r "C:\Users\Escritorio2\Documents\.code\twitter-gif-maker-fortress\.release\*.*" 14 | 15 | ; Create a desktop shortcut (optional) 16 | CreateShortCut "$DESKTOP\Twitter-Gif-Maker.lnk" "$INSTDIR\Twitter-Gif-Maker.exe" 17 | 18 | ; Optional: Add an uninstaller 19 | WriteUninstaller "$INSTDIR\Uninstall.exe" 20 | 21 | Exec "$INSTDIR\Twitter-Gif-Maker.exe" 22 | SectionEnd 23 | 24 | ; Optional: Uninstaller section 25 | Section "Uninstall" 26 | ; Remove installed files and shortcuts 27 | Delete "$INSTDIR\YourApp.exe" 28 | Delete "$SMPROGRAMS\YourAppName.lnk" 29 | Delete "$DESKTOP\YourAppName.lnk" 30 | 31 | ; Remove installation directory and all its contents 32 | RMDir /r "$INSTDIR" 33 | 34 | ; Remove uninstaller 35 | Delete "$INSTDIR\Uninstall.exe" 36 | SectionEnd -------------------------------------------------------------------------------- /scripts_dlls/setup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | mkdir bin 4 | mkdir .build 5 | mkdir .release 6 | 7 | xcopy "SDL2.dll" ".build" 8 | xcopy "SDL2_image.dll" ".build" /i 9 | xcopy "SDL2_ttf.dll" ".build" /i 10 | xcopy "libwinpthread-1.dll" ".build" /i 11 | xcopy "res" ".build/res/" /i /e /y 12 | 13 | xcopy "SDL2.dll" ".release" /i 14 | xcopy "SDL2_image.dll" ".release" /i 15 | xcopy "SDL2_ttf.dll" ".release" /i 16 | xcopy "libwinpthread-1.dll" ".release" /i 17 | xcopy "res" ".release/res/" /i /e /y -------------------------------------------------------------------------------- /scripts_dlls/ship.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem you could also remove the line above, because it might help you to see what happens 3 | 4 | rem /i option is needed to avoid the batch file asking you whether destination folder is a file or a folder 5 | rem /e option is needed to copy also all folders and subfolders 6 | rem /y 7 | 8 | del /Q "bin\*" 9 | xcopy "SDL2.dll" ".release" /i /y 10 | xcopy "SDL2_image.dll" ".release" /i /y 11 | xcopy "SDL2_ttf.dll" ".release" /i /y 12 | xcopy "libwinpthread-1.dll" ".release" /i /y 13 | xcopy "res" ".release/res/" /i /e /y 14 | mingw32-make build DEBUG=false 15 | del /Q "bin\*" 16 | echo Build successful 17 | timeout /t 3 -------------------------------------------------------------------------------- /scripts_dlls/update_res.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | xcopy "res" ".build/res/" /i /e /y 4 | xcopy "res" ".release/res/" /i /e /y -------------------------------------------------------------------------------- /scripts_dlls/windows_installer_translations.nsi: -------------------------------------------------------------------------------- 1 | ;At start will be searched if the current system language is in this list, 2 | ;if not the first language in this list will be chosen as language 3 | !insertmacro MUI_LANGUAGE "English" 4 | !insertmacro MUI_LANGUAGE "PortugueseBR" 5 | 6 | ;Language strings 7 | 8 | LangString LangStringSecMainComponentName ${LANG_ENGLISH} "Twitter-Gif-Maker" 9 | LangString LangStringSecMainComponentName ${LANG_PortugueseBR} "Twitter-Gif-Maker" 10 | 11 | LangString LangStringSecMainComponentDescription ${LANG_ENGLISH} "Encode and convert videos to gif to use on twitter with ffmpeg" 12 | LangString LangStringSecMainComponentDescription ${LANG_PortugueseBR} "Codifique e converta vídeos para gif para usar no twitter com ffmpeg" 13 | 14 | LangString LangStringSecOptionalComponentName ${LANG_ENGLISH} "Start Menu Shortcuts" 15 | LangString LangStringSecOptionalComponentName ${LANG_PortugueseBR} "Atalhos no menu iniciar" 16 | 17 | LangString LangStringSecOptionalComponentDescription ${LANG_ENGLISH} "Create shortcuts in the start menu" 18 | LangString LangStringSecOptionalComponentDescription ${LANG_PortugueseBR} "Crie atalhos no menu iniciar" 19 | 20 | LangString LangStringUninstallLink ${LANG_ENGLISH} "Uninstall" 21 | LangString LangStringUninstallLink ${LANG_PortugueseBR} "Desinstalar" 22 | 23 | LangString LangStringStartMenuLink ${LANG_ENGLISH} "Twitter-Gif-Maker" 24 | LangString LangStringStartMenuLink ${LANG_PortugueseBR} "Twitter-Gif-Maker" 25 | 26 | 27 | LangString LangStringCustomPageOtherOptionsTitle ${LANG_ENGLISH} "Other Options" 28 | LangString LangStringCustomPageOtherOptionsTitle ${LANG_PortugueseBR} "Outras opções" 29 | 30 | LangString LangStringCustomPageOtherOptionsSubTitle ${LANG_ENGLISH} "Select other options" 31 | LangString LangStringCustomPageOtherOptionsSubTitle ${LANG_PortugueseBR} "Selecione outras opções" 32 | 33 | LangString LangStringCustomPageOtherOptionsCheckboxOpenInstallDir ${LANG_ENGLISH} "Open the install directory" 34 | LangString LangStringCustomPageOtherOptionsCheckboxOpenInstallDir ${LANG_PortugueseBR} "Abra o diretório de instalação" 35 | 36 | LangString LangStringCustomPageOtherOptionsCheckboxOpenWebsite ${LANG_ENGLISH} "Launch the application" 37 | LangString LangStringCustomPageOtherOptionsCheckboxOpenWebsite ${LANG_PortugueseBR} "Iniciar o aplicativo" -------------------------------------------------------------------------------- /settings.ini: -------------------------------------------------------------------------------- 1 | [Files] 2 | Last opened=C:\Users\Latitude 5480\Documents\.code\Trekton\.build\datatest.ini 3 | Last opened =C:\Users\Latitude 5480\Documents\.code\Trekton\.build\datatest.ini 4 | Last opened :=C:\Users\Latitude 5480\Downloads\data.ini 5 | -------------------------------------------------------------------------------- /src/Core/App.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SDL.h" 4 | #include "../Resources/Resources.hpp" 5 | #include 6 | #include "Assert.h" 7 | #include "IniHandler.hpp" 8 | #include "../Renderer/Atlas.hpp" 9 | 10 | class Scene; 11 | //global variables 12 | extern bool debug_mode; 13 | 14 | class App { 15 | 16 | public: 17 | 18 | App(); 19 | ~App(); 20 | 21 | void init(const char* title, uint32_t xpos, uint32_t ypos, uint32_t width, uint32_t height, bool fullscreen, bool splash_screen); 22 | void load(); 23 | void handle_events(); 24 | void update(double deltaTime); 25 | void render(); 26 | void clean(); 27 | 28 | //Functionality 29 | void change_scene(Scene* scene); 30 | void change_to_next_scene(); 31 | 32 | //Util methods 33 | void change_background_color(vec3f color); 34 | 35 | //Local getters 36 | vec2f get_window_size(); 37 | 38 | //System methods 39 | float get_fps(); 40 | void set_fps(float fps); 41 | bool running(); 42 | 43 | //Getters 44 | SDL_Window* get_window(); 45 | SDL_Renderer* get_renderer(); 46 | Resources* get_resources(); 47 | Atlas* get_atlas(); 48 | IniHandler* get_ini_handler(); 49 | TTF_Font* get_main_font(); 50 | 51 | 52 | private: 53 | bool m_is_running = false; 54 | bool m_is_loaded = false; 55 | bool m_has_splash_screen = true; 56 | 57 | SDL_Window* m_window = nullptr; 58 | SDL_Renderer* m_renderer = nullptr; 59 | Resources* m_resources_ptr = nullptr; 60 | Atlas* m_atlas_ptr = nullptr; 61 | IniHandler* m_ini_handler_ptr = nullptr; 62 | 63 | //Local 64 | vec2f m_window_size = vec2f(0,0); 65 | vec3f m_window_color = vec3f(26, 25, 50); 66 | 67 | //System 68 | int m_fps = 0; 69 | }; -------------------------------------------------------------------------------- /src/Core/Assert.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef F_ENABLE_DEBUG 6 | #endif 7 | 8 | #ifdef F_ENABLE_ASSERTS 9 | #define F_ASSERT(x) { \ 10 | if(!(x)){ \ 11 | std::cerr << "Assertion Failed: " << #x << std::endl; \ 12 | __debugbreak(); \ 13 | }\ 14 | } 15 | #define F_TEST(x) { std::cerr << "Test: " << #x << std::endl; } 16 | #else 17 | #define F_ASSERT(x) 18 | #define F_TEST(x) 19 | #endif -------------------------------------------------------------------------------- /src/Core/DataLoader.cpp: -------------------------------------------------------------------------------- 1 | #include "DataLoader.hpp" 2 | 3 | const char *Data_Loader::load_file(const char *filter) 4 | { 5 | char const * lFilterPatterns[1]={filter}; 6 | auto file = tinyfd_openFileDialog("Open File", NULL, 1, lFilterPatterns, NULL, 0); 7 | 8 | if (!file) { 9 | std::cout << "No file selected" << std::endl; 10 | return ""; 11 | } 12 | 13 | return file; 14 | } 15 | 16 | const char *Data_Loader::load_folder(const char *title) 17 | { 18 | auto folder = tinyfd_selectFolderDialog(title, SDL_GetBasePath()); 19 | 20 | if (!folder) { 21 | std::cout << "No folder selected" << std::endl; 22 | return ""; 23 | } 24 | 25 | return folder; 26 | } 27 | -------------------------------------------------------------------------------- /src/Core/DataLoader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __DATA_LOADER__ 2 | #define __DATA_LOADER__ 3 | 4 | #include "../ImGui/tinyfiledialogs.h" 5 | #include "SDL.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace Data_Loader{ 12 | const char* load_file(const char* filter); 13 | const char* load_folder(const char* title); 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /src/Core/IniHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "IniHandler.hpp" 2 | 3 | #include "Assert.h" 4 | 5 | IniHandler::IniHandler() 6 | { 7 | std::cout << "INFO: Started IniHandler\n"; 8 | } 9 | 10 | IniHandler::~IniHandler() 11 | { 12 | } 13 | 14 | void IniHandler::load_ini_files(std::string path) 15 | { 16 | ini::IniFile file; 17 | 18 | file.load(path); 19 | 20 | for(const auto& sectionPair : file){ 21 | if(sectionPair.first == "config")continue; 22 | 23 | IniData data; 24 | data.fileName = path; 25 | data.name = sectionPair.first; 26 | 27 | 28 | std::unordered_map fieldMap = { 29 | {"fileName", data.fileName}, 30 | {"relative_x", std::to_string(data.relative_x)}, 31 | {"relative_y", std::to_string(data.relative_y)}, 32 | {"relative_name", data.relative_name}, 33 | }; 34 | 35 | for(auto& [key,val] : sectionPair.second){ 36 | 37 | if(fieldMap.count(key) > 0) { 38 | fieldMap[key] = val.as(); 39 | } 40 | } 41 | 42 | data.fileName = fieldMap["fileName"]; 43 | data.relative_x = std::stoi(fieldMap["relative_x"]); 44 | data.relative_y = std::stoi(fieldMap["relative_y"]); 45 | data.relative_name = fieldMap["relative_name"]; 46 | 47 | F_ASSERT(data.name != ""); 48 | ini_files.push_back(data); 49 | } 50 | } 51 | 52 | void IniHandler::update_ini_files() 53 | { 54 | if(ini_files.size() == 0)return; 55 | 56 | ini::IniFile file; 57 | 58 | file.load("config.ini"); 59 | 60 | if(file["config"]["lastWriteTime"].as() != std::to_string(std::filesystem::last_write_time("config.ini").time_since_epoch().count())){ 61 | 62 | for(auto& ini : ini_files){ 63 | if(ini.name == "")continue; 64 | 65 | ini.name = file[ini.name]["name"].as(); 66 | ini.relative_x = file[ini.name]["relative_x"].as(); 67 | ini.relative_y = file[ini.name]["relative_y"].as(); 68 | ini.relative_name = file[ini.name]["relative_name"].as(); 69 | 70 | update_ini_file(ini); 71 | } 72 | 73 | file["config"]["lastWriteTime"] = std::to_string(std::filesystem::last_write_time("config.ini").time_since_epoch().count()); 74 | file.save("config.ini"); 75 | } 76 | } 77 | 78 | void IniHandler::update_ini_file(IniData data) 79 | { 80 | F_ASSERT(data.name != ""); 81 | ini::IniFile file; 82 | 83 | if(data.name == "")return; 84 | 85 | file.load(data.fileName); 86 | 87 | file[data.name]; 88 | file[data.name]["name"] = data.name; 89 | file[data.name]["fileName"] = data.fileName; 90 | file[data.name]["relative_x"] = std::to_string(data.relative_x); 91 | file[data.name]["relative_y"] = std::to_string(data.relative_y); 92 | file[data.name]["relative_name"] = data.relative_name; 93 | 94 | file.save(data.fileName); 95 | } 96 | 97 | void IniHandler::create_ini_file(IniData data, std::string path) 98 | { 99 | F_ASSERT(data.name != ""); 100 | 101 | ini::IniFile file; 102 | 103 | std::cout << "INFO: Creating ini file " << path << data.name << "\n"; 104 | 105 | file.load(path); 106 | 107 | file[data.name]; 108 | file[data.name]["name"] = data.name; 109 | file[data.name]["fileName"] = data.fileName; 110 | file[data.name]["relative_x"] = std::to_string(data.relative_x); 111 | file[data.name]["relative_y"] = std::to_string(data.relative_y); 112 | file[data.name]["relative_name"] = data.relative_name; 113 | 114 | if(ini_files.size() > 0){ 115 | file["config"]["lastWriteTime"] = std::to_string(std::filesystem::last_write_time(data.fileName).time_since_epoch().count()); 116 | } 117 | 118 | file.save(path); 119 | ini_files.push_back(data); 120 | } 121 | 122 | IniData* IniHandler::get_ini_data(std::string name) 123 | { 124 | for(auto& ini : ini_files){ 125 | if(ini.name == name){ 126 | return &ini; 127 | } 128 | } 129 | 130 | IniData data; 131 | data.fileName = "config.ini"; 132 | data.name = name; 133 | 134 | create_ini_file(data, "config.ini"); 135 | 136 | return &data; 137 | } 138 | -------------------------------------------------------------------------------- /src/Core/IniHandler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef INIHANDLER_HPP 4 | #define INIHANDLER_HPP 5 | 6 | #include "../Utils/inicpp.h" 7 | #include "../Utils/Common.hpp" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | //Base class to handle all the ini files the project needs 16 | //It will load an have an update class to update the ini struct if the file was modified 17 | 18 | struct IniData{ 19 | std::string fileName; 20 | std::string name; 21 | int relative_x = 0; 22 | int relative_y = 0; 23 | std::string relative_name = "null"; 24 | 25 | bool was_modified = false; 26 | }; 27 | 28 | class IniHandler{ 29 | public: 30 | IniHandler(); 31 | ~IniHandler(); 32 | 33 | void load_ini_files(std::string path); 34 | void update_ini_files(); 35 | 36 | void update_ini_file(IniData data); 37 | 38 | void create_ini_file(IniData data, std::string path); 39 | IniData* get_ini_data(std::string name); 40 | 41 | private: 42 | std::vector ini_files; 43 | }; 44 | 45 | #endif -------------------------------------------------------------------------------- /src/Core/main.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "App.hpp" 3 | 4 | //Initialization of the app and calling all the core functions 5 | int main(int args, char *argv[]) { 6 | //Fps 7 | Uint64 currentTick = SDL_GetPerformanceCounter(); 8 | Uint64 lastTick = 0; 9 | double deltaTime = 0; 10 | const double desiredFPS = 60.0; 11 | const double frameTime = 1.0 / desiredFPS; 12 | double accumulatedTime = 0; 13 | 14 | Uint32 start_time, frame_time; 15 | float fps; 16 | 17 | //App 18 | std::unique_ptr mApp = std::make_unique(); 19 | 20 | mApp->init("X-Gif-Maker v1.0", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 804, 384, false, false); 21 | 22 | while (mApp->running()) { 23 | 24 | //Gathering the fps before everything so it can calculate the difference for the framerate; 25 | lastTick = currentTick; 26 | currentTick = SDL_GetPerformanceCounter(); 27 | deltaTime = (double)((currentTick - lastTick) / (double)SDL_GetPerformanceFrequency()); 28 | 29 | start_time = SDL_GetTicks(); 30 | 31 | //Core functions 32 | //The core functions are all called inside the app, more functionality is added to the app class 33 | //Through the scenes 34 | accumulatedTime += deltaTime; 35 | 36 | while (accumulatedTime >= frameTime) { 37 | mApp->handle_events(); 38 | mApp->update(frameTime); 39 | 40 | accumulatedTime -= frameTime; 41 | 42 | } 43 | 44 | mApp->render(); 45 | 46 | //Framerate calculation 47 | frame_time = SDL_GetTicks()-start_time; 48 | fps = (frame_time > 0) ? 1000.0f / frame_time : 0.0f; 49 | 50 | //Sending the fps to the app so it can be displayed 51 | mApp->set_fps(fps); 52 | mApp->load(); 53 | } 54 | 55 | mApp->clean(); 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /src/Entity/Enemy.cpp: -------------------------------------------------------------------------------- 1 | #include "Enemy.hpp" 2 | 3 | Enemy::Enemy() 4 | { 5 | } 6 | 7 | Enemy::Enemy(vec2f _pos, vec2f _scale, SDL_Texture *_texture, int _uid) 8 | { 9 | m_pos = _pos; 10 | m_scale = _scale; 11 | m_texture = _texture; 12 | m_uid = _uid; 13 | 14 | //random initializers 15 | m_spawned_timer = Random::get(0, 5); 16 | 17 | m_idle_time = Random::get(1, 9); 18 | m_walk_time = Random::get(2, 8); 19 | m_moving_right = Random::get(0.5); 20 | } 21 | 22 | Enemy::~Enemy() 23 | { 24 | } 25 | 26 | void Enemy::set_name(std::string name) 27 | { 28 | } 29 | 30 | void Enemy::set_state(EnemyState state) 31 | { 32 | } 33 | 34 | std::string Enemy::get_name() 35 | { 36 | return std::string(); 37 | } 38 | 39 | EnemyState Enemy::get_state() 40 | { 41 | return m_state; 42 | } 43 | 44 | bool Enemy::is_moving_right() 45 | { 46 | return m_moving_right; 47 | } 48 | 49 | void Enemy::update(double deltaTime) 50 | { 51 | } 52 | 53 | void Enemy::draw(Resources *resources) 54 | { 55 | if(m_life.value < m_life.max) 56 | for(int i = 0; i < m_life.value; i++){ 57 | m_renderer->draw_pixel(m_pos.x + i, m_pos.y + 45, 255, 0, 0, 255); 58 | } 59 | } 60 | 61 | void Enemy::input(SDL_Event event) 62 | { 63 | } 64 | -------------------------------------------------------------------------------- /src/Entity/Enemy.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _ENEMY_HPP_ 2 | #define _ENEMY_HPP_ 3 | 4 | #include "Entity.hpp" 5 | 6 | enum EnemyState{ 7 | ENEMY_IDLE, 8 | ENEMY_WALKING, 9 | ENEMY_RUNNING, 10 | ENEMY_ATTACKING, 11 | ENEMY_CREATING 12 | }; 13 | 14 | class Enemy : public Entity{ 15 | public: 16 | Enemy(); 17 | Enemy(vec2f _pos, vec2f _scale, SDL_Texture* _texture, int _uid); 18 | ~Enemy(); 19 | 20 | void set_name(std::string name); 21 | void set_state(EnemyState state); 22 | std::string get_name(); 23 | EnemyState get_state(); 24 | 25 | bool is_moving_right(); 26 | 27 | void update(double deltaTime); 28 | void draw(Resources* resources); 29 | void input(SDL_Event event); 30 | 31 | private: 32 | std::string m_name; 33 | 34 | EnemyState m_state = ENEMY_CREATING; 35 | 36 | float m_spawned_timer = 0; 37 | float m_idle_timer = 0; 38 | float m_walk_timer = 0; 39 | float m_speed = 15; 40 | 41 | float m_idle_time = 5; 42 | float m_walk_time = 5; 43 | 44 | //booleans 45 | bool m_moving_right = true; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/Entity/Entity.cpp: -------------------------------------------------------------------------------- 1 | #include "Entity.hpp" 2 | 3 | Entity::Entity() 4 | { 5 | } 6 | 7 | Entity::Entity(vec2f _pos, vec2f _scale, SDL_Texture *_texture, int _uid) 8 | { 9 | m_pos = _pos; 10 | m_texture = _texture; 11 | m_uid = _uid; 12 | m_current_frame.w = _scale.x; 13 | m_current_frame.h = _scale.y; 14 | } 15 | 16 | void Entity::set_pos(float xpos, float ypos) 17 | { 18 | m_pos.x = xpos; 19 | m_pos.y = ypos; 20 | } 21 | 22 | void Entity::set_scale(float w, float h) 23 | { 24 | m_scale.x = w; 25 | m_scale.y = h; 26 | } 27 | 28 | void Entity::set_angle(float _angle) 29 | { 30 | m_angle = _angle; 31 | } 32 | 33 | void Entity::set_life(float _maxLife, float _life) 34 | { 35 | m_life = Life(_maxLife, _life); 36 | } 37 | 38 | void Entity::set_speed(float _speed) 39 | { 40 | m_speed = _speed; 41 | } 42 | 43 | void Entity::change_state(State _state, const char* reason) 44 | { 45 | std::cout << reason << std::endl; 46 | m_current_state = _state; 47 | } 48 | 49 | void Entity::change_visibility(bool _visible) 50 | { 51 | m_visible = _visible; 52 | } 53 | 54 | void Entity::set_move(bool _moving) 55 | { 56 | m_moving = _moving; 57 | } 58 | 59 | void Entity::input(SDL_Event event) 60 | { 61 | 62 | } 63 | 64 | SDL_Texture* Entity::get_texture() 65 | { 66 | 67 | return m_texture; 68 | } 69 | void Entity::set_texture(SDL_Texture* _texture) 70 | { 71 | if(_texture == nullptr){ 72 | std::cout << "Texture is null" << std::endl; 73 | return; 74 | } 75 | m_texture = _texture; 76 | } 77 | 78 | void Entity::set_renderer(EntityRenderer *_renderer) 79 | { 80 | m_renderer = _renderer; 81 | } 82 | 83 | void Entity::set_current_sprite(Sprite _sprite) 84 | { 85 | m_current_sprite = _sprite; 86 | } 87 | 88 | void Entity::add_sprite_animation(SpriteAnimation _animation) 89 | { 90 | m_animations.push_back(_animation); 91 | } 92 | 93 | void Entity::set_animation(std::string _name) 94 | { 95 | for (auto const& animation : m_animations) { 96 | if (animation.name == _name) { 97 | //mCurrentAnimation = animation; 98 | return; 99 | } 100 | } 101 | } 102 | 103 | SDL_Rect Entity::get_current_frame() 104 | { 105 | return m_current_frame; 106 | } 107 | 108 | Sprite Entity::get_current_sprite() 109 | { 110 | return m_current_sprite; 111 | } 112 | 113 | vec2f Entity::get_pos() 114 | { 115 | return m_pos; 116 | } 117 | 118 | vec2f Entity::get_scale() 119 | { 120 | return m_scale; 121 | } 122 | 123 | float Entity::get_speed() 124 | { 125 | return m_speed; 126 | } 127 | 128 | float Entity::get_angle() 129 | { 130 | return m_angle; 131 | } 132 | 133 | int Entity::get_uid() 134 | { 135 | return m_uid; 136 | } 137 | 138 | bool Entity::is_visible() 139 | { 140 | return m_visible; 141 | } 142 | 143 | bool Entity::is_moving() 144 | { 145 | return m_moving; 146 | } 147 | 148 | bool Entity::is_close_to_pos(vec2f pos, float radius) 149 | { 150 | return (pos.x + radius < m_pos.x && m_pos.x < pos.x + radius) && 151 | (pos.y - radius < m_pos.y && m_pos.y < pos.y + radius); 152 | } 153 | 154 | void Entity::hit(float damage, Entity* from) 155 | { 156 | m_life.add(damage); 157 | } 158 | 159 | void Entity::update(double deltaTime) 160 | { 161 | } 162 | 163 | void Entity::draw(Resources* resources) 164 | { 165 | } 166 | 167 | bool Entity::is_alive() 168 | { 169 | return m_life.is_alive(); 170 | } 171 | 172 | float Entity::get_current_life() 173 | { 174 | return m_life.value; 175 | } 176 | -------------------------------------------------------------------------------- /src/Entity/Entity.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SDL.h" 3 | #include "../Utils/Common.hpp" 4 | #include "SDL_image.h" 5 | #include "../Utils/Sprite.hpp" 6 | #include "../Resources/Resources.hpp" 7 | #include "../Renderer/EntityRenderer.hpp" 8 | 9 | #include "../Utils/random.hpp" 10 | 11 | using Random = effolkronium::random_static; 12 | 13 | #include 14 | #include 15 | 16 | struct Sprite{ 17 | SDL_Texture* texture; 18 | 19 | vec2f sprite_pos; 20 | vec2f sprite_scale; 21 | 22 | int sprite_scale_multiplier; 23 | }; 24 | 25 | //main class for the entities, in our app everything that will be displayed and have interaction is an entity 26 | class Entity { 27 | public: 28 | //constructors, so a entity might not be able to access app if we want to. 29 | Entity(); 30 | Entity(vec2f _pos, vec2f _scale, SDL_Texture* _texture, int _uid); 31 | 32 | //setters 33 | void set_pos(float xpos, float ypos); 34 | void set_scale(float w, float h); 35 | void set_angle(float _angle); 36 | void set_life(float _maxLife, float _life); 37 | void set_speed(float _speed); 38 | void set_texture(SDL_Texture* _texture); 39 | void set_renderer(EntityRenderer* _renderer); 40 | void set_current_sprite(Sprite _sprite); 41 | 42 | //animation stuff 43 | void add_sprite_animation(SpriteAnimation _animation); 44 | void set_animation(std::string _name); 45 | 46 | void change_state(State _state, const char* reason); 47 | void change_visibility(bool _visible); 48 | void set_move(bool _moving); 49 | 50 | //input stuff 51 | void input(SDL_Event event); 52 | 53 | //getters 54 | SDL_Texture* get_texture(); 55 | SDL_Rect get_current_frame(); 56 | Sprite get_current_sprite(); 57 | vec2f get_pos(); 58 | vec2f get_scale(); 59 | float get_speed(); 60 | float get_angle(); 61 | int get_uid(); 62 | bool is_visible(); 63 | bool is_moving(); 64 | 65 | //utils 66 | bool is_close_to_pos(vec2f pos, float radius); 67 | 68 | //functionality methods 69 | void hit(float damage, Entity* from); 70 | void update(double deltaTime); 71 | void draw(Resources* resources); 72 | bool is_alive(); 73 | float get_current_life(); 74 | 75 | //a default spriteanimation 76 | //SpriteAnimation mCurrentAnimation = SpriteAnimation("default", std::vector{"default", "default1"}, nullptr); 77 | 78 | protected: 79 | //global variables that every entity should be able to call 80 | 81 | //controller variables 82 | int m_uid; 83 | 84 | //draw/pos stuff 85 | EntityRenderer* m_renderer; 86 | Sprite m_current_sprite; 87 | vec2f m_pos; 88 | float m_angle = 0; 89 | vec2f m_scale = vec2f(1, 1); 90 | SDL_Rect m_current_frame = {0,0,0,0}; 91 | SDL_Texture* m_texture; 92 | bool m_visible = true; 93 | bool m_moving = false; 94 | std::vector m_animations; 95 | //SpriteAnimation mCurrentAnimation; 96 | 97 | //parameters 98 | Life m_life = Life(100, 100); 99 | State m_current_state = UPDATE; 100 | float m_speed = 1; 101 | }; -------------------------------------------------------------------------------- /src/Entity/FileEntity.cpp: -------------------------------------------------------------------------------- 1 | #include "FileEntity.hpp" 2 | 3 | FileEntity::FileEntity() 4 | { 5 | } 6 | 7 | FileEntity::FileEntity(vec2f _pos, vec2f _scale, SDL_Texture *_texture, int _uid) : Entity(_pos, _scale, _texture, _uid) 8 | { 9 | 10 | } 11 | 12 | void FileEntity::set_file_path(std::string _file_path, std::string path) 13 | { 14 | m_file_path = _file_path; 15 | m_complete_file_path = path; 16 | 17 | if(m_file_path.length() > 6) 18 | { 19 | m_file_path = m_file_path.substr(0, 6) + ".."; 20 | } 21 | } 22 | 23 | std::string FileEntity::get_file_path() 24 | { 25 | return m_file_path; 26 | } 27 | 28 | std::string FileEntity::get_complete_file_path() 29 | { 30 | return m_complete_file_path; 31 | } 32 | 33 | void FileEntity::hover(bool state) 34 | { 35 | m_hovered = state; 36 | } 37 | 38 | bool FileEntity::is_hovered() 39 | { 40 | return m_hovered; 41 | } 42 | -------------------------------------------------------------------------------- /src/Entity/FileEntity.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILEENTITY_HPP 2 | #define FILEENTITY_HPP 3 | 4 | #include "Entity.hpp" 5 | 6 | class FileEntity : public Entity { 7 | public: 8 | FileEntity(); 9 | FileEntity(vec2f _pos, vec2f _scale, SDL_Texture *_texture, int _uid); 10 | 11 | void set_file_path(std::string _file_path, std::string path); 12 | std::string get_file_path(); 13 | std::string get_complete_file_path(); 14 | void hover(bool state); 15 | 16 | bool is_hovered(); 17 | 18 | private: 19 | std::string m_file_path; 20 | std::string m_complete_file_path; 21 | 22 | bool m_hovered = false; 23 | }; 24 | 25 | #endif -------------------------------------------------------------------------------- /src/ImGui/imgui_impl_sdl.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for SDL2 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 10 | // Missing features: 11 | // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. 12 | 13 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 14 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 15 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 16 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 17 | 18 | #pragma once 19 | #include "imgui.h" // IMGUI_IMPL_API 20 | 21 | struct SDL_Window; 22 | struct SDL_Renderer; 23 | typedef union SDL_Event SDL_Event; 24 | 25 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context); 26 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window); 27 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window); 28 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window); 29 | IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer); 30 | IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown(); 31 | IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(); 32 | IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event); 33 | 34 | #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS 35 | static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter 36 | #endif 37 | -------------------------------------------------------------------------------- /src/ImGui/imgui_impl_sdlrenderer.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for SDL_Renderer 2 | // (Requires: SDL 2.0.17+) 3 | 4 | // Important to understand: SDL_Renderer is an _optional_ component of SDL. 5 | // For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX. 6 | // If your application will want to render any non trivial amount of graphics other than UI, 7 | // please be aware that SDL_Renderer offers a limited graphic API to the end-user and it might 8 | // be difficult to step out of those boundaries. 9 | // However, we understand it is a convenient choice to get an app started easily. 10 | 11 | // Implemented features: 12 | // [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! 13 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 14 | 15 | #pragma once 16 | #include "imgui.h" // IMGUI_IMPL_API 17 | 18 | struct SDL_Renderer; 19 | 20 | IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer); 21 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_Shutdown(); 22 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_NewFrame(); 23 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data); 24 | 25 | // Called by Init/NewFrame/Shutdown 26 | IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateFontsTexture(); 27 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyFontsTexture(); 28 | IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateDeviceObjects(); 29 | IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyDeviceObjects(); 30 | -------------------------------------------------------------------------------- /src/Renderer/AppGui.cpp: -------------------------------------------------------------------------------- 1 | #include "AppGui.hpp" 2 | 3 | void GUI::setup(SDL_Window* window, SDL_Renderer* renderer) 4 | { 5 | IMGUI_CHECKVERSION(); 6 | ImGui::CreateContext(); 7 | ImGuiIO& io = ImGui::GetIO(); (void)io; 8 | 9 | //io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange; 10 | 11 | //styling 12 | ImGuiStyle& style = ImGui::GetStyle(); 13 | style.WindowRounding = 5; 14 | style.WindowTitleAlign = ImVec2(0.05f, 0.5f); 15 | style.WindowBorderSize = 0; 16 | style.FrameRounding = 2; 17 | style.ScrollbarRounding = 0; 18 | style.FramePadding = ImVec2(4, 2); 19 | style.ChildRounding = 5; 20 | style.Colors[ImGuiCol_Button] = ImVec4{0.25f, 0.29f, 0.43f, 0}; 21 | style.Colors[ImGuiCol_ChildBg] = ImVec4{0.15f, 0.15f, 0.15f, 1}; 22 | style.Colors[ImGuiCol_WindowBg] = ImVec4{0.25f, 0.29f, 0.43f, 0}; 23 | style.Colors[ImGuiCol_Header] = ImVec4{0.25f, 0.29f, 0.43f, 0}; 24 | style.Colors[ImGuiCol_ButtonActive] = ImVec4{0.34f, 0.43f, 0.25f, 0}; 25 | style.Colors[ImGuiCol_ButtonHovered] = ImVec4{0.39f, 0.45f, 0.57f, 1.0f}; 26 | style.Colors[ImGuiCol_Border] = ImVec4{0.39f, 0.45f, 0.57f, .4f}; 27 | style.Colors[ImGuiCol_TitleBg] = ImVec4{0.25f, 0.29f, 0.43f, 1.0f}; 28 | style.Colors[ImGuiCol_TitleBgActive] = ImVec4{0.34f, 0.43f, 0.25f, 1.0f}; 29 | 30 | //adding custom font 31 | io.Fonts->AddFontFromFileTTF("res/font/pixolleta.ttf", 10); 32 | 33 | 34 | 35 | //ImGui::StyleColorsDark(); 36 | 37 | ImGui_ImplSDL2_InitForSDLRenderer(window, renderer); 38 | ImGui_ImplSDLRenderer_Init(renderer); 39 | } 40 | 41 | void GUI::event(SDL_Event event) 42 | { 43 | ImGui_ImplSDL2_ProcessEvent(&event); 44 | } 45 | 46 | 47 | void GUI::draw(std::function function) 48 | { 49 | // Start the Dear ImGui frame 50 | ImGui_ImplSDLRenderer_NewFrame(); 51 | ImGui_ImplSDL2_NewFrame(); 52 | ImGui::NewFrame(); 53 | 54 | 55 | //add here our GUI render 56 | { 57 | if (function)function(); 58 | //bool isOpen = true; 59 | //ImGui::ShowDemoWindow(&isOpen); 60 | 61 | //example of a window 62 | /* 63 | ImGui::Begin("Hello World!"); 64 | ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); 65 | ImGui::End(); 66 | */ 67 | } 68 | 69 | //rendering 70 | ImGui::Render(); 71 | ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData()); 72 | } 73 | 74 | void GUI::clean() 75 | { 76 | // Cleanup 77 | ImGui_ImplSDLRenderer_Shutdown(); 78 | ImGui_ImplSDL2_Shutdown(); 79 | ImGui::DestroyContext(); 80 | } 81 | 82 | //we will check some stuff so we can focus the keyboard without breaking anything else 83 | void GUI::set_focus() 84 | { 85 | if (!ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) 86 | ImGui::SetKeyboardFocusHere(0); 87 | } 88 | -------------------------------------------------------------------------------- /src/Renderer/AppGui.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../ImGui/imgui.h" 3 | #include "../ImGui/imgui_impl_sdl.h" 4 | #include "../ImGui/imgui_impl_sdlrenderer.h" 5 | #include 6 | #include 7 | #include 8 | 9 | namespace GUI { 10 | void setup(SDL_Window *window, SDL_Renderer *renderer); 11 | void event(SDL_Event event); 12 | void draw(std::function function); 13 | void clean(); 14 | 15 | //util functions 16 | void set_focus(); 17 | } -------------------------------------------------------------------------------- /src/Renderer/AssetsObject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "SDL.h" 6 | #include "SDL_image.h" 7 | 8 | struct AssetObject{ 9 | SDL_Texture* texture; 10 | std::string layer; 11 | int x, y; 12 | 13 | AssetObject(SDL_Texture* texture, std::string layer, int x, int y){ 14 | this->texture = texture; 15 | this->layer = layer; 16 | this->x = x; 17 | this->y = y; 18 | } 19 | }; -------------------------------------------------------------------------------- /src/Renderer/Atlas.cpp: -------------------------------------------------------------------------------- 1 | #include "Atlas.hpp" 2 | 3 | Atlas::Atlas(SDL_Renderer* renderer, float _scale) 4 | { 5 | std::cout << "Instantiated atlas!..." << std::endl; 6 | m_game_scale = _scale; 7 | m_renderer_ptr = renderer; 8 | } 9 | 10 | Atlas::~Atlas() 11 | { 12 | } 13 | 14 | //the simple draw function, its used to show a sprite in the screen 15 | void Atlas::draw(SDL_Texture* texture, vec2f scale, double size, double xpos, double ypos, bool flip) 16 | { 17 | 18 | SDL_Rect dst; 19 | dst.x = (xpos + (scale.x * size - scale.x * size) / 2); 20 | dst.y = (ypos + (scale.y * size - scale.y * size) / 2); 21 | dst.w = scale.x * size; 22 | dst.h = scale.y * size; 23 | 24 | /*SDL_Rect dst; 25 | dst.w = scale.x*size; 26 | dst.h = scale.y*size; 27 | dst.x = xpos + (dst.w * size - dst.w * size * dst.x) / 2; 28 | dst.y = ypos + (dst.h * size - dst.h * size * dst.y) / 2;*/ 29 | 30 | auto flip_state = flip ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; 31 | 32 | SDL_RenderCopyEx(m_renderer_ptr, texture, NULL, &dst, 0, 0, flip_state); 33 | } 34 | void Atlas::draw(Entity* p_entity, Camera* p_camera) { 35 | if (!p_entity->is_visible())return; 36 | 37 | SDL_Rect src; 38 | src.x = p_entity->get_current_frame().x; 39 | src.y = p_entity->get_current_frame().y; 40 | src.w = p_entity->get_current_frame().w * m_game_scale; 41 | src.h = p_entity->get_current_frame().h * m_game_scale; 42 | 43 | SDL_Rect dst; 44 | dst.x = (p_entity->get_pos().x + (p_entity->get_current_frame().w * m_game_scale - p_entity->get_current_frame().w * m_game_scale * p_entity->get_scale().x) / 2) - p_camera->get_pos().x; 45 | dst.y = (p_entity->get_pos().y + (p_entity->get_current_frame().h * m_game_scale - p_entity->get_current_frame().h * m_game_scale * p_entity->get_scale().y) / 2) - p_camera->get_pos().y; 46 | dst.w = p_entity->get_current_frame().w * p_entity->get_scale().x * m_game_scale; 47 | dst.h = p_entity->get_current_frame().h * p_entity->get_scale().y * m_game_scale; 48 | 49 | //std::cout << "checks src" << "x " << src.x << " y " << src.y << " w " << src.w << " h " << src.h << std::endl; 50 | //std::cout << "checks" << "x " << dst.x << " y " << dst.y << " w " << dst.w << " h " << dst.h << std::endl; 51 | 52 | //std::cout << "just testing? " << p_entity->getTexture() << "renderer" << rendererptr << "size : " << dst.h << std::endl; 53 | 54 | SDL_RenderCopyEx(m_renderer_ptr, p_entity->get_texture(), &src, &dst, p_entity->get_angle(), 0, SDL_FLIP_NONE); 55 | } 56 | void Atlas::draw(std::unique_ptr p_entity, Camera* p_camera) { 57 | if (!p_entity->is_visible())return; 58 | 59 | SDL_Rect src; 60 | src.x = p_entity->get_current_frame().x; 61 | src.y = p_entity->get_current_frame().y; 62 | src.w = p_entity->get_current_frame().w * m_game_scale; 63 | src.h = p_entity->get_current_frame().h * m_game_scale; 64 | 65 | SDL_Rect dst; 66 | dst.x = (p_entity->get_pos().x + (p_entity->get_current_frame().w * m_game_scale - p_entity->get_current_frame().w * m_game_scale * p_entity->get_scale().x) / 2) - p_camera->get_pos().x; 67 | dst.y = (p_entity->get_pos().y + (p_entity->get_current_frame().h * m_game_scale - p_entity->get_current_frame().h * m_game_scale * p_entity->get_scale().y) / 2) - p_camera->get_pos().y; 68 | dst.w = p_entity->get_current_frame().w * p_entity->get_scale().x * m_game_scale; 69 | dst.h = p_entity->get_current_frame().h * p_entity->get_scale().y * m_game_scale; 70 | 71 | //std::cout << "checks src" << "x " << src.x << " y " << src.y << " w " << src.w << " h " << src.h << std::endl; 72 | //std::cout << "checks" << "x " << dst.x << " y " << dst.y << " w " << dst.w << " h " << dst.h << std::endl; 73 | 74 | //std::cout << "just testing? " << p_entity->getTexture() << "renderer" << rendererptr << "size : " << dst.h << std::endl; 75 | 76 | SDL_RenderCopyEx(m_renderer_ptr, p_entity->get_texture(), &src, &dst, p_entity->get_angle(), 0, SDL_FLIP_NONE); 77 | } 78 | 79 | void Atlas::draw(float p_x, float p_y, const char* p_text, TTF_Font* font, SDL_Color textColor) 80 | { 81 | SDL_Surface* surfaceMessage = TTF_RenderText_Blended(font, p_text, textColor); 82 | SDL_Texture* message = SDL_CreateTextureFromSurface(m_renderer_ptr, surfaceMessage); 83 | 84 | SDL_Rect src; 85 | src.x = 0; 86 | src.y = 0; 87 | src.w = surfaceMessage->w; 88 | src.h = surfaceMessage->h; 89 | 90 | SDL_Rect dst; 91 | dst.x = p_x; 92 | dst.y = p_y; 93 | dst.w = src.w; 94 | dst.h = src.h; 95 | 96 | SDL_FreeSurface(surfaceMessage); 97 | SDL_RenderCopyEx(m_renderer_ptr, message, &src, &dst, 0, 0, SDL_FLIP_NONE); 98 | SDL_DestroyTexture(message); 99 | } 100 | 101 | void Atlas::draw_from_sheet(Entity *entity, Camera *camera) 102 | { 103 | Sprite curr_sprite = entity->get_current_sprite(); 104 | 105 | int scaled_x = curr_sprite.sprite_scale.x * (m_game_scale+curr_sprite.sprite_scale_multiplier); 106 | int scaled_y = curr_sprite.sprite_scale.y * (m_game_scale+curr_sprite.sprite_scale_multiplier); 107 | 108 | std::cout << m_game_scale << " " << curr_sprite.sprite_scale_multiplier << "\n"; 109 | 110 | std::cout << scaled_x << " " << scaled_y << "\n"; 111 | 112 | SDL_Rect src = {curr_sprite.sprite_pos.x, curr_sprite.sprite_pos.y, curr_sprite.sprite_scale.x, curr_sprite.sprite_scale.y}; 113 | 114 | SDL_Rect dst = {entity->get_pos().x - camera->get_pos().x, entity->get_pos().y - camera->get_pos().y, scaled_x, scaled_y}; 115 | 116 | SDL_RenderCopyEx(m_renderer_ptr, entity->get_current_sprite().texture, &src, &dst, entity->get_angle(), 0, SDL_FLIP_NONE); 117 | } 118 | 119 | SDL_Renderer *Atlas::get_renderer() 120 | { 121 | return m_renderer_ptr; 122 | } 123 | 124 | void Atlas::draw_pixel(float p_x, float p_y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) 125 | { 126 | SDL_SetRenderDrawColor(m_renderer_ptr, r, g, b, a); 127 | SDL_SetRenderDrawBlendMode(m_renderer_ptr, SDL_BLENDMODE_ADD); 128 | SDL_RenderDrawPoint(m_renderer_ptr, p_x, p_y); 129 | SDL_RenderDrawPoint(m_renderer_ptr, p_x+1, p_y); 130 | SDL_RenderDrawPoint(m_renderer_ptr, p_x+1, p_y+1); 131 | SDL_RenderDrawPoint(m_renderer_ptr, p_x, p_y+1); 132 | } 133 | -------------------------------------------------------------------------------- /src/Renderer/Atlas.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SDL.h" 3 | #include "SDL_image.h" 4 | #include "SDL_ttf.h" 5 | #include "../Entity/Entity.hpp" 6 | #include "../Renderer/Camera.hpp" 7 | #include 8 | #include 9 | 10 | class Atlas { 11 | public: 12 | Atlas(SDL_Renderer *renderer, float _scale); 13 | ~Atlas(); 14 | 15 | void draw(SDL_Texture* texture, vec2f scale, double size, double xpos, double ypos, bool flip = false); 16 | void draw(Entity* entity, Camera* camera); 17 | void draw(std::unique_ptr entity, Camera* camera); 18 | void draw(float p_x, float p_y, const char* p_text, TTF_Font* font, SDL_Color textColor); 19 | void draw_from_sheet(Entity* entity, Camera* camera); 20 | 21 | //getters 22 | SDL_Renderer* get_renderer(); 23 | 24 | //void draw_pixel(Uint16 p_x, Uint16 p_y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 25 | void draw_pixel(float p_x, float p_y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 26 | private: 27 | SDL_Renderer* m_renderer_ptr; 28 | float m_game_scale = 1; 29 | }; -------------------------------------------------------------------------------- /src/Renderer/Camera.cpp: -------------------------------------------------------------------------------- 1 | #include "Camera.hpp" 2 | 3 | Camera::Camera(Entity* _target, vec2f _screen_size) 4 | { 5 | m_target = _target; 6 | 7 | m_camera_size = _screen_size; 8 | 9 | //m_current_pos = m_target->get_pos(); 10 | m_current_pos.x = 0; 11 | m_current_pos.y = 0; 12 | } 13 | 14 | void Camera::move(double deltaTime) 15 | { 16 | if (m_target == nullptr)return; 17 | 18 | //if (!target->isMoving())return; 19 | 20 | m_ref_pos = m_target->get_pos(); 21 | m_ref_pos.x -= m_camera_size.x / 2; 22 | m_ref_pos.y -= m_camera_size.y / 2; 23 | 24 | float x = m_ref_pos.x - m_current_pos.x; 25 | float y = m_ref_pos.y - m_current_pos.y; 26 | 27 | //std::cout << "Quick test: " << refPos.x << " " << refPos.y << "Camera : " << x << " " << y << std::endl; 28 | 29 | //currentPos.x = refPos.x - (cameraSize.x / 2); 30 | //currentPos.y = refPos.y - (cameraSize.y / 2); 31 | 32 | m_current_pos.x = (1 - m_smooth_speed) * m_current_pos.x + m_smooth_speed * m_ref_pos.x; 33 | m_current_pos.y = (1 - m_smooth_speed) * m_current_pos.y + m_smooth_speed * m_ref_pos.y; 34 | 35 | /* 36 | currentPos.x += (x + smoothSpeed)-cameraSize.x/2; 37 | currentPos.y += (y + smoothSpeed)-cameraSize.y/2;*/ 38 | 39 | //std::cout << "Current position of the camera : " << currentPos.x << "" << currentPos.y << std::endl; 40 | } 41 | 42 | void Camera::update_camera_size(vec2f size) 43 | { 44 | m_camera_size = size; 45 | } 46 | 47 | vec2f Camera::get_pos() 48 | { 49 | return m_current_pos; 50 | } 51 | -------------------------------------------------------------------------------- /src/Renderer/Camera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../Utils/Common.hpp" 4 | #include "../Entity/Entity.hpp" 5 | 6 | class Camera { 7 | public: 8 | Camera(Entity* _target, vec2f _screen_size); 9 | 10 | void move(double deltaTime); 11 | void update_camera_size(vec2f size); 12 | void set_entity(Entity* _target) { m_target = _target; } 13 | vec2f get_pos(); 14 | private: 15 | vec2f m_camera_size = vec2f(1024, 768); 16 | vec2f m_offset = vec2f(0,0); 17 | float m_smooth_speed = .01f; 18 | 19 | //positions 20 | vec2f m_current_pos; 21 | vec2f m_ref_pos; 22 | 23 | Entity* m_target = nullptr; 24 | }; -------------------------------------------------------------------------------- /src/Renderer/EntityRenderer.cpp: -------------------------------------------------------------------------------- 1 | #include "EntityRenderer.hpp" 2 | 3 | EntityRenderer::EntityRenderer(SDL_Renderer *renderer, float _scale) 4 | { 5 | m_game_scale = _scale; 6 | m_renderer_ptr = renderer; 7 | } 8 | 9 | EntityRenderer::~EntityRenderer() 10 | { 11 | } 12 | 13 | void EntityRenderer::draw_pixel(float p_x, float p_y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) 14 | { 15 | SDL_SetRenderDrawColor(m_renderer_ptr, r, g, b, a); 16 | SDL_SetRenderDrawBlendMode(m_renderer_ptr, SDL_BLENDMODE_ADD); 17 | SDL_RenderDrawPoint(m_renderer_ptr, p_x, p_y); 18 | SDL_RenderDrawPoint(m_renderer_ptr, p_x+1, p_y); 19 | SDL_RenderDrawPoint(m_renderer_ptr, p_x+1, p_y+1); 20 | SDL_RenderDrawPoint(m_renderer_ptr, p_x, p_y+1); 21 | } 22 | -------------------------------------------------------------------------------- /src/Renderer/EntityRenderer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _Entity_Renderer_hpp 2 | #define _Entity_Renderer_hpp 3 | #include "SDL.h" 4 | #include "SDL_image.h" 5 | #include "SDL_ttf.h" 6 | #include 7 | #include 8 | 9 | class EntityRenderer { 10 | public: 11 | EntityRenderer(SDL_Renderer *renderer, float _scale); 12 | ~EntityRenderer(); 13 | 14 | //void draw_font(float p_x, float p_y, const char* p_text, TTF_Font* font, SDL_Color textColor); 15 | 16 | //void draw_pixel(Uint16 p_x, Uint16 p_y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 17 | void draw_pixel(float p_x, float p_y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 18 | private: 19 | SDL_Renderer* m_renderer_ptr; 20 | float m_game_scale = 1; 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /src/Renderer/ParticleSystem.cpp: -------------------------------------------------------------------------------- 1 | #include "ParticleSystem.hpp" 2 | 3 | ParticleSystem::ParticleSystem(Atlas *atlas, int max_particles) 4 | { 5 | m_atlas_ptr = atlas; 6 | m_max_particles = max_particles; 7 | m_current_particles = 0; 8 | } 9 | 10 | ParticleSystem::~ParticleSystem() 11 | { 12 | } 13 | 14 | void ParticleSystem::update(double delta_time) 15 | { 16 | //delete the particle memory if it's not alive 17 | if(is_deleting_particle){ 18 | for (auto it = m_particles_vector.begin(); it != m_particles_vector.end();) 19 | { 20 | if(!it->alive){ 21 | it = m_particles_vector.erase(it); 22 | } 23 | else{ 24 | ++it; 25 | } 26 | } 27 | is_deleting_particle = false; 28 | } 29 | 30 | for (auto &particle : m_particles_vector) 31 | { 32 | if(!particle.alive)continue; 33 | 34 | particle.position.x += particle.speed.x * delta_time; 35 | particle.position.y += particle.speed.y * delta_time; 36 | particle.life_time -= delta_time; 37 | particle.color.a -= particle.opacity_decrease * delta_time; 38 | 39 | if(particle.life_time <= 0){ 40 | particle.alive = false; 41 | is_deleting_particle = true; 42 | //delete &particle; 43 | } 44 | } 45 | } 46 | 47 | void ParticleSystem::draw() 48 | { 49 | for (auto &particle : m_particles_vector) 50 | { 51 | if(!particle.alive)continue; 52 | 53 | m_atlas_ptr->draw_pixel(particle.position.x, particle.position.y, particle.color.r, particle.color.g, particle.color.b, particle.color.a); 54 | } 55 | } 56 | 57 | void ParticleSystem::add_particle(Particle particle) 58 | { 59 | if(m_particles_vector.size() >= m_max_particles)return; 60 | 61 | Particle test; 62 | Uint8 current_quadrant = 0; 63 | if(particle.type == PARTICLE_SQUARE){ 64 | current_quadrant = particle.particles_amount / 4; 65 | } 66 | 67 | for(int i = 0 ; i < particle.particles_amount; i++){ 68 | Particle p = particle; 69 | if(particle.type == PARTICLE_SQUARE){ 70 | p.position.x = particle.position.x + (rand() % 20 + (-10)); 71 | p.position.y = particle.position.y + (rand() % 20); 72 | 73 | //vec2f cur_speed = p.speed; 74 | 75 | 76 | //p.speed = {cur_speed.x + rand() % 100 + (-100), cur_speed.y + rand() % 100 + (-100)}; 77 | } 78 | else if(particle.type == PARTICLE_CIRCLE){ 79 | float angle = (rand() % 360) * 3.14159 / 180; 80 | p.position.x = particle.position.x + cos(angle) * (rand() % 100); 81 | p.position.y = particle.position.y + sin(angle) * (rand() % 100); 82 | } 83 | 84 | float curr_life = p.life_time; 85 | 86 | p.opacity_decrease = rand() % 14 + 1; 87 | 88 | p.life_time = rand() % 6 + (curr_life); 89 | 90 | m_particles_vector.push_back(p); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Renderer/ParticleSystem.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _PARTICLE_SYSTEM_HPP_ 2 | #define _PARTICLE_SYSTEM_HPP_ 3 | 4 | #pragma once 5 | 6 | #include "../Renderer/Atlas.hpp" 7 | #include "../Utils/Math.hpp" 8 | #include 9 | #include 10 | 11 | #include "SDL.h" 12 | 13 | enum ParticleType{ 14 | PARTICLE_SQUARE, 15 | PARTICLE_CIRCLE 16 | }; 17 | 18 | struct Particle{ 19 | ParticleType type; 20 | 21 | Uint32 particles_amount; 22 | 23 | vec2f position; 24 | vec2f speed; 25 | float life_time; 26 | float opacity_decrease; 27 | SDL_Color color; 28 | 29 | bool alive; 30 | }; 31 | 32 | 33 | //System that will be used to create and manage particles 34 | //right now it will work with creating a class for each kind of particles/ 35 | //TODO: make it ecs based 36 | class ParticleSystem{ 37 | public: 38 | ParticleSystem(Atlas* atlas, int max_particles); 39 | ~ParticleSystem(); 40 | 41 | void update(double delta_time); 42 | void draw(); 43 | 44 | void add_particle(Particle particle); 45 | 46 | private: 47 | Atlas* m_atlas_ptr; 48 | 49 | int m_max_particles; 50 | int m_current_particles; 51 | 52 | bool is_deleting_particle = false; 53 | 54 | std::vector m_particles_vector; 55 | }; 56 | 57 | #endif -------------------------------------------------------------------------------- /src/Resources/AssetData.cpp: -------------------------------------------------------------------------------- 1 | #include "AssetData.hpp" 2 | 3 | AssetData::AssetData(std::string name, std::string folder, SDL_Texture *texture) 4 | { 5 | mName = name; 6 | mFolder = folder; 7 | mTexture = texture; 8 | } 9 | 10 | AssetData::~AssetData() 11 | { 12 | 13 | } 14 | 15 | std::string AssetData::GetName() 16 | { 17 | return mName; 18 | } 19 | 20 | std::string AssetData::GetFolder() 21 | { 22 | return mFolder; 23 | } 24 | 25 | SDL_Texture *AssetData::GetTexture() 26 | { 27 | return mTexture; 28 | } 29 | -------------------------------------------------------------------------------- /src/Resources/AssetData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SDL.h" 4 | #include "SDL_image.h" 5 | #include 6 | #include 7 | 8 | //the class that will be used to store the data of the assets 9 | //it will consist with the folder so we can reference it with the selected folder 10 | 11 | class AssetData{ 12 | public: 13 | AssetData(std::string name, std::string folder, SDL_Texture* texture); 14 | ~AssetData(); 15 | 16 | std::string GetName(); 17 | std::string GetFolder(); 18 | SDL_Texture* GetTexture(); 19 | 20 | private: 21 | std::string mName; 22 | std::string mFolder; 23 | SDL_Texture* mTexture; 24 | }; -------------------------------------------------------------------------------- /src/Resources/Resources.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Tools/Reader.hpp" 4 | #include "AssetData.hpp" 5 | 6 | #include "SDL.h" 7 | #include "SDL_image.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | class Resources { 15 | public: 16 | Resources(SDL_Renderer* renderer); 17 | 18 | void LoadFolder(std::string path); 19 | void LoadAssets(); 20 | SDL_Texture* SaveTexture(const char* file); 21 | SDL_Texture* GetTexture(const char* file, bool debug); 22 | SDL_Texture* HandleMap(const char* file); 23 | 24 | //asset data creation 25 | void CreateAssetData(const char* file, const char* name, const char* folder); 26 | std::vector GetAssets(std::string folder); 27 | AssetData* GetAsset(std::string name); 28 | 29 | //getters 30 | std::vector GetFolders(); 31 | 32 | std::map GetTextures(); 33 | std::vector GetTexturesName(); 34 | 35 | private: 36 | std::map mTextures; 37 | std::map mAssets; 38 | SDL_Renderer* mRenderer; 39 | 40 | std::vector mFolders; 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /src/Scenes/GameScene.cpp: -------------------------------------------------------------------------------- 1 | #include "GameScene.hpp" 2 | 3 | 4 | GameScene::GameScene(App *app, Logger *logger, Cooldown *cooldown, Camera *camera):Scene(app, logger, cooldown, camera) 5 | { 6 | 7 | } 8 | 9 | void GameScene::load_assets() 10 | { 11 | 12 | } 13 | 14 | void GameScene::init() 15 | { 16 | m_cd->set_state("init_event", .1f, [&] { m_logger->log("Starting the GameScene!");}); 17 | 18 | // 19 | load_assets(); 20 | } 21 | 22 | void GameScene::update(double deltaTime) 23 | { 24 | 25 | } 26 | 27 | void GameScene::ui() 28 | { 29 | 30 | } 31 | 32 | void GameScene::draw() 33 | { 34 | //ui 35 | GUI::draw([this](){this->ui();}); 36 | } 37 | 38 | void GameScene::input(SDL_Event event) 39 | { 40 | 41 | } 42 | 43 | void GameScene::clean() 44 | { 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/Scenes/GameScene.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _GAMESCENE_HPP 2 | #define _GAMESCENE_HPP 3 | #include "Scene.hpp" 4 | 5 | #include 6 | 7 | class GameScene : public Scene { 8 | public: 9 | GameScene(App* app, Logger* logger, Cooldown* cooldown, Camera* camera); 10 | 11 | void init(); 12 | void update(double deltaTime); 13 | void ui(); 14 | void draw(); 15 | void input(SDL_Event event); 16 | void clean(); 17 | void load_assets(); 18 | 19 | 20 | private: 21 | 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/Scenes/IntroScene.cpp: -------------------------------------------------------------------------------- 1 | #include "IntroScene.hpp" 2 | #include "MainScene.hpp" 3 | 4 | Entity* m_logo = nullptr; 5 | float m_y_pos = -200; 6 | vec2f m_window_size = vec2f(0, 0); 7 | 8 | IntroScene::IntroScene(App* app, Logger* logger, Cooldown* cooldown, Camera* camera):Scene(app, logger, cooldown, camera) 9 | { 10 | } 11 | 12 | //function that will load all the logo animation assets needed for the scene 13 | SDL_Texture* logo_frames[13] = { nullptr }; 14 | 15 | void IntroScene::load_assets() 16 | { 17 | logo_frames[1] = m_app->get_resources()->GetAsset("logo1")->GetTexture(); 18 | logo_frames[0] = m_app->get_resources()->GetAsset("logo1")->GetTexture(); 19 | logo_frames[2] = m_app->get_resources()->GetAsset("logo2")->GetTexture(); 20 | logo_frames[3] = m_app->get_resources()->GetAsset("logo3")->GetTexture(); 21 | logo_frames[4] = m_app->get_resources()->GetAsset("logo4")->GetTexture(); 22 | logo_frames[5] = m_app->get_resources()->GetAsset("logo5")->GetTexture(); 23 | logo_frames[6] = m_app->get_resources()->GetAsset("logo6")->GetTexture(); 24 | logo_frames[7] = m_app->get_resources()->GetAsset("logo7")->GetTexture(); 25 | logo_frames[8] = m_app->get_resources()->GetAsset("logo8")->GetTexture(); 26 | logo_frames[9] = m_app->get_resources()->GetAsset("logo9")->GetTexture(); 27 | logo_frames[10] = m_app->get_resources()->GetAsset("logo10")->GetTexture(); 28 | logo_frames[11] = m_app->get_resources()->GetAsset("logo11")->GetTexture(); 29 | logo_frames[12] = m_app->get_resources()->GetAsset("logo12")->GetTexture(); 30 | } 31 | 32 | void IntroScene::init() 33 | { 34 | m_cd->set_state("init_event", .4f, [&] { m_logger->log("Starting the IntroScene!");}); 35 | m_app->change_background_color(vec3f(0, 0, 0)); 36 | 37 | m_y_pos = -200; 38 | std::cout << m_y_pos << std::endl; 39 | 40 | m_window_size = m_app->get_window_size(); 41 | 42 | m_logo = new Entity(vec2f((-156 + m_window_size.x) / 2, (-116/2 + m_window_size.y)/2), vec2f(156, 116), m_app->get_resources()->GetAsset("logo1")->GetTexture(), 0); 43 | m_logo->change_visibility(false); 44 | load_assets(); 45 | 46 | std::cout << "Why" << std::endl; 47 | 48 | m_logo->set_texture(logo_frames[1]); 49 | 50 | m_cd->set_state("start_event", 1.5f, [&] { 51 | m_logo->change_visibility(true); 52 | }); 53 | } 54 | 55 | //variables for the logo animation 56 | int frame = 1; 57 | float mTime = 0; 58 | 59 | void IntroScene::update(double deltaTime) 60 | { 61 | if (!m_logo->is_visible())return; 62 | 63 | //loop between all the frames from the animation using the time variable 64 | { 65 | if (frame < 18) { 66 | mTime += deltaTime; 67 | if (mTime >= .08f) { 68 | mTime = 0; 69 | frame++; 70 | if(frame < 13) 71 | m_logo->set_texture(logo_frames[frame]); 72 | } 73 | }else{ 74 | m_app->change_to_next_scene(); 75 | } 76 | } 77 | 78 | if (Mouse::is_at_area(Area(m_logo->get_pos().x, m_logo->get_pos().y, m_logo->get_current_frame().w, m_logo->get_current_frame().h))) { 79 | m_logger->log("Mouse on logo!"); 80 | } 81 | } 82 | 83 | void Gui() { 84 | 85 | } 86 | 87 | void IntroScene::draw() 88 | { 89 | m_app->get_atlas()->draw(m_logo, m_camera); 90 | 91 | GUI::draw(Gui); 92 | } 93 | 94 | void IntroScene::input(SDL_Event event) 95 | { 96 | } 97 | 98 | void IntroScene::clean() 99 | { 100 | m_y_pos = -200; 101 | delete m_logo; 102 | } 103 | -------------------------------------------------------------------------------- /src/Scenes/IntroScene.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Scene.hpp" 3 | 4 | class IntroScene : public Scene { 5 | public: 6 | IntroScene(App* app, Logger* logger, Cooldown* cooldown, Camera* camera); 7 | 8 | void init(); 9 | void update(double deltaTime); 10 | void draw(); 11 | void input(SDL_Event event); 12 | void clean(); 13 | void load_assets(); 14 | }; -------------------------------------------------------------------------------- /src/Scenes/MainScene.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _MAINSCENE_HPP 2 | #define _MAINSCENE_HPP 3 | #include "Scene.hpp" 4 | 5 | #include "../Core/DataLoader.hpp" 6 | #include "../Entity/FileEntity.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | enum MOUSE_KEY_STATE{ 14 | LEFT_CLICK, 15 | RIGHT_CLICK, 16 | NO_KEY 17 | }; 18 | 19 | class MainScene : public Scene { 20 | public: 21 | MainScene(App* app, Logger* logger, Cooldown* cooldown, Camera* camera); 22 | 23 | void init(); 24 | void update(double deltaTime); 25 | void draw(); 26 | void input(SDL_Event event); 27 | void clean(); 28 | void load_assets(); 29 | 30 | void ui(); 31 | 32 | private: 33 | std::vector m_files; 34 | 35 | MOUSE_KEY_STATE m_current_mouse_key = NO_KEY; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/Scenes/PartialScene.cpp: -------------------------------------------------------------------------------- 1 | #include "PartialScene.hpp" 2 | 3 | PartialScene::PartialScene(App *app, Logger *logger, Cooldown *cooldown, Camera *camera) 4 | { 5 | m_app = app; 6 | m_logger = logger; 7 | m_cd = cooldown; 8 | m_camera = camera; 9 | 10 | m_resources = app->get_resources(); 11 | m_ini_handler = app->get_ini_handler(); 12 | m_atlas = app->get_atlas(); 13 | } 14 | 15 | void PartialScene::init() 16 | { 17 | m_cd->set_state("partial_init_event", .2f, [&] { m_logger->log("Starting the PartialScene!");}); 18 | } 19 | 20 | void PartialScene::input(SDL_Event event) 21 | { 22 | } 23 | 24 | void PartialScene::update(double deltaTime) 25 | { 26 | } 27 | 28 | void PartialScene::draw() 29 | { 30 | } 31 | 32 | void PartialScene::clean() 33 | { 34 | } 35 | -------------------------------------------------------------------------------- /src/Scenes/PartialScene.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Core/App.hpp" 4 | #include "../Core/Assert.h" 5 | #include "../Core/IniHandler.hpp" 6 | #include "../Renderer/AppGui.hpp" 7 | #include "../Renderer/Atlas.hpp" 8 | #include "../Renderer/Camera.hpp" 9 | #include "../Renderer/AssetsObject.hpp" 10 | #include "../Resources/Resources.hpp" 11 | #include "../Entity/Entity.hpp" 12 | #include "../Tools/Cooldown.hpp" 13 | #include "../Tools/Logger.hpp" 14 | #include "../Utils/Mouse.hpp" 15 | 16 | #include "SDL.h" 17 | #include "SDL_image.h" 18 | #include "SDL_ttf.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | //the scene class, we'll use this to create the behaviours of our app. 30 | class PartialScene { 31 | public: 32 | PartialScene(App* app, Logger* logger, Cooldown* cooldown, Camera* camera); 33 | 34 | virtual void init(); 35 | virtual void input(SDL_Event event); 36 | virtual void update(double deltaTime); 37 | virtual void draw(); 38 | virtual void clean(); 39 | 40 | protected: 41 | App* m_app = nullptr; 42 | 43 | //tools 44 | Logger* m_logger = nullptr; 45 | Cooldown* m_cd = nullptr; 46 | Camera* m_camera = nullptr; 47 | Resources* m_resources = nullptr; 48 | IniHandler* m_ini_handler = nullptr; 49 | Atlas* m_atlas = nullptr; 50 | }; -------------------------------------------------------------------------------- /src/Scenes/Scene.cpp: -------------------------------------------------------------------------------- 1 | #include "Scene.hpp" 2 | 3 | Scene::Scene(App* app, Logger* logger, Cooldown* cooldown, Camera* camera) 4 | { 5 | m_app = app; 6 | m_logger = logger; 7 | m_cd = cooldown; 8 | m_camera = camera; 9 | 10 | m_resources = app->get_resources(); 11 | m_ini_handler = app->get_ini_handler(); 12 | m_atlas = app->get_atlas(); 13 | } 14 | 15 | void Scene::init() 16 | { 17 | } 18 | 19 | void Scene::input(SDL_Event event) 20 | { 21 | } 22 | 23 | void Scene::update(double deltaTime) 24 | { 25 | } 26 | 27 | void Scene::draw() 28 | { 29 | } 30 | 31 | void Scene::clean() 32 | { 33 | } 34 | -------------------------------------------------------------------------------- /src/Scenes/Scene.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Core/App.hpp" 4 | #include "../Core/Assert.h" 5 | #include "../Core/IniHandler.hpp" 6 | #include "../Renderer/AppGui.hpp" 7 | #include "../Renderer/Atlas.hpp" 8 | #include "../Renderer/Camera.hpp" 9 | #include "../Renderer/AssetsObject.hpp" 10 | #include "../Resources/Resources.hpp" 11 | #include "../Entity/Entity.hpp" 12 | #include "../Tools/Cooldown.hpp" 13 | #include "../Tools/Logger.hpp" 14 | #include "../Utils/Mouse.hpp" 15 | #include "PartialScene.hpp" 16 | 17 | #include "SDL.h" 18 | #include "SDL_image.h" 19 | #include "SDL_ttf.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | //the scene class, we'll use this to create the behaviours of our app. 32 | class Scene { 33 | public: 34 | Scene(App* app, Logger* logger, Cooldown* cooldown, Camera* camera); 35 | 36 | virtual void init(); 37 | virtual void input(SDL_Event event); 38 | virtual void update(double deltaTime); 39 | virtual void draw(); 40 | virtual void clean(); 41 | 42 | protected: 43 | App* m_app = nullptr; 44 | 45 | //tools 46 | Logger* m_logger = nullptr; 47 | Cooldown* m_cd = nullptr; 48 | Camera* m_camera = nullptr; 49 | Resources* m_resources = nullptr; 50 | IniHandler* m_ini_handler = nullptr; 51 | Atlas* m_atlas = nullptr; 52 | 53 | std::vector> m_partial_scenes; 54 | }; -------------------------------------------------------------------------------- /src/Scenes/Scenes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Scene.hpp" 4 | #include "MainScene.hpp" 5 | #include "IntroScene.hpp" -------------------------------------------------------------------------------- /src/Scenes/TestPartialScene.cpp: -------------------------------------------------------------------------------- 1 | #include "TestPartialScene.hpp" 2 | 3 | TestPartialScene::TestPartialScene(App *app, Logger *logger, Cooldown *cooldown, Camera *camera) : PartialScene(app, logger, cooldown, camera) 4 | { 5 | } 6 | 7 | void TestPartialScene::init() 8 | { 9 | m_cd->set_state("test_partial_init_event", .3f, [&] { 10 | m_logger->log("Starting the TestPartialScene!"); 11 | std::cout << m_test_string->c_str() << std::endl; 12 | }); 13 | } 14 | 15 | void TestPartialScene::input(SDL_Event event) 16 | { 17 | } 18 | 19 | void TestPartialScene::update(double deltaTime) 20 | { 21 | 22 | } 23 | 24 | void TestPartialScene::draw() 25 | { 26 | if(m_test_string == nullptr) return; 27 | 28 | m_atlas->draw(300, 300, m_test_string->c_str(), m_app->get_main_font(), {255,255,255,125}); 29 | } 30 | 31 | void TestPartialScene::clean() 32 | { 33 | } 34 | 35 | void TestPartialScene::add_string(std::string *str) 36 | { 37 | m_test_string = str; 38 | } 39 | -------------------------------------------------------------------------------- /src/Scenes/TestPartialScene.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PartialScene.hpp" 4 | 5 | class TestPartialScene : public PartialScene 6 | { 7 | public: 8 | TestPartialScene(App *app, Logger *logger, Cooldown *cooldown, Camera *camera); 9 | 10 | void init() override; 11 | void input(SDL_Event event) override; 12 | void update(double deltaTime) override; 13 | void draw() override; 14 | void clean() override; 15 | 16 | void add_string(std::string* str); 17 | 18 | private: 19 | // Add your variables here 20 | 21 | std::string* m_test_string; 22 | }; -------------------------------------------------------------------------------- /src/Tools/Cooldown.cpp: -------------------------------------------------------------------------------- 1 | #include "Cooldown.hpp" 2 | 3 | Cooldown::Cooldown() 4 | { 5 | 6 | } 7 | 8 | void Cooldown::update(double deltaTime) 9 | { 10 | if (m_events.size() == 0)return; 11 | 12 | //no memory leak approach 13 | for (auto it = m_events.begin(); it != m_events.end();) { 14 | Event* ev = *it; 15 | 16 | ev->update(deltaTime); 17 | 18 | if (ev->finished) { 19 | if (ev) { 20 | std::cout << "Removing event of the list : " << ev->name << std::endl; 21 | delete ev; 22 | ev = nullptr; 23 | } 24 | it = m_events.erase(it); 25 | } 26 | else { 27 | ++it; 28 | } 29 | } 30 | } 31 | 32 | void Cooldown::set_state(std::string _name, float _timer, std::function _event, bool _repeat) 33 | { 34 | for (auto const& e : m_events) { 35 | if (e->name == _name) { 36 | //std::cout << "trying to add an defined event already! skipping this iteration.." << e->name << std::endl; 37 | return; 38 | } 39 | } 40 | m_events.push_back(new Event(_name, _timer, _event, _repeat)); 41 | } 42 | -------------------------------------------------------------------------------- /src/Tools/Cooldown.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "SDL.h" 8 | 9 | /// 10 | /// Class to work with routines in the main thread 11 | /// 12 | 13 | struct Event{ 14 | std::string name; float timer; std::function event; bool repeat; 15 | 16 | float current_timer = 0; bool finished = false; 17 | 18 | Event() 19 | :name("event"), timer(1), event(NULL), repeat(false) 20 | {} 21 | Event(std::string _name, float _timer, std::function _event, bool _repeat) 22 | :name(_name), timer(_timer), event(_event), repeat(_repeat) 23 | {} 24 | 25 | void start() { 26 | std::cout << "created the event : " << name << "with the parameters : " << timer << repeat << std::endl; 27 | } 28 | 29 | int update(double deltaTime) { 30 | if (!finished) { 31 | current_timer += 1 * deltaTime; 32 | 33 | //std::cout << "updating the event : " << name << " with the timer : " << currentTimer << std::endl; 34 | 35 | if (current_timer >= timer) { 36 | std::cout << "finished the event of : " << name << std::endl; 37 | event(); 38 | if (!repeat) { 39 | std::cout << "finishing the event : " << name << std::endl; 40 | finished = true; 41 | } 42 | current_timer = 0; 43 | } 44 | return 1; 45 | } 46 | return 0; 47 | } 48 | }; 49 | 50 | class Cooldown { 51 | public: 52 | Cooldown(); 53 | 54 | void update(double deltaTime); 55 | 56 | //set 57 | void set_state(std::string _name, float _timer, std::function _event, bool _repeat = false); 58 | 59 | private: 60 | //set variables 61 | std::list m_events; 62 | 63 | //local variables 64 | float m_current_timer = 0; 65 | }; -------------------------------------------------------------------------------- /src/Tools/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include "Logger.hpp" 2 | 3 | Logger::Logger(SDL_Texture* logger, float logSpeed, bool enabled ) 4 | { 5 | m_logger = logger; 6 | m_log_speed = logSpeed; 7 | m_enabled = enabled; 8 | } 9 | 10 | void Logger::init(Atlas* atlas, TTF_Font* font, vec2f scale) 11 | { 12 | if (atlas == nullptr || font == nullptr) { 13 | std::cout << "Couldnt initialize the logger! " << std::endl; 14 | m_enabled = false; 15 | } 16 | m_atlas = atlas; 17 | m_scale = scale; 18 | m_font = font; 19 | } 20 | 21 | void Logger::log(std::string text) 22 | { 23 | auto data = std::make_unique(text); 24 | 25 | m_logs.push_back(std::move(data)); 26 | } 27 | 28 | void Logger::update(float deltaTime) 29 | { 30 | if (m_logs.size() == 0 || !m_enabled)return; 31 | 32 | auto it = m_logs.begin(); 33 | while (it != m_logs.end()) { 34 | if (!it->get()) { 35 | ++it; 36 | continue; 37 | } 38 | it->get()->y = Math::lerp(it->get()->y, 60, m_log_speed * deltaTime); 39 | if (it->get()->y >= 59.8f) { 40 | it = m_logs.erase(it); 41 | } 42 | else { 43 | ++it; 44 | } 45 | } 46 | } 47 | 48 | void Logger::draw() 49 | { 50 | if (m_logs.size() == 0 || !m_enabled)return; 51 | 52 | for (auto& log : m_logs) { 53 | if (!log.get())continue; 54 | 55 | m_atlas->draw(m_logger, m_scale, 3, 25, log.get()->y); 56 | m_atlas->draw(58, log.get()->y + 14, log.get()->text.c_str(), m_font, { 255, 255, 255 }); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Tools/Logger.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "SDL.h" 9 | #include "SDL_ttf.h" 10 | #include "../Entity/Entity.hpp" 11 | #include "../Renderer/Atlas.hpp" 12 | #include "../Resources/Resources.hpp" 13 | #include "../Utils/Math.hpp" 14 | 15 | struct LogData{ 16 | public: 17 | float y;std::string text; 18 | 19 | LogData(std::string text):y(0), text(text){}; 20 | }; 21 | 22 | class Logger { 23 | public: 24 | Logger(SDL_Texture* logger, float logSpeed = 3.5f, bool enabled = true); 25 | 26 | void init(Atlas* atlas, TTF_Font* font, vec2f scale); 27 | 28 | void log(std::string text); 29 | void update(float deltaTime); 30 | void draw(); 31 | 32 | private: 33 | //member variables 34 | vec2f m_scale = vec2f(0, 0); 35 | float m_log_speed = 3.5f; 36 | bool m_enabled = true; 37 | std::list> m_logs; 38 | 39 | //pointers 40 | SDL_Texture* m_logger = nullptr; 41 | TTF_Font* m_font = nullptr; 42 | Atlas* m_atlas = nullptr; 43 | }; -------------------------------------------------------------------------------- /src/Tools/Reader.cpp: -------------------------------------------------------------------------------- 1 | #include "Reader.hpp" 2 | 3 | std::vector Reader::get_folders(std::string path) 4 | { 5 | std::vector folders; 6 | const std::experimental::filesystem::path realPath{ path }; 7 | for (auto const& dir_entry : std::experimental::filesystem::directory_iterator{ realPath }){ 8 | int extension = dir_entry.path().string().find("."); 9 | 10 | if(extension != -1){ 11 | //folders.push_back(dir_entry.path().string()); 12 | continue; 13 | } 14 | 15 | folders.push_back(dir_entry.path().string()); 16 | } 17 | return folders; 18 | } 19 | 20 | std::vector Reader::read_file(std::string path) 21 | { 22 | std::vector files; 23 | const std::experimental::filesystem::path realPath{ path }; 24 | for (auto const& dir_entry : std::experimental::filesystem::directory_iterator{ realPath }){ 25 | int extension = dir_entry.path().string().find("."); 26 | 27 | if(extension == -1){ 28 | //folders.push_back(dir_entry.path().string()); 29 | continue; 30 | } 31 | 32 | files.push_back(dir_entry.path().string()); 33 | } 34 | return files; 35 | } -------------------------------------------------------------------------------- /src/Tools/Reader.hpp: -------------------------------------------------------------------------------- 1 | //script that will be used to read folder information 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace Reader{ 10 | std::vector get_folders(std::string path); 11 | std::vector read_file(std::string path); 12 | } -------------------------------------------------------------------------------- /src/Utils/Common.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __COMMON_HPP__ 2 | #define __COMMON_HPP__ 3 | #pragma once 4 | #include 5 | //enums 6 | enum State{IDLE,UPDATE,UNAVALIABLE}; 7 | 8 | //important stuff to entities 9 | struct vec2f 10 | { 11 | float x, y; 12 | vec2f() 13 | :x(0.0f), y(0.0f) 14 | {} 15 | 16 | vec2f(float p_x, float p_y) 17 | :x(p_x), y(p_y) 18 | {} 19 | 20 | void print() 21 | { 22 | std::cout << x << ", " << y << std::endl; 23 | } 24 | }; 25 | struct vec3f { 26 | float x, y, z; 27 | vec3f() 28 | :x(0.0f), y(0.0f), z(0.0f) 29 | {} 30 | vec3f(float p_x, float p_y, float p_z) 31 | :x(p_x), y(p_y), z(p_z) 32 | {} 33 | void print() 34 | { 35 | std::cout << x << ", " << y << ", " << z << std::endl; 36 | } 37 | }; 38 | /// 39 | /// Structure that will have position and radius 40 | /// 41 | struct Area { 42 | float x, y, w, h; 43 | Area(float pX, float pY, float pW, float pH):x(pX), y(pY), w(pW), h(pH) {} 44 | 45 | bool intersects(const Area pArea) { 46 | return (x < pArea.x + pArea.w) && 47 | (pArea.x < x + w) && 48 | (y < pArea.y + pArea.h) && 49 | (pArea.y < y + h); 50 | } 51 | }; 52 | 53 | struct Stat{ 54 | float value; 55 | float max; 56 | Stat():value(0), max(0){} 57 | Stat(float _value, float _max):value(_value), max(_max){} 58 | 59 | void add(float _value){ 60 | value += _value; 61 | if(value > max){ 62 | value = max; 63 | } 64 | } 65 | }; 66 | 67 | struct Life : public Stat{ 68 | Life():Stat(){} 69 | Life(float _value, float _max):Stat(_value, _max){} 70 | 71 | bool is_alive(){ 72 | return value > 0; 73 | } 74 | }; 75 | #endif -------------------------------------------------------------------------------- /src/Utils/Gizmos.cpp: -------------------------------------------------------------------------------- 1 | #include "Gizmos.hpp" 2 | 3 | void Gizmos::draw_area(vec2f pos, float radius, Atlas* atlas, vec3f color) 4 | { 5 | #if F_ENABLE_DEBUG 6 | for(int i = 0 ; i < radius ; ++i){ 7 | if(i == 0){ 8 | for(int j = 0 ; j < radius ; ++j){ 9 | atlas->draw_pixel(pos.x + j, pos.y+i, color.x, color.y, color.z, 255); 10 | 11 | if(j == radius - 1){ 12 | for(int k = 0 ; k < radius ; ++k){ 13 | atlas->draw_pixel(pos.x + radius, pos.y+k, color.x, color.y, color.z, 255); 14 | } 15 | } 16 | } 17 | } 18 | 19 | if(i == radius - 1){ 20 | for(int j = 0 ; j < radius ; ++j){ 21 | atlas->draw_pixel(pos.x + j, pos.y+i, color.x, color.y, color.z, 255); 22 | } 23 | } 24 | 25 | atlas->draw_pixel(pos.x, pos.y+i, color.x, color.y, color.z, 255); 26 | } 27 | #endif 28 | } 29 | 30 | void Gizmos::draw_line(vec2f start, vec2f end, Atlas *atlas, vec3f color) 31 | { 32 | #if F_ENABLE_DEBUG 33 | float dx = end.x - start.x; 34 | float dy = end.y - start.y; 35 | float steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy); 36 | float x_inc = dx / steps; 37 | float y_inc = dy / steps; 38 | float x = start.x; 39 | float y = start.y; 40 | 41 | for(int i = 0 ; i < steps ; ++i){ 42 | atlas->draw_pixel(x, y, color.x, color.y, color.z, 255); 43 | x += x_inc; 44 | y += y_inc; 45 | } 46 | #endif 47 | } 48 | 49 | void Gizmos::draw_circle(vec2f pos, float radius, Atlas *atlas, vec3f color) 50 | { 51 | #if F_ENABLE_DEBUG 52 | int x = radius; 53 | int y = 0; 54 | int err = 0; 55 | 56 | while(x >= y){ 57 | atlas->draw_pixel(pos.x + x, pos.y + y, color.x, color.y, color.z, 255); 58 | atlas->draw_pixel(pos.x + y, pos.y + x, color.x, color.y, color.z, 255); 59 | atlas->draw_pixel(pos.x - y, pos.y + x, color.x, color.y, color.z, 255); 60 | atlas->draw_pixel(pos.x - x, pos.y + y, color.x, color.y, color.z, 255); 61 | atlas->draw_pixel(pos.x - x, pos.y - y, color.x, color.y, color.z, 255); 62 | atlas->draw_pixel(pos.x - y, pos.y - x, color.x, color.y, color.z, 255); 63 | atlas->draw_pixel(pos.x + y, pos.y - x, color.x, color.y, color.z, 255); 64 | atlas->draw_pixel(pos.x + x, pos.y - y, color.x, color.y, color.z, 255); 65 | 66 | if(err <= 0){ 67 | y += 1; 68 | err += 2*y + 1; 69 | } 70 | 71 | if(err > 0){ 72 | x -= 1; 73 | err -= 2*x + 1; 74 | } 75 | } 76 | #endif 77 | } -------------------------------------------------------------------------------- /src/Utils/Gizmos.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef GIZMOS_HPP 4 | #define GIZMOS_HPP 5 | 6 | #include "../Renderer/Atlas.hpp" 7 | #include "Common.hpp" 8 | 9 | namespace Gizmos{ 10 | void draw_area(vec2f pos, float radius, Atlas* atlas, vec3f color = {255,0,0}); 11 | void draw_line(vec2f start, vec2f end, Atlas* atlas, vec3f color = {255,0,0}); 12 | void draw_circle(vec2f pos, float radius, Atlas* atlas, vec3f color = {255,0,0}); 13 | } 14 | 15 | 16 | #endif -------------------------------------------------------------------------------- /src/Utils/Math.cpp: -------------------------------------------------------------------------------- 1 | #include "Math.hpp" 2 | 3 | double Math::lerp(double a, double b, double t) 4 | { 5 | if (t <= 0.5) 6 | return a + (b - a) * t; 7 | else 8 | return b - (b - a) * (1.0 - t); 9 | } 10 | 11 | int Math::clamp(int min, int value, int max) 12 | { 13 | if (value < min) 14 | return min; 15 | else if (value > max) 16 | return max; 17 | else 18 | return value; 19 | } 20 | 21 | int Math::round(double value) 22 | { 23 | return (int)(value + 0.5); 24 | } 25 | 26 | double Math::sign(double value) 27 | { 28 | if (value > 0) 29 | return 1; 30 | else if (value < 0) 31 | return -1; 32 | else 33 | return 0; 34 | } 35 | 36 | double Math::abs(double value) 37 | { 38 | if (value < 0) 39 | return -value; 40 | else 41 | return value; 42 | } 43 | 44 | double Math::pow(double base, double exponent) 45 | { 46 | double result = 1; 47 | for (int i = 0; i < exponent; i++) 48 | result *= base; 49 | return result; 50 | } 51 | 52 | double Math::sqrt(double value) 53 | { 54 | double result = 0; 55 | for (int i = 0; i < value; i++) 56 | { 57 | if (i * i == value) 58 | { 59 | result = i; 60 | break; 61 | } 62 | } 63 | return result; 64 | } -------------------------------------------------------------------------------- /src/Utils/Math.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Math { 4 | double lerp(double a, double b, double t); 5 | 6 | int clamp(int min, int value, int max); 7 | int round(double value); 8 | double sign(double value); 9 | double abs(double value); 10 | double pow(double base, double exponent); 11 | double sqrt(double value); 12 | }; -------------------------------------------------------------------------------- /src/Utils/Mouse.cpp: -------------------------------------------------------------------------------- 1 | #include "Mouse.hpp" 2 | 3 | bool Mouse::is_at_area(Area pArea) 4 | { 5 | int x = 0, y = 0; 6 | SDL_GetMouseState(&x, &y); 7 | //explanation of the magic numbers: 8 | //4 are used to smoothen the edge-case detection 9 | //8x8 is the width of the default cursor 10 | Area mouseArea = Area(x-4, y-4, 8, 8); 11 | return mouseArea.intersects(pArea); 12 | } 13 | 14 | vec2f Mouse::get_mouse_pos() 15 | { 16 | int x = 0, y = 0; 17 | SDL_GetMouseState(&x, &y); 18 | return vec2f(x,y); 19 | } 20 | -------------------------------------------------------------------------------- /src/Utils/Mouse.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef MOUSE_HPP 3 | #define MOUSE_HPP 4 | 5 | #include "SDL.h" 6 | #include "Common.hpp" 7 | #include 8 | #include 9 | namespace Mouse { 10 | 11 | bool is_at_area(Area pArea); 12 | vec2f get_mouse_pos(); 13 | 14 | class MouseCursor{ 15 | SDL_Rect rect; 16 | SDL_Rect point; 17 | 18 | public: 19 | MouseCursor(SDL_Rect rect = {0, 0, 16, 16}, SDL_Rect point = {0,0,1,1}) { 20 | //SDL_ShowCursor(SDL_DISABLE); 21 | this->rect = rect; 22 | this->point = point; 23 | } 24 | void disable_cursor(){ 25 | SDL_ShowCursor(true); 26 | } 27 | void update(){ 28 | vec2f mousePos = get_mouse_pos(); 29 | rect.x = mousePos.x; 30 | rect.y = mousePos.y; 31 | point.x = mousePos.x; 32 | point.y = mousePos.y; 33 | } 34 | void draw(SDL_Texture* tex, SDL_Renderer* ren){ 35 | //SDL_ShowCursor(SDL_DISABLE); 36 | SDL_RenderCopy(ren, tex, NULL, &rect); 37 | } 38 | }; 39 | }; 40 | 41 | #endif -------------------------------------------------------------------------------- /src/Utils/Sprite.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "SDL.h" 6 | #include "SDL_image.h" 7 | 8 | #include "../Resources/Resources.hpp" 9 | 10 | //this script will handle all the functionality that a sprite needs 11 | struct SpriteAnimation{ 12 | std::string name; 13 | std::vector frames; 14 | 15 | int current_frame = 0; 16 | int frameCount = 0; 17 | //the time that will be used in between the frames 18 | double frame_timer = 0.8f; 19 | double m_frame_time = 0; 20 | 21 | //default constructor 22 | SpriteAnimation() 23 | :name("default"), frames(std::vector()), current_frame(0), frameCount(0), frame_timer(0.8f), m_frame_time(0) 24 | {} 25 | 26 | SpriteAnimation(std::string name, std::vector frames, double frameTimer){ 27 | this->name = name; 28 | this->frames = frames; 29 | this->frameCount = frames.size(); 30 | this->frame_timer = frameTimer; 31 | print(); 32 | } 33 | 34 | void update(double deltaTime){ 35 | m_frame_time += deltaTime; 36 | 37 | //TODO: need to fix this double issue so its possible to modify the frame timer 38 | if(m_frame_time >= 0.1f){ 39 | m_frame_time = 0; 40 | current_frame += 1; 41 | } 42 | if(current_frame >= frameCount){ 43 | current_frame = 0; 44 | } 45 | } 46 | std::string get_current_frame(){ 47 | return frames[current_frame]; 48 | } 49 | 50 | void print(){ 51 | std::cout << "_______________ANIMATION________________" << std::endl; 52 | std::cout << "Animation Name : " << name << std::endl; 53 | std::cout << "Frames : " << std::endl; 54 | for(auto const& frame : frames){ 55 | std::cout << frame << std::endl; 56 | } 57 | std::cout << "Current Frame : " << current_frame << std::endl; 58 | std::cout << "Frame Count : " << frameCount << std::endl; 59 | std::cout << "Frame Timer : " << frame_timer << std::endl; 60 | std::cout << "_______________ANIMATION________________" << std::endl; 61 | } 62 | }; 63 | --------------------------------------------------------------------------------