Giter Site home page Giter Site logo

blah's Introduction

blah

A small 2D C++ Game Framework, using few dependencies and simple code to maintain easy building and portability.

โ˜† This will likely see breaking changes! Use at your own risk! โ˜†

a sample application

#include <blah.h>
using namespace Blah;

Batch batch;

int main()
{
    Config config;
    config.name = "blah app";
    config.on_render = []()
    {
        auto target = App::backbuffer();
        target->clear(Color::black);

        auto center = Vec2f(target->width(), target->height()) / 2;
        auto rotation = Time::seconds * Calc::TAU;
        auto transform = Mat3x2f::create_transform(center, Vec2f::zero, Vec2f::one, rotation);

        batch.push_matrix(transform);
        batch.rect(Rectf(-32, -32, 64, 64), Color::red);
        batch.pop_matrix();

        batch.render(target);
        batch.clear();
    };

    return App::run(&config);
}

building

  • Requires C++17 and CMake 3.14+
  • At least one Renderer implementation must be enabled in CMake:
    • OpenGL (Default on Linux/macOS) BLAH_RENDERER_OPENGL
    • D3D11 (Default on Windows) BLAH_RENDERER_D3D11
    • Additional renderers can be added by implementing the Renderer Backend

notes

  • There's no Shader abstraction, so you need to swap between GLSL/HLSL depending on the Renderer.
  • Only floatN/mat3x2/mat4x4 uniforms are supported.
  • No threaded rendering, so it will explode if you try that.

blah's People

Contributors

accacio avatar akholetsky avatar akien-mga avatar benjitrosch avatar bitwitch avatar fabtjar avatar impiaaa avatar kevinbchen avatar noelfb avatar puugz avatar randygaul avatar rtarun9 avatar sherjilozair avatar shortgecko avatar sushilragoonath avatar svercl 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blah's Issues

PostProcessing

Hi Noel ๐Ÿ‘‹๐Ÿผ !
Thank you SO much for putting this together, along with the "how to make a game in SDL" video you have helped me tremendously to understand C++, OpenGL, and game programming. There's not a lot of content like yours out there, keep at it!

This is not really an 'issue' with the framework, I just want to ask you something regarding postprocessing using blah.
Sorry if this is not the right place for this kind of question, I didn't know where else to ask, hope you don't mind.
How did you implement a point-light system that you have in your game?

Screen Shot 2021-11-25 at 10 48 39

How does postprocessing in general fit in the OpenGL abstraction in blah. Say I have a PointLightComponent how would that get rendered?
Are you using another frame buffer, rendering the lights there as a grayscale image, and then compositing everything together?
if so, do you use two Batch.cpp objects? one for lights and one for everything else?

I could not find a way of doing this in a clean way, I'm currently rendering all my lights after everything else got rendered and using a custom "light material" which is just a wrapper around a Material... but the code is a mess. Any pointers in the right direction would be greatly appreciated :) Have a great week

Screen Shot 2021-11-25 at 11 00 51

App::content_scale() feels wrong across platforms

Ideally this method is meant to return a reasonable value to scale Gui based on the user's desktop and whether they have a high dpi monitor. On windows this feels right to me, but macOS returns really weird values and Linux seems close but too large on my test environments.

SDL2 has SDL_GetDisplayDPI which the implementation uses, but I'm not sure how to use those values correctly. It seems like dividing by 96 makes sense, but is there a way to tell what the correct DPI constant should be? I've seen other cases where they divide by 72.

SDL2 related code: https://github.com/NoelFB/blah/blob/master/src/internal/platform_sdl2.cpp#L539

Drop Platform abstraction in favor of SDL2

Originally when I started this I wanted to have an abstraction layer for the platform implementation. However, SDL2 runs on everything I need for my use cases & I'm not interested in personally maintaining more platform abstraction layers, so I may simplify the API and just require SDL2.

Imgui rendering with Blah

I'm working on integrating Dear ImGui with Blah, and have everything basically working, except I'm a bit stumped by the final render step. I saw on Twitch that you were using Imgui in your projects and thought you might have some guidance.

Any tips on how to translate Imgui's ImDrawData or ImDrawList into a texture or something that I can pass to Blah's batch/drawing functions? Semi-pseudocode:

config.on_render = []()
{
    Batch batch;
    ImDrawData *imgui_draw_data = ImGui::GetDrawData();
    if (imgui_draw_data->Valid)
      batch.render_imgui(imgui_draw_data)
};

Thanks for open-sourcing this library! Studying it has been a valuable learning experience.

`Reserve` identifier not found

Windows 10. Visual Studio 2019.

An error appears when building a test project.

E:\Projects\CPP\blah\blah_source\public\blah\containers\list.h(103,3): error C3861: 'Reserve': identifier not found
E:\Projects\CPP\blah\blah_source\public\blah\containers\list.h(103,10): message : 'Reserve': function declaration must be available as none of the arguments depend on a template parameter

Direct graphics api usage

I'm looking to directly use directx11. Not sure if I should create a function somewhere in the app to get the ID3D11Device and ID3D11DeviceContext or maybe there is another way to obtain these but I'm not sure.

flip_vertically when drawing multiple framebuffer

Hi Noel! I keep learning cpp/openGL by looking at your code :) thanks you for making this open source.

There's something I can't figure out and I thought I'd ask here, batch.flip_vertically is set to true ever time we draw a framebuffer texture: m_batch.flip_vertically = ... && texture->is_framebuffer();

I thought that would cause the content to end up "flipped" vertically if we render to multiple framebuffers an odd number of times:

// ping pong a few times between framebuffer textures, flipping the texture on each render
{
batch.tex(buffer->texture(0), Blah::Vec2f::zero, Color::white);
batch.render(buffer2); // the texture is flipped once here (DOWN)
batch.clear();
}
{
batch.tex(buffer2->texture(0), Blah::Vec2f::zero, Color::white);
batch.render(buffer); // then again (UP)
batch.clear();
}

// render to screen
batch.tex(buffer->texture(0), Vec2f::zero, Color::white);
batch.render(App::backbuffer()); // here again (DOWN)
batch.clear();

It works as expected in 'blah' though. And I can't figure out why that is. There's definitely something I'm missing

Vec3 / operation undefined

Mat4x4f::create_lookat is trying to normalize a Vec3.
error C2676: binary '/': 'Blah::Vec3' does not define this operator or a conversion to a type acceptable to the predefined operator
I did this in the
template
Vec3 Vec3::normal() const {
// return Vec3(x, y, z) / length();
return Vec3(x / length(), y / length(), z / length()) ;
}

Was upgrade to new SDL2 version difficult?

Just curious about what you had to change for the upgrade overall? The diff for your commit is really huge and a bit hard to read, so wanted to just ask here if that's ok!

Mouse difference

Hi, I think it would be nice to have something like Input::mouse_diff() that gives the latest change to the mouse coordinates. I'm currently using something like this to move around my camera around world space but I think it could useful elsewhere.

Texture/Samplers use incorrect register slots

In D3D11 you can specify which registers textures/samplers get bound to, but the Material API (and in turn, what ends up getting rendered) assumes their order is their register, which is incorrect, especially since you can skip registers in HLSL. (Which can happen if, for example, the texture at register 0 is unused, and the HLSL compiler strips it out).

Should be a pretty trivial fix, just need to use the D3D11_SHADER_INPUT_BIND_DESC BindPoint variable and use that. Will need to refactor how Materials work a little bit, and make sure the behavior is the same in OpenGL. Will get to this sometime next week.

Random module

Hi,
Any plans on adding noise/random sampling to this library?

Blah with OpenGL not working on Windows 10

so i tried out the sample application from the readme and it ran fine with D3D11. but when i tried to run it with OpenGL, it just doesn't work. this is the output i get (btw i'm on CLion):

OpenGL 3.3.0 NVIDIA 528.49, NVIDIA GeForce GTX 1050/PCIe/SSE2

Process finished with exit code -1073740791 (0xC0000409)

i've tried everything from updating my nvidia drivers, updating my windows and i also tried to run it on my laptop which is also on windows 10 but every time i just get that message and nothing happens.

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.