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

Text rendering redesign #216

Merged
merged 82 commits into from
Jul 1, 2021
Merged

Text rendering redesign #216

merged 82 commits into from
Jul 1, 2021

Conversation

afritz1
Copy link
Owner

@afritz1 afritz1 commented Jul 1, 2021

TextRenderUtils adds several tools for determining texture size of a text box and drawing text to a buffer.

TextBox and ListBox are now much more convenient and versatile. They have been switched to a dirty boolean pattern so they only attempt to re-draw their underlying texture when it is about to be rendered on-screen. The limitation of having to allocate them on the heap has been removed as well.

Additional text alignment options were also added to support various cases like the orange trigger text in the game world being aligned to the bottom of its text box.

Future work would include changing the on-screen position to vector space and decoupling geometry dimensions from texture dimensions so that high-resolution fonts can be used.

Preparing some utils functions to be used by TextBox and ListBox so they can be decoupled and better-designed.
Separated ListBox construction from initialization so it doesn't need to be in a unique_ptr anymore. Also started using "Rect + Properties" pattern for list box initialization arguments. ListBox is currently rendering a black box, probably need to call updateTexture().
Doesn't necessarily match the original game exactly but it's better now.
Added dirty boolean so the texture can be conditionally updated right before it's rendered.
Tried another way with updateTexture() being private but I like getTexture() being intuitive and not requiring any parameters.
Not the best solution but it works for now.
Still off by one pixel in the player inventory rendering when scrolled to the bottom but maybe that's just from float->int truncation somewhere.
Unable to test due to hundreds of compile errors.
This allows text to be drawn onto color buffers with existing background colors like tooltips.
A std::string&& would be more efficient but text shouldn't be changing frequently enough for it to matter.
Likely going to be used in UiView namespaces where the dimensions of a text box should be known at text box construction time.
Able to compile again.
It was a good convenience at the time but it has been superseded by better TextBox initialization patterns like InitInfo.
The text box might need to redraw itself in getTexture(), so it has to be non-const. Also added FontLibrary pointer for ease of redrawing the underlying texture. I guess it's okay to store a pointer to a singleton?
Also added TextRenderUtils::drawTextLines() for better code reuse.
Still just estimates but they should be plenty.
Wasn't able to make each font name a std::string due to global initialization order issues with all the UiView namespaces that reference them.
Only need them to stretch to the left and right edges of the screen in the worst case.
It always clamps either the foreground or shadow position non-negative so that the rendering starts at the dstX/Y position.
Need to add more text alignments so the trigger text is anchored to the bottom of its text box.
@afritz1 afritz1 added this to the 0.14.0 milestone Jul 1, 2021
@afritz1 afritz1 merged commit f040b1d into master Jul 1, 2021
@afritz1 afritz1 deleted the text-rendering-redesign branch July 1, 2021 23:59
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

Successfully merging this pull request may close these issues.

1 participant