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

Reimplement fade effects outside of GraphicsDriver classes #2223

Merged

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Nov 12, 2023

This is for #1349 (one of the preliminary steps), but also a proper thing to do.

Targets ags3, but I may redo in ags4 too. In theory it would be nice to have #1349 done in ags3, because that impacts Emscripten performance (according to @ericoporto ), but completing it will take a while. This is just a first step.

If done for ags3, I'd postpone merging this until after 3.6.1 is released anyway, for safety.

In this PR:

  • Reimplemented each effect in screen.cpp, with a set of screen_effect_*() functions as transition "interface". Bring them to certain level of consistency in how they render and update frame.
  • Removed FadeIn(), FadeOut() and BoxOutEffect() methods from IGraphicsDriver, and respective implementations.
  • Removed redundant callbacks from gfx drivers.
  • Mark GameState.no_hicolor_fadein flag as deprecated, as it's purely an optimization, and should perhaps be a part of engine config rather than a part of script API.
  • Implemented Render(to_texture) and GetCopyOfScreenIntoDDB methods for graphics drivers.

PS. Reimplementing transition effects is done as one big commit, but these functions are purely graphic animation which has no effect on game logic (sans setting screen_is_faded_out flag), so I think it's okay to do in a batch.

@ivan-mogilko ivan-mogilko added context: code fixing/improving existing code: refactor, optimise, tidy... context: game logic labels Nov 12, 2023
@ericoporto
Copy link
Member

This specifically has and additional benefit of reducing the amount of things in the graphics driver - say a new graphic driver is written for Metal, Vulkan, or for an accelerated SDL renderer, this is one less thing to implement.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Nov 18, 2023

While testing this found and fixed several cases in the "render target" feature which was introduced for GUI in 3.6.0.
Turned out it never had fully correct logic, but worked in the existing circumstances.

These should be applied to 3.6.1 regardless of this pr.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Dec 15, 2023

A note to self, following need to be changed:

  • for fadeout create screenshot by asking graphics renderer to redraw last frame (using a copy of data they have);
    it would be also nice to have an option to redraw only particular batches, if they would have IDs or names.
  • add new Render method which accepts render target texture as an argument, and draws without calling Present.

@ivan-mogilko ivan-mogilko force-pushed the 362--gameloopunwind branch 6 times, most recently from c9cde61 to a57d593 Compare January 18, 2024 01:14
@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jan 18, 2024

In general, this is done and may be tested (I will convert from draft when 3.6.1 is fixed in a separate release branch).

Had to do some changes to OpenGL and Direct3D classes, necessary for implementing rendering whole game on a any arbitrary texture. That also simplified code in few places.

For example, I removed "native-res buffer" creation and deletion from D3D/OGL driver classes and replaced that with a common DDB object, because there's a function for creating a texture for rendering on it since 3.6.0.

Reimplemented each effect in screen.cpp, with a set of screen_effect_*() functions as transition "interface". Bring them to certain level of consistency in how they render and update frame.
Removed FadeIn(), FadeOut() and BoxOutEffect() methods from IGraphicsDriver, and respective implementations.
Removed redundant callbacks from gfx drivers.
Mark GameState.no_hicolor_fadein flag as deprecated, as it's purely an optimization, and should perhaps be a part of engine config rather than a part of script API.
Use existing DDB class to work with native render target.
@ivan-mogilko ivan-mogilko marked this pull request as ready for review February 12, 2024 21:07
@ivan-mogilko ivan-mogilko merged commit ad2adc8 into adventuregamestudio:master Feb 13, 2024
20 checks passed
@ivan-mogilko ivan-mogilko deleted the 362--gameloopunwind branch February 13, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: code fixing/improving existing code: refactor, optimise, tidy... context: game logic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants