All Projects → tanis2000 → binocle-c

tanis2000 / binocle-c

Licence: MIT license
A simple game engine in C

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
objective c
16641 projects - #2 most used programming language
lua
6591 projects
HTML
75241 projects

Projects that are alternatives of or similar to binocle-c

Wonder.js
🚀Functional, High performance 3D Webgl Engine
Stars: ✭ 225 (+99.12%)
Mutual labels:  engine
Zombusters
🕹️ A retro style zombies shooter with cool isometric pixel art for Windows and MacOS
Stars: ✭ 41 (-63.72%)
Mutual labels:  videogame
unified-args
Create CLIs for unified processors
Stars: ✭ 30 (-73.45%)
Mutual labels:  engine
Sucle
Common Lisp Voxel Game Engine
Stars: ✭ 239 (+111.5%)
Mutual labels:  engine
Dome
A lightweight game development environment where games can be written in Wren
Stars: ✭ 251 (+122.12%)
Mutual labels:  engine
unity-button-sounds-editor
Editor extension for Unity game engine. It helps to assign AudioClip to buttons and to play sounds by button clicks.
Stars: ✭ 65 (-42.48%)
Mutual labels:  engine
Ogsr Engine
OGSR Project - Evolution of X-Ray Engine for S.T.A.L.K.E.R.: Shadow of Chernobyl
Stars: ✭ 213 (+88.5%)
Mutual labels:  engine
abi-code-gen
Generic code generator from abi
Stars: ✭ 21 (-81.42%)
Mutual labels:  engine
codacy-scalameta
Codacy tool for Scalameta
Stars: ✭ 35 (-69.03%)
Mutual labels:  engine
grakkit
A modern JavaScript development environment for Minecraft.
Stars: ✭ 184 (+62.83%)
Mutual labels:  engine
Flingengine
A Vulkan game engine with a focus on data oriented design
Stars: ✭ 239 (+111.5%)
Mutual labels:  engine
Vqengine
DirectX 11 Renderer written in C++11
Stars: ✭ 250 (+121.24%)
Mutual labels:  engine
php-chess
A chess library for PHP.
Stars: ✭ 42 (-62.83%)
Mutual labels:  engine
Nil.js
JavaScript engine for .NET written in C#.
Stars: ✭ 236 (+108.85%)
Mutual labels:  engine
HelenaFramework
Modern framework on C++20 for backend/frontend development.
Stars: ✭ 53 (-53.1%)
Mutual labels:  engine
Awesome Haxe Gamedev
Resources for game development on haxe
Stars: ✭ 213 (+88.5%)
Mutual labels:  engine
f1-telemetry-client
A Node UDP client and telemetry parser for Codemaster's Formula 1 series of games
Stars: ✭ 128 (+13.27%)
Mutual labels:  videogame
rpgwizard
2D RPG Game creator
Stars: ✭ 37 (-67.26%)
Mutual labels:  engine
diaspora federation
A library that provides functionalities needed for the diaspora* federation protocol.
Stars: ✭ 97 (-14.16%)
Mutual labels:  engine
Landing-CMS
A simple CMS for landing pages
Stars: ✭ 78 (-30.97%)
Mutual labels:  engine

Binocle C version

Binocle Logo

Binocle C version is a simple game engine written in pure C.

The previous incarnation was a C++ engine with way more features than this one, but I wanted to get back to the basics and trim everything down to a more manageable framework without all the bloat that C++ carries around.

It's born out of the need for the following features:

  • Cross-platform compilation (macOS, Windows, iOS, Android, Web)
  • OpenGL ES 2 support (but you can use any variant of OpenGL as long as it's supported by your hardware)

Nothing too fancy, but still something I always need when I make 2D or 3D games and prototypes.

The API is evolving all the time but the core is pretty stable. I keep adding and tweaking stuff based on my needs, so things may change without notice.

Windows macOS Wasm iOS Android

Features

  • Cross-platform: macOS, Windows, iOS, Android, Web (Linux planned)
  • OpenGL API (ES 2/3 on mobile platforms) on all platforms
  • Metal API available on iOS and macOS
  • 2D Sprites
  • Spritesheets (TexturePacker format. LibGDX format is in the works)
  • Sprite batching
  • Music and sound effects
  • Bezier paths that can be used for anything
  • BitmapFont fonts
  • TrueType fonts
  • 2D Camera
  • 3D camera
  • 2D Collisions (boxes and circles)
  • Easing functions
  • Entity Component System
  • Timing functions
  • Viewport adapters for 2D pixel perfect images
  • Experimental hot code reloading for game code
  • Lua scripting through LuaJIT on supported platforms and fallback to Lua where LuaJIT is not available
  • Experimental Wren scripting support
  • 3D physics through Newton Dynamics (desktop platforms only)

Documentation

The full documentation is available on Read the Docs Please notice that the documentation is still a work in progress.

Installing

The easiest way to work with Binocle is to use the CLI project manager called bone. With bone you can initialize a new project and automate the compilation and linking scripts. It's a quite young tool so please remember to make regular backups of your projects.

Installing bone

You can grab bone from the GitHub repo. You can either download the binaries on the Releases page or compile it yourself.

Creating, building, running, updating and upgrading a project

Please refer to the documentation of bone to setup your first Binocle application.

Third party libraries

Binocle sits on the shoulders of giants. I tried to keep the amount of external libraries to a minimum. The current libraries are the following:

  • SDL by the almighty Ryan C. Gordon (OS abstraction)
  • sokol (backend for OpenGL and Metal)
  • sokol_time
  • miniaudio (cross-platform audio support)
  • zlib
  • Vorbis by the Xiph.Org Foundation
  • OGG by the Xiph.Org Foundation
  • FreeType
  • Dear ImGui
  • glew (for Windows OpenGL support)
  • Kazmath by Luke Benstead
  • stbimage
  • parson
  • Lua
  • LuaJIT
  • libuv (Wren's dependency)
  • Wren
  • Newton Dynamics
  • Chipmunk (2D physics)

Coordinate system

Binocle uses a right-handed coordinate system which is the same used by OpenGL

Contributing

You're welcome to try Binocle and contribute.

Right now there are a few areas that could use some help:

  • Adding Linux support. It should work almost out of the box once you figure out the CMake scripts.
  • More examples
  • Travis scripts to build static libraries for all the different systems so that we can distribute Binocle as a binary library with just the headers and avoid having to recompile the whole library for every new project.
  • Complete the Lua bindings
  • Complete the Wren bindings

Manually compiling the library

If you want to work on the library itself, just clone this repository and compile it on your own. The following are the build commands for each supported platform.

macOS

mkdir build
cd build
cmake -G Xcode -D DEBUG=1 -D BUILD_EXAMPLE=1 ../
open binocle.xcodeproj

Windows

I usually run the CMake GUI tool and select the Visual Studio generator there. That's pretty much all that's needed.

Android

You will need the Android SDK and NDK and the correct environment variables for this to work.

mkdir build

cmake -H. -B./build/armeabi-v7a -D ANDROID_ABI=armeabi-v7a -D ANDROID_PLATFORM=android-33 -D DEBUG=1 -D BUILD_EXAMPLE=1 -D CMAKE_TOOLCHAIN_FILE=./cmake/android.toolchain.cmake -G Ninja
cmake -H. -B./build/arm64-v8a -D ANDROID_ABI=arm64-v8a -D ANDROID_PLATFORM=android-33 -D DEBUG=1 -D BUILD_EXAMPLE=1 -D CMAKE_TOOLCHAIN_FILE=./cmake/android.toolchain.cmake -G Ninja
cmake -H. -B./build/x86 -D ANDROID_ABI=x86 -D ANDROID_PLATFORM=android-33 -D DEBUG=1 -D BUILD_EXAMPLE=1 -D CMAKE_TOOLCHAIN_FILE=./cmake/android.toolchain.cmake -G Ninja
cmake -H. -B./build/x86_64 -D ANDROID_ABI=x86_64 -D ANDROID_PLATFORM=android-33 -D DEBUG=1 -D BUILD_EXAMPLE=1 -D CMAKE_TOOLCHAIN_FILE=./cmake/android.toolchain.cmake -G Ninja

ninja -C build/armeabi-v7a -j8 && ninja -C build/arm64-v8a -j8 && ninja -C build/x86 -j8 && ninja -C build/x86_64 -j8

cd ../platform/android/android-project
./gradlew installDebug

iOS

You will need the latest Xcode and its command line tools.

mkdir build
cd build
cmake -G Xcode -D DEBUG=1 -D IOS=1 -D BUILD_EXAMPLE=1 ../
open binocle.xcodeproj

iOS without Xcode

If you want to compile for the simulator replace:

  • BINOCLE_IOS_SDK=iphonesimulator
  • BINOCLE_IOS_ARCH=x86_64
mkdir build
cd build
cmake -D DEBUG=1 -D IOS=1 -D BUILD_EXAMPLE=1 -D BINOCLE_IOS_SDK=iphoneos -D BINOCLE_IOS_ARCH=arm64 ../
make -j8

Emscripten (web)

You need a recent version of Emscripten installed on your system. If you're using macOS, you can't just do a brew install emscripten to set it up. It will have issues. The best way is to clone emscripten's repository and follow its setup guide. In the end you will have a shell script to run to setup all the environment variables. Just replace its path in the script below.

mkdir build
cd build
source "/Users/tanis/Documents/emsdk/emsdk_env.sh"
emcmake cmake ../ -DCMAKE_BUILD_TYPE=Release -D BUILD_EXAMPLE=1
make -j8
cd example/src
python -m SimpleHTTPServer 8000
open http://localhost:8000/ExampleProject.html

Generating the documentation

To generate the documentation just add the -DBUILD_DOC=ON option when running cmake.

Credits

Many of the concepts come from Matt Thorson's Monocle engine (the name of this project is a kind of joke around Matt's engine name as you can guess).

Some code has been developed while Prime31 was working on its own C# engine called Nez so there will surely be similarities and lines of code that are almost the same.

The ECS has been inspired by Artemis and some parts have been taken from Diana Other pieces of code have been taken here and there on the web and I can't recall where they come from. If you see some code that looks familiar, please let me know and I'll give full credits.

The Metal backend and the glue code to keep both OpenGL and Metal as available backends has been taken from Andre Weissflog's exceptional Sokol library. I started implementing a first version based on it and I ended up reusing a lot of his code. In the future I will probably just adopt Sokol as the backend, but it was actually a good exercise to learn how to implement a cross-platform API with complete separation of platform-dependent code.

The logo has been created using the following images:

The idea of the final logo is from @h_a_l_e_x

A big thank you to JetBrains for providing us Open Source license of CLion. If you do not know about them, please check out their site by clicking on the logo below. They make the best tool for C developers, hands-down JetBrains Logo (Main) logo CLion logo

Examples

Here's an examples' repository with a few examples to start with.

This repository also contains an example project that I use to debug and test new features. It can be compiled by using the -D BUILD_EXAMPLE=1 CMake directive.

Projects using Binocle

Shadow Crash screenshot Shadow Crash, my entry for Ludum Dare 50. You can get the source code here

Santa frowns to town screenshot Santa frowns to town, my entry for Ludum Dare 43. You can get the source code here

Binocle Demo Tool screenshot Binocle Demo Tool, my personal unreleased demo tool

License

The MIT License (MIT) Copyright (c) 2015-2022 Valerio Santinelli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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].