All Projects → redblobgames → helloworld-sdl2-opengl-emscripten

redblobgames / helloworld-sdl2-opengl-emscripten

Licence: Apache-2.0 license
Basic program that uses SDL2+OpenGL, compiling both locally and via emscripten

Programming Languages

C++
36643 projects - #6 most used programming language
Makefile
30231 projects
HTML
75241 projects
CMake
9771 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to helloworld-sdl2-opengl-emscripten

rust to js
An example of Rust code that compiles to javascript.
Stars: ✭ 26 (-63.38%)
Mutual labels:  sdl2, emscripten
Engine
A basic cross-platform 3D game engine
Stars: ✭ 208 (+192.96%)
Mutual labels:  sdl2, emscripten
faur
⚒️✨ My personal C games framework. 2D graphics, sound, inputs, states, ECS, and misc utils for data, files, math, memory, strings, time, and more. Builds for Linux, Windows, Web, and embedded devices.
Stars: ✭ 55 (-22.54%)
Mutual labels:  sdl2, emscripten
RoguelikeTutorial2020
r/RoguelikeDev Does The Complete Roguelike Tutorial
Stars: ✭ 25 (-64.79%)
Mutual labels:  sdl2, emscripten
Nothing
A simple platformer about nothing
Stars: ✭ 249 (+250.7%)
Mutual labels:  sdl2
Flextgl
OpenGL and Vulkan header and loader generator.
Stars: ✭ 180 (+153.52%)
Mutual labels:  sdl2
Civone
An open source implementation of Sid Meier's Civilization.
Stars: ✭ 176 (+147.89%)
Mutual labels:  sdl2
roswasm suite
Libraries for compiling C++ ROS nodes to Webassembly using Emscripten
Stars: ✭ 62 (-12.68%)
Mutual labels:  emscripten
Haskanoid
A breakout game in Haskell using SDL and FRP, with Wiimote and Kinect support.
Stars: ✭ 242 (+240.85%)
Mutual labels:  sdl2
Bstone
Unofficial source port for Blake Stone series
Stars: ✭ 170 (+139.44%)
Mutual labels:  sdl2
42 cheatsheet
Also referred to as "The C Man"
Stars: ✭ 204 (+187.32%)
Mutual labels:  sdl2
Ck2dll
Crusader Kings II double byte patch /production : 3.3.4 /dev : 3.3.4
Stars: ✭ 186 (+161.97%)
Mutual labels:  sdl2
Tmxlite
lightweight C++14 parser for Tiled tmx files
Stars: ✭ 248 (+249.3%)
Mutual labels:  sdl2
Gwork
Skinnable GUI with useful widget collection. Fork of GWEN.
Stars: ✭ 179 (+152.11%)
Mutual labels:  sdl2
eigen-js
⚡ Eigen-js is a port of the Eigen C++ linear algebra library
Stars: ✭ 78 (+9.86%)
Mutual labels:  emscripten
Dino Rush
🌋 Endless runner game
Stars: ✭ 173 (+143.66%)
Mutual labels:  sdl2
SDL image
Image decoding for many popular formats for Simple Directmedia Layer.
Stars: ✭ 325 (+357.75%)
Mutual labels:  sdl2
Vcmi
Open-source engine for Heroes of Might and Magic III
Stars: ✭ 2,514 (+3440.85%)
Mutual labels:  sdl2
Freej2me
A free J2ME emulator with libretro, awt and sdl2 frontends.
Stars: ✭ 203 (+185.92%)
Mutual labels:  sdl2
hypseus-singe
Hypseus is a SDL2 version of Daphne and Singe. Laserdisc game emulation.
Stars: ✭ 86 (+21.13%)
Mutual labels:  sdl2

http://unmaintained.tech/badge.svg

I wanted a bare-bones program for SDL2 + OpenGL 2D rendering that also compiled to JS+WebGL with Emscripten+Wasm. There are some SDL2 + OpenGL tutorials out there but most of them don’t target the WebGL subset of OpenGL. I can’t use the fixed function pipeline, so older OpenGL code won’t work, and I can’t use newer things like vertex array objects, instancing, or geometry shaders, so newer OpenGL code often won’t work.

Installation

The Makefile should work on Mac OS X and Linux. The code should work on Windows and other SDL+OpenGL platforms but I haven’t tested that.

Install SDL2

On Mac using Homebrew:

brew install SDL2 SDL2_image

On RedHat/Fedora flavors of Linux:

sudo yum install SDL2-devel SDL2_image-devel

On Debian/Ubuntu flavors of Linux:

sudo apt install libsdl2-dev libsdl2-image-dev

On Arch flavors of Linux:

sudo pacman -S sdl2 sdl2_image

Install STB, Dear Imgui

git submodule init
git submodule update

Compiling and running

To run the native code:

make && bin/main

To run the emscripten code: (brew install emscripten on Mac, pacman -S emscripten on Arch Linux):

make www

and then tell the webserver to serve the files from www/.

My Emscripten-ed wasm output is on my web site.

I’ve also written a partial CMakeLists.txt file but am not using it yet.

The font included in this project is Droid Sans, under the Apache License v2. The ImGui library includes the Proggy font.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].