Giter VIP home page Giter VIP logo

dimi309 / small3d Goto Github PK

View Code? Open in Web Editor NEW
113.0 4.0 4.0 81.45 MB

Tiny C++ 3D game development library for Win/MacOS/Linux/iOS/Android.

Home Page: https://dimi309.github.io/small3d/

License: BSD 3-Clause "New" or "Revised" License

CMake 6.05% C++ 85.34% GLSL 1.97% Batchfile 1.35% Shell 1.91% C 0.10% Objective-C 3.21% Java 0.08%
3d-game-engine android game-engine graphics-engine ios linux macos opengl windows cpp cross-platform gamedev opengl-es

small3d's Introduction

small3d

Build status

[Source Code] [API Documentation]

Minimalistic, open source library for making 3D games in C++

This library provides a sufficient level of game development functionalities for C++ developers to be able to build cross-platform games based on a single code-base. Supporting as many platforms as possible while minimising the amount of code and time needed for maintenance is favoured over richness of features and the use of cutting edge methods and technologies.

Games

First little games

  • Avoid the Bug

  • Chase the Goat

  • Frog Remixed

All of the above can be found here: https://github.com/dimi309/small3d-first-games

More "evolved" titles

Non-game project

Features

  • 3D models loaded from glTF (glb files), Wavefront (obj files) or from a native format
  • Other customised meshes and shapes
  • Texture mapping
  • Gouraud shading
  • Basic materials support (colour, transparency)
  • Shadow mapping
  • Image rendering
  • Font rendering
  • Sound (ogg and native files)
  • Collision detection
  • Frame-based animation (Wavefront)
  • Skeletal animation (glTF)

Limitations

  • Non-PNG images are not supported.
  • There are no scenes, just SceneObjects rendered in an infinite space.
  • The 3D model parsers are far from feature-complete but pretty robust nonetheless. The goal is not to be able to read a complete node structure from a gltf file for example, but to extract individual models and their animations, in order to use them in a game.

Supported platforms

  • Windows
  • MacOS
  • Linux (Tested on Debian, Ubuntu, Fedora and Arch)
  • FreeBSD
  • Android
  • iOS

Running on OpenGL on PC and OpenGL ES on mobile, this library is extremely backwards compatible. It can run on iOS 9.3 and Android 4.1.

Note: There used to be Vulkan support too, but it has been discontinued. Here is an article on the reasons for this:

https://www.gamedev.net/blogs/entry/2275791-abandoning-vulkan/

And here is the last Vulkan commit before the Vulkan renderer got removed:

https://github.com/dimi309/small3d/releases/tag/1.8015.last.vulkan

Note that despite the official deprecation of OpenGL on Apple devices, OpenGL and OpenGL ES still work just fine there. If and when that changes, I will implement a renderer in Metal or something.

Tutorial

https://www.gamedev.net/tutorials/programming/engines-and-middleware/small3d-tutorial-r5655/

Building and deploying

Prerequisites

The following need to be installed, with the relevant environment variables and tools accessible via the command line:

  • Some compiler (e.g. gcc, Visual Studio, clang) with C++17 support recommended as a minimum.
  • 7zip (only on Windows)
  • CMake
  • Android Studio if building for Android
  • Xcode if building for iOS

Deploying small3d for PC

Run the build script which is suitable to your platform from the scripts directory (build-vs.bat, build-mingw.bat or build.sh).

Then, the unit tests are executed by running unittests binary from build/bin.

If any of this fails or you would simply like to restart the building procedure, the best way to clean the repository is by using git:

git clean -fdx

For building your own project, you need:

  • The header files from the build/include directory
  • The libraries from the build/lib directory
  • The shaders from build/shaders directory
  • The small3d/cmake directory if you will be using cmake

You can also deploy using conan. The conan package is provided in a separate repository.

Deploying small3d for mobile

Builds for mobile platforms can be performed by executing either build-android or build-ios from the scripts directory. You can then use the test projects in the android, ios and ios-opengles directories to check if everything works, or as a starting point for your own projects.

If the Android project produces an NDK or SDK related error when opened in Android Studio, just close it without exiting Android Studio and open it again.

Also on Android, while a game or the unit tests are running, the error .../GL2Encoder.cpp:s_glGetBufferParameteriv:3386 GL error 0x502 might appear in the log. You can ignore it. It is produced when glGetBufferParameteriv is called in the Renderer to check if a model has already been copied to the GPU and the model is not found (as expected when it has been newly loaded).

Note that, while on the PC edition I use GLFW for windowing functionalities and I/O, on mobile I access the native infrastructure directly.

Boilerplate Project

If you would like to start with an empty project that has the basic game loop and input already set up, you are looking for this:

https://github.com/dimi309/small3d-boilerplate

It is highly recommended to use this boilerplate if you intend to port your game to Android and / or iOS. While it is pretty straightforward to get this library working for the desktop and you might prefer the freedom and flexibility of working with a project set up from scratch, mobile platforms have many specificities and quirks to take care of, so the boilerplate can save you a lot of time in that respect.

Referenced libraries

The following dependencies' source code repositories (not binaries) are distributed in this same repository (in the deps directory). They can be built by executing a single script (see "Building", above) and they can also be used directly in your application / game code.

  • glew when building for PC
  • glfw
  • glm
  • png
  • zlib
  • ogg
  • vorbis
  • portaudio
  • freetype
  • cereal
  • oboe when building for Android

small3d's People

Contributors

dimi309 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

small3d's Issues

Sound does not work on Ubuntu 20.04.3 LTS (sometimes)

Sometimes (not always) the following error is produced on Ubuntu 20.04.3 LTS:

LSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave

Vulkan Renderer: VK_ERROR_DEVICE_LOST when increasing objects per frame on Debian 10 and 11

On Debian GNU/Linux 10 (buster), after the Vulkan Renderer has run out of objects that it can draw per frame and tries to increase them by recreating the entire Vulkan setup (Renderer::increaseObjectsPerFrame) the following error is produced:

INTEL-MESA: error: ../src/intel/vulkan/anv_queue.c:45: execbuf2 failed: Invalid argument (VK_ERROR_DEVICE_LOST)
INTEL-MESA: error: ../src/intel/vulkan/anv_queue.c:244: vkQueueSubmit() failed (VK_ERROR_DEVICE_LOST)

Following that, draw and present calls no longer succeed and the program freezes.
This has not been observed on Windows or MacOS, neither on mobile devices.

OpenGL Renderer producing random EXC_BAD_ACCESS crashes on Apple silicon

The OpenGL Renderer has been known to produce random EXC_BAD_ACCESS crashes on Apple silicon (on an Apple Machook pro with M1 chip). Unfortunately I no longer have access to a machine with the Apple M chip, so I do not know if the situation has improved over time either due to updates Apple drivers updates or to improvements in the small3d code that may have resolved the issue by chance. Any feedback on this issue or even help from developers who have access to Apple M processors would be greatly appreciated ๐Ÿ˜„

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.