SDL2 Static Library Extension to Simplify using OpenGL and OpenGL Shaders
- Unpack
SDL_EXT_GLSLsomewhere easy to reference by your compiler.
Link library and include alongside SDL2 and OpenGL in your project.
Refer to Docs for how to use.
TODO: setup doxygen or similar to create markdowns in a doc folder or webpages in another repo to host on github-pages
Working with source code or building for a specific system.
Note: This is an option step, you can jump straight to Buidling without needing to link SDL2 or OpenGL.
Configure include and linker as if any other SDL2 + OpenGL project.
The following sections assume you at least have SDL2 and OpenGL installed on your system:
Note: See wiki.libsdl.org/SDL2/FrontPage for more info on installing and using SDL2.
- Create
builddirectory in project's root folder - Create
resourcesdirectory inbuild - Copy files (excluding
README.md) from./test_resources/into./build/resources/
Note: Be sure to add
SDL2.dlltobuildif using Windows (pickx86orx64as needed)
- Set working dir:
.\src - Flags:
/EHsc /nologo /Ox - Source targets to build:
test_lib.c sdl_gl.c glsl_shader.c glsl_ext.c - Build output:
/Fe..\build\test.exe - Add SDL2 include dir:
/I"<full-path-SDL2-include-dir>" - Configure Linker:
/link- Set as console:
/SUBSYSTEM:CONSOLE - Add Libraries:
Shell32.lib SDL2.lib SDL2main.lib OpenGL32.lib - Add SDL2 lib dir:
/LIBPATH:"<full-path-SDL2-lib-dir>"Note:
<full-path-SDL2-lib-dir>can bex86orx64(depends only oncl.exeselected for build)
- Set as console:
Note: Run
$ sdl2-config --cflags --libsto get SDL args for gcc
- Set working dir:
./src - Flags:
-O3 -DNO_SHARED_MEMORY -D_REENTRANT -D_THREAD_SAFE - Build output:
-o ../build/test - Source tagets to build:
test_lib.c sdl_gl.c glsl_shader.c glsl_ext.c - Add SDL2 include dir:
-I<full-path-SDL2-include-dir> - Add Libraries:
-lm -lSLD2 -lGL
Execute .\build\test.exe
Controls:
- Move:
WASDShiftCTRL - Rotate:
Arrow Keys - Select Shader:
[] - Select Texture:
;' - Toggle Smooth Texturing:
L - Toggle Quad Spin:
Spacebar
Expected four BMP textures. First and last should have alpha channels.
Building the static library.
Note: SDL2 and OpenGL linking not required for this step.
SDL2 includes are required
See wiki.libsdl.org/SDL2/FrontPage for more info on installing and using SDL2.
- Build Objects (
cl.exe):- Set working dir:
.\src - Flags:
/EHsc /nologo /Ox /c - Source targets to build:
sdl_gl.c glsl_shader.c glsl_ext.c - Add SDL2 include dir:
/I"<full-path-SDL2-include-dir>"
- Set working dir:
- Build Library (
lib.exe):- Set working dir:
.\src - Build output:
/OUT:..\build\SDL_EXT_GLSL.lib - Obj targets to build:
sdl_gl.obj glsl_shader.obj glsl_ext.obj
- Set working dir:
- Build Objects (
gcc)Note: Run
$ sdl2-config --cflagsto get SDL args for gcc- Set working dir:
./src - Flags:
-O3 -c -DNO_SHARED_MEMORY -D_REENTRANT -D_THREAD_SAFE - Source tagets to build:
sdl_gl.c glsl_shader.c glsl_ext.c - Add SDL2 include dir:
-I<full-path-SDL2-include-dir>
- Set working dir:
- Build Library (
ar)- Flags:
rcs - Build output:
../build/libSDL_EXT_GLSL.so - Obj target to build:
sdl_gl.o glsl_shader.o glsl_ext.o
- Flags:
Run batch script: scripts\package_for_dist.bat
Note: Can run from project root or
scriptsdirectory
Run script: scripts\package_for_dist.sh
Note: Can run from project root or
scriptsdirectory
After scripts, dist with subdirectory SDL_EXT_GLSL should exist.
Enter dist, compress SDL_EXT_GLSL with versioning.
Distribute as needed.
Nothing at this time