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

lib: move compositor to rust #240

Open
caiiiycuk opened this issue Jan 25, 2024 · 1 comment
Open

lib: move compositor to rust #240

caiiiycuk opened this issue Jan 25, 2024 · 1 comment

Comments

@caiiiycuk
Copy link
Contributor

caiiiycuk commented Jan 25, 2024

Hi, here is my proposal for how we can transfer all graphics-related tasks to the render-ng library.

  1. We need to change rv_init to accept a window context handle (provided by SDL; we can provide something from SDL_SysWMinfo). Like this:
struct rv_init_descriptor {
	uint32_t width;
	uint32_t height;
	const char* render_config;
	void* handle; // <----- native window handle
};

rv_context rv_init(rv_init_descriptor desc);
  1. The function to render RGBA data in window coordinates (using the same coordinates as those used for rv_resize):
rv_render_rgba(const rv_rect& dest, uint32_t width, uint32_t height, uint8_t *rgba);

We also use 'texture coloring' (as in FragColor = texture(tex, uv) * color). While it's not mandatory, please add color as the last optional parameter if possible.

rv_render_rgba(const rv_rect& dest, uint32_t width, uint32_t height, uint8_t *rgba, uint32_t *color = nullptr);

The blend function is always the same: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  1. lifecycle function:
enum Stage {
   LAYER_3D,
   LAYER_2D,
   PRESENT
}

rv_stage(Stage stage);
  • LAYER_2D is called just before we start using rv_render_rgba. Here, you can set the blend function, viewport, etc.
  • PRESENT marks the end of a frame, where we actually render to the frame.
  • LAYER_3D is called immediately after PRESENT. Here you can reset the color buffer, etc.
  1. Optiononal function that sets clear color (we want to change bg of the game window):
void rv_clear_color(uint32_t color)

P.S. Feel free to change the naming/declarations as you see fit.

@caiiiycuk
Copy link
Contributor Author

It is very important to not break android version. Not sure if rust can create context on android device, so if possible let's keep fallback path of rv_init using glfunctor.

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

1 participant