blah/README.md

67 lines
2.2 KiB
Markdown
Raw Normal View History

2020-08-26 15:38:59 +08:00
## blah
2020-12-31 06:33:02 +08:00
A small C++ game framework for 2D games.
Goal is to be simple and use as few dependencies as possible, to maintain 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+
2020-12-29 10:37:33 +08:00
- Platform Backend
2021-01-13 16:38:31 +08: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-29 10:37:33 +08:00
- Graphics Backend
2021-01-13 16:38:31 +08:00
- [OpenGL](https://github.com/NoelFB/blah/blob/master/src/internal/graphics_backend_gl.cpp) can be enabled in CMake with `OPENGL_ENABLED`.
- [D3D11](https://github.com/NoelFB/blah/blob/master/src/internal/graphics_backend_d3d11.cpp) (unfinished) can be enabled in CMake with `D3D11_ENABLED`.
- 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-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::elapsed * Calc::TAU;
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;
}
```