Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Low prio] Offscreen drawing in a bitmap #43

Open
ivmarkov opened this issue May 17, 2021 · 3 comments
Open

[Low prio] Offscreen drawing in a bitmap #43

ivmarkov opened this issue May 17, 2021 · 3 comments
Assignees

Comments

@ivmarkov
Copy link

Given that HAGL is essentially a software rasterizer (with an option to delegate a few things to the HAL below), I'm a bit surprised that bitmap_t is missing all the draw* and fill* methods that you've done for the "main" HAGL surface. The only difference between the bitmap variants and the regular ones is that in the bitmap variants you need a bitmap version of hagl_get_pixel and hagl_put_pixel. Which would be good to have anyway.

Treating bitmap_t as a valid offscreen drawing surface might allow you to fold back into the main HAGL project the "double" and "triple" buffering complexity, which (IMO) would reduce the complexity of the "driver" code.

@tuupola
Copy link
Owner

tuupola commented May 17, 2021

Do you mean that all primitive drawing functions should require a context where to draw? For example instead of:

 hagl_put_pixel(x0, y0, color);

one should provide the bitmap_t to draw to:

 hagl_put_pixel(bitmap, x0, y0, color);

@ivmarkov
Copy link
Author

That might be one option - the introduction of the notion of an abstract 'drawing surface' is often what e.g. other toolkits do. Some of these even differentiate between a 'surface' (where you render) vs 'context' (= surface + any state like current colors and font).

A completely different approach is implemented here, where the 2D primitives (line, circle, rectangle, text, etc.) are viewed as top-level objects which render themselves by producing an iterator over a range of points. Might be particularly useful for the embedded space indeed.

The other, 'backward compatibility' option would be to just introduce a bunch of bitmap_* functions. At the expense of less abstraction in the API, i.e. you cannot abstract higher-level rendering functions over what surface they render. Your call, I guess...

@tuupola
Copy link
Owner

tuupola commented Aug 27, 2021

The more I think of it including a pointer to surface or context in the function calls would solve many problems. I remember I originally decided against it because I thought would make the function calls unnecessary complex. Live and learn...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants