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

Add support for cross-platform fallback API to show a prerendered image #2528

Open
milasudril opened this issue Apr 7, 2024 · 0 comments
Open

Comments

@milasudril
Copy link

milasudril commented Apr 7, 2024

I close #2174 with a better idea: Expose a cross-platform API that can push an image to a window without having a working hardware-accelerated context.

#2174 explicitly suggested cross-platform support for creating a cairo context that could be used as a fallback to display an error message. For the single-purpose of error handling, it is probably not ideal to add a dependency to cairo. If you want ot use cairo for rendering of 2d graphics you can as mentioned in #2174, render to a memory surface, and then display the image. However, in my case, there is no way to display it.

The suggestion is to add the following API:

/**
This function displays `image` on `window`, with its upper-left corner located at (`origin_x`, `origin_y`).

The image data is organized similarly to `glfwCreateCursor`, but the alpha channel is ignored.

Any existing content of window is overwritten, without any blending. To clear the window, this function
can be called with image pointing to data that should be used as background.

This function can only be called if there is no rendering context associated with the window
*/
void glfwDisplayImage(GLFWwindow* window, int origin_x, int origin_y, struct GLFWimage const* image);

The issue of initial error handling has been brought up on the discourse:

https://discourse.glfw.org/t/adding-platform-independant-error-boxes/386

The idea was to wrap a MessageBox-style API. However, I think it is more flexible to let the user render the message (obviously using a software renderer, since there is no hardware render at this point), and display the result.

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