feat: added single character loading

This commit is contained in:
Krzysztof Rudnicki 2023-09-04 14:12:27 +02:00
parent 3f4bcf3f5b
commit a311ece772

View File

@ -1739,7 +1739,7 @@ void TextRenderer::Load(const std::string &font, unsigned int fontSize)
... ...
\end{lstlisting} \end{lstlisting}
\newapge \newpage
\paragraph{Actual loading and configuration} \paragraph{Actual loading and configuration}
We load the font using freeType, after checking if it was loaded correctly we set size of a single character, disable byte-alignment in order for the text to be rendered correctly, preload first 128 [ASCII] characters and since we already loaded everything we wanted we destroy FreeType library We load the font using freeType, after checking if it was loaded correctly we set size of a single character, disable byte-alignment in order for the text to be rendered correctly, preload first 128 [ASCII] characters and since we already loaded everything we wanted we destroy FreeType library
@ -1788,10 +1788,39 @@ void TextRenderer::Load(const std::string &font, unsigned int fontSize)
\end{tikzpicture} \end{tikzpicture}
\caption{Loading font logic} \caption{Loading font logic}
\label{fig:findingMatches} \label{fig:loadingFont}
\end{figure} \end{figure}
\paragraph{Loading characters}
In order to preload ASCII characters we use a method loadCharacter from TextRenderer, it uses FreeType library to load character, then generates textures for a character (it needs to allign a texture to character), sets options for texture and adds the character object to characters array
\begin{figure}[htp]
\centering
\begin{tikzpicture}[node distance=1.5cm]
\useasboundingbox (-5,0) rectangle (5, -13cm); % Set a custom bounding box
\node (start) [startstop] {Load character};
\node (pro1) [process, below of=start] {Load character using FreeType};
\draw [arrow] (start) -- (pro1);
\node (pro2) [process, below of=pro1] {Generate Texture};
\draw [arrow] (pro1) -- (pro2);
\node (pro3) [process, below of=pro2] {Setup texture options};
\draw [arrow] (pro2) -- (pro3);
\node (pro4) [process, below of=pro3] {Create character instance};
\draw [arrow] (pro3) -- (pro4);
\node (pro5) [process, below of=pro4] {Push character to characters array};
\draw [arrow] (pro4) -- (pro5);
\node (stop) [startstop, below of=pro5] {Finish loading};
\draw [arrow] (pro5) -- (stop);
\end{tikzpicture}
\caption{Loading single character logic}
\label{fig:loadingCharacter}
\end{figure}
\subsection{Dependency Management} \subsection{Dependency Management}
There are several libraries: OpenGL, GLFW, stb\_image and freetype being integrated into engine, they are simply included at the top of any files that need them. There are several libraries: OpenGL, GLFW, stb\_image and freetype being integrated into engine, they are simply included at the top of any files that need them.