2020-08-26 00:38:59 -07:00
## blah
2021-03-18 00:23:35 -07:00
A small 2D C++ Game Framework, using few dependencies and simple code to mainain easy building and portability.
2020-08-27 18:16:01 -07:00
2020-12-30 14:33:02 -08:00
** ☆ This will likely see breaking changes! Use at your own risk! ☆**
2020-08-26 00:38:59 -07:00
2020-12-25 18:47:02 -08:00
#### building
2021-01-04 08:24:02 +01:00
- Requires C++17 and CMake 3.12+
2020-12-28 18:37:33 -08:00
- Platform Backend
2021-01-13 09:38:31 +01:00
- [SDL2 ](https://github.com/NoelFB/blah/blob/master/src/internal/platform_backend_sdl2.cpp ) can be enabled in CMake with `SDL2_ENABLED` , and setting `SDL2_INCLUDE_DIRS` and `SDL2_LIBRARIES`
2020-12-28 18:37:33 -08:00
- Graphics Backend
2021-01-13 09:38:31 +01:00
- [OpenGL ](https://github.com/NoelFB/blah/blob/master/src/internal/graphics_backend_gl.cpp ) can be enabled in CMake with `OPENGL_ENABLED` .
2021-03-18 00:23:35 -07:00
- [D3D11 ](https://github.com/NoelFB/blah/blob/master/src/internal/graphics_backend_d3d11.cpp ) can be enabled in CMake with `D3D11_ENABLED` .
2021-01-13 09:38:31 +01:00
- Other backends can be added by implementing the [Platform Backend ](https://github.com/NoelFB/blah/blob/master/src/internal/platform_backend.h ) or [Graphics Backend ](https://github.com/NoelFB/blah/blob/master/src/internal/graphics_backend.h ).
2020-08-27 20:19:46 -07:00
#### notes
2021-01-13 09:38:31 +01:00
- There's no Shader abstraction, so the [Sprite Batcher ](https://github.com/NoelFB/blah/blob/master/include/blah/drawing/batch.h ) has hard-coded GLSL/HLSL. This will need to change.
2020-12-28 18:37:33 -08:00
- Only floatN/mat3x2/mat4x4 uniforms are supported.
2020-12-25 18:47:02 -08:00
- There's no Audio API or backend implementation yet.
2020-12-28 18:37:33 -08:00
- No threaded rendering so it will explode if you try that.
2020-08-27 20:19:46 -07:00
#### a sample application
```cpp
#include <blah.h>
using namespace Blah ;
Batch batch ;
2020-12-29 17:38:21 -08:00
TextureRef tex ;
void startup ()
{
tex = Texture :: create ( "player.png" );
}
2020-08-27 20:19:46 -07:00
void render ()
{
2020-12-26 14:44:48 -08:00
App :: backbuffer -> clear ( Color :: black );
2020-08-27 20:19:46 -07:00
2020-12-26 14:44:48 -08:00
auto center = Vec2 ( App :: backbuffer -> width (), App :: backbuffer -> height ()) / 2 ;
auto rotation = Time :: elapsed * Calc :: TAU ;
auto transform = Mat3x2 :: create_transform ( center , Vec2 :: zero , Vec2 :: one , rotation );
2020-08-27 20:23:26 -07:00
batch . push_matrix ( transform );
2020-12-26 14:44:48 -08:00
batch . rect ( Rect ( - 32 , - 32 , 64 , 64 ), Color :: red );
2020-12-29 17:38:21 -08:00
batch . tex ( tex , Vec2 ( 64 , 0 ), Color :: white );
2020-08-27 20:19:46 -07:00
batch . pop_matrix ();
2020-12-26 14:44:48 -08:00
batch . render ();
2020-08-27 20:19:46 -07:00
batch . clear ();
}
int main ()
{
Config config ;
config . name = "blah app" ;
config . width = 1280 ;
config . height = 720 ;
2020-12-29 17:38:21 -08:00
config . on_startup = startup ;
2020-08-27 20:19:46 -07:00
config . on_render = render ;
App :: run ( & config );
return 0 ;
}
```