blah/README.md

68 lines
2.4 KiB
Markdown
Raw Normal View History

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