We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4806 - Question: Can I draw something with software render over OpenGL surface?
Summary: Question: Can I draw something with software render over OpenGL surface?
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.1
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-19 13:16 UTC by Vitaly Novichkov
Modified: 2020-03-23 03:34 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vitaly Novichkov 2019-09-19 13:16:37 UTC
I have a problem:
- I using OpenGL directly by raw calls (not via SDL's render API which I use as a fallback only).
- I want to draw some sort of "loading" animation.
- At the same time, while loading process, I loading new textures into OpenGL.
- OpenGL is known that it can't be used in multiple threads safely.
- Because of that, I can't load new textures in background and at the same time draw anything on OpenGL context. Therefore, while loading, I draw nothing, just black screen and the stuck of the window until the loading process will complete.

The question: How I can draw anything on the window by using software render to don't disturb OpenGL and let it receive all necessary textures?
Comment 1 Ryan C. Gordon 2020-03-23 03:34:52 UTC
So some options for this:

- Load the textures you need for the loading screen first and then use them while loading everything else. Load some amount of the total textures per frame, perhaps drawing the loading screen and swapping buffers every ~33 milliseconds ( about 30fps) if you're animating something (less if not), regardless of how much you managed to load that frame.

- Create a second GL context on your loading thread, and mark it as "shared" with the main context, so they both use the same textures. After loading is done, optionally delete the second context (or keep it around for future loading). All actual drawing happens in the main context.

You can't do any software rendering, though. This isn't an SDL restriction, it's an OpenGL one. The closest you could get is uploading pixels you generated yourself in memory to a texture...and then you're in the same position.

--ryan.