Giter Site home page Giter Site logo

sdl2_template's Introduction

SDL2 CMake Template

A quickstart template for a CMake project intended for games/graphics

Includes Git Submodules for

  • ImGui (defaults to OpenGL3 Backend)
  • GLM
  • SDL2

Also includes stb_image header

To use a different graphical API, just edit the CMakeLists in lib to use a different ImGui backend

SDL2

SDL2 is a bit messy to 'get' unless you use the provided submodule (and checkout a release version)

Currently the below method, using SDL2_DIR on Windows is not working correctly, so use the Git Submodule to grab SDL2, this should be done by default as long as the repository is cloned with --recursive, if not theres a lot of posts on how to init and clone submodules. Just remember that if you need a specific commit (you probably will for SDL2 as it defaults to cloning the main branch (SDL3) so make sure to grab a release that you want.)

If you enable the USE_SDL_SYS CMake Variable, it will use system SDL2 libs (on Linux devices) or use the directory specified by 'SDL2_DIR' (see Sample Commands for CMake syntax :D )

On Windows, it is recommended to use the 'devel' libs, in a local folder as the source for your SDL2 libraries, for release its a little different, at some point I will set up automatic downloading of development/release libraries and scripts to automatically wrap up release versions with their dlls, but I've not done that before so I'll have to experiment a bit

Sample commands

Use something like this for a Ninja build project on Windows/MSVC

Specifying an SDL dir is not needed if using the Git Submodule method to getting SDL

cmake ../ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DSDL2_DIR=C:\SDL2\cmake

In case you add more SDL2 libraries, use these variables to specify their locations:

-DSDL2_mixer_DIR=C:\SDL2_Mixer\cmake -DSDL2_image_DIR=C:\SDL2_Image\cmake -DSDL2_ttf_DIR=C:\SDL2_TTF\cmake

On Linux, it should be as simple as specifying your project file to be generated (Ninja, Make, etc) and hitting go as long as you have the SDL2 libs installed that you need

sdl2_template's People

Contributors

shylexx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.