0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 12:33:43 +00:00
SDL_Minigame/classTextureManager.html

312 lines
18 KiB
HTML

<!-- HTML header for doxygen 1.10.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=11" />
<meta name="generator" content="Doxygen 1.13.2" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>VEGO-Engine: TextureManager Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="doxygen-awesome-fragment-copy-button.js"></script>
<script type="text/javascript">
DoxygenAwesomeFragmentCopyButton.init()
</script>
<script type="text/javascript" src="doxygen-awesome-paragraph-link.js"></script>
<script type="text/javascript">
DoxygenAwesomeParagraphLink.init()
</script>
<script type="text/javascript" src="doxygen-awesome-interactive-toc.js"></script>
<script type="text/javascript">
DoxygenAwesomeInteractiveToc.init()
</script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only-darkmode-toggle.css" rel="stylesheet" type="text/css"/>
<link href="custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top">
<!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">VEGO-Engine
<span id="projectnumber">&#160;0.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('classTextureManager.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="classTextureManager-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">TextureManager Class Reference</div></div>
</div><!--header-->
<div class="contents">
<p>A manager for loading, caching, and drawing textures.
<a href="#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="TextureManager_8h_source.html">TextureManager.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ad3be4563a8829983a69870a83e2e0b8e" id="r_ad3be4563a8829983a69870a83e2e0b8e"><td class="memItemLeft" align="right" valign="top"><a id="ad3be4563a8829983a69870a83e2e0b8e" name="ad3be4563a8829983a69870a83e2e0b8e"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>TextureManager</b> (<a class="el" href="classManager.html">Manager</a> *manager)</td></tr>
<tr class="separator:ad3be4563a8829983a69870a83e2e0b8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab8a4eb67288539db37552b2c68217bb1" id="r_ab8a4eb67288539db37552b2c68217bb1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ab8a4eb67288539db37552b2c68217bb1">addSingleTexture</a> (<a class="el" href="classTextures.html">Textures</a> texture, const char *filePath)</td></tr>
<tr class="memdesc:ab8a4eb67288539db37552b2c68217bb1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Adds a single texture to the cache. <br /></td></tr>
<tr class="separator:ab8a4eb67288539db37552b2c68217bb1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8090211c196974905fd8a907829930f2" id="r_a8090211c196974905fd8a907829930f2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8090211c196974905fd8a907829930f2">addTextures</a> (const std::map&lt; <a class="el" href="classTextures.html">Textures</a>, const char * &gt; &amp;textures)</td></tr>
<tr class="memdesc:a8090211c196974905fd8a907829930f2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Adds multiple textures to the cache. <br /></td></tr>
<tr class="separator:a8090211c196974905fd8a907829930f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3304650a6b7304dbaa1afb164ed4c4e8" id="r_a3304650a6b7304dbaa1afb164ed4c4e8"><td class="memItemLeft" align="right" valign="top">SDL_Texture *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a3304650a6b7304dbaa1afb164ed4c4e8">loadTexture</a> (<a class="el" href="classTextures.html">Textures</a> texture)</td></tr>
<tr class="memdesc:a3304650a6b7304dbaa1afb164ed4c4e8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Loads a texture from the cache. <br /></td></tr>
<tr class="separator:a3304650a6b7304dbaa1afb164ed4c4e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afd2ed5b21c33c12d568cb82a5c0adf80" id="r_afd2ed5b21c33c12d568cb82a5c0adf80"><td class="memItemLeft" align="right" valign="top"><a id="afd2ed5b21c33c12d568cb82a5c0adf80" name="afd2ed5b21c33c12d568cb82a5c0adf80"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setScaleMode</b> (SDL_ScaleMode scaleMode)</td></tr>
<tr class="separator:afd2ed5b21c33c12d568cb82a5c0adf80"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac2bf6f97639eee824c45266472430ee0" id="r_ac2bf6f97639eee824c45266472430ee0"><td class="memItemLeft" align="right" valign="top">SDL_Texture *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac2bf6f97639eee824c45266472430ee0">loadMapTileTexture</a> (const char *path)</td></tr>
<tr class="memdesc:ac2bf6f97639eee824c45266472430ee0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Loads a map tile texture from the file system and caches it. <br /></td></tr>
<tr class="separator:ac2bf6f97639eee824c45266472430ee0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a849a1a5271fff7a4109b6bd9f156631f" id="r_a849a1a5271fff7a4109b6bd9f156631f"><td class="memItemLeft" align="right" valign="top"><a id="a849a1a5271fff7a4109b6bd9f156631f" name="a849a1a5271fff7a4109b6bd9f156631f"></a>
std::string&#160;</td><td class="memItemRight" valign="bottom"><b>getTexturePath</b> (<a class="el" href="classTextures.html">Textures</a> texture)</td></tr>
<tr class="separator:a849a1a5271fff7a4109b6bd9f156631f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-static-methods" name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:ade289eda2f6b9a25468470f6b959cf91" id="r_ade289eda2f6b9a25468470f6b959cf91"><td class="memItemLeft" align="right" valign="top"><a id="ade289eda2f6b9a25468470f6b959cf91" name="ade289eda2f6b9a25468470f6b959cf91"></a>
static std::vector&lt; SDL_Rect &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>splitSpriteSheet</b> (SDL_Texture *spriteSheet, int width, int height, int spritesOnSheet)</td></tr>
<tr class="separator:ade289eda2f6b9a25468470f6b959cf91"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac11591a33c57e86aa13aaf1c449cb33f" id="r_ac11591a33c57e86aa13aaf1c449cb33f"><td class="memItemLeft" align="right" valign="top"><a id="ac11591a33c57e86aa13aaf1c449cb33f" name="ac11591a33c57e86aa13aaf1c449cb33f"></a>
static void&#160;</td><td class="memItemRight" valign="bottom"><b>draw</b> (SDL_Renderer *renderer, SDL_Texture *texture, SDL_FRect src, SDL_FRect dest, bool flipped=false)</td></tr>
<tr class="separator:ac11591a33c57e86aa13aaf1c449cb33f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A manager for loading, caching, and drawing textures. </p>
<p>The <code><a class="el" href="classTextureManager.html" title="A manager for loading, caching, and drawing textures.">TextureManager</a></code> class is responsible for handling texture loading, caching, and rendering in the engine. It provides functions to add, load, and draw textures from files, as well as manage sprite sheets.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classTextures.html" title="Forward declaration of the Textures enum class.">Textures</a> are used to identify textures within the engine. It is expected that they are implemented within the games scope. </dd></dl>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="ab8a4eb67288539db37552b2c68217bb1" name="ab8a4eb67288539db37552b2c68217bb1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab8a4eb67288539db37552b2c68217bb1">&#9670;&#160;</a></span>addSingleTexture()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void TextureManager::addSingleTexture </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classTextures.html">Textures</a></td> <td class="paramname"><span class="paramname"><em>texture</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *</td> <td class="paramname"><span class="paramname"><em>filePath</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Adds a single texture to the cache. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">texture</td><td>The texture identifier. </td></tr>
<tr><td class="paramname">filePath</td><td>The file path to the texture file. </td></tr>
</table>
</dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname">std::runtime_error</td><td>Is thrown if the texture could not be loaded correctly</td></tr>
</table>
</dd>
</dl>
<p>This function loads the texture from the specified file and stores it in a cache. </p>
</div>
</div>
<a id="a8090211c196974905fd8a907829930f2" name="a8090211c196974905fd8a907829930f2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8090211c196974905fd8a907829930f2">&#9670;&#160;</a></span>addTextures()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void TextureManager::addTextures </td>
<td>(</td>
<td class="paramtype">const std::map&lt; <a class="el" href="classTextures.html">Textures</a>, const char * &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>textures</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Adds multiple textures to the cache. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">textures</td><td>A map of texture identifiers and corresponding file paths.</td></tr>
</table>
</dd>
</dl>
<p>This function iterates over the provided map of textures and loads each texture using <code>addSingleTexture</code>. It allows for several textures to be added at once. </p>
</div>
</div>
<a id="ac2bf6f97639eee824c45266472430ee0" name="ac2bf6f97639eee824c45266472430ee0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac2bf6f97639eee824c45266472430ee0">&#9670;&#160;</a></span>loadMapTileTexture()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SDL_Texture * TextureManager::loadMapTileTexture </td>
<td>(</td>
<td class="paramtype">const char *</td> <td class="paramname"><span class="paramname"><em>path</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Loads a map tile texture from the file system and caches it. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">path</td><td>The file path to the texture. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>SDL_Texture*</code> representing the map tile. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname">std::runtime_error</td><td>Is thrown if the texture could not be loaded correctly</td></tr>
</table>
</dd>
</dl>
<p>This function checks if the map tile texture is already cached. If not, it loads the texture from the file system and stores it in the cache.</p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000009">Todo</a></b></dt><dd>should not be usable for the developer and only be accessed by the map class </dd></dl>
</div>
</div>
<a id="a3304650a6b7304dbaa1afb164ed4c4e8" name="a3304650a6b7304dbaa1afb164ed4c4e8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3304650a6b7304dbaa1afb164ed4c4e8">&#9670;&#160;</a></span>loadTexture()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SDL_Texture * TextureManager::loadTexture </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classTextures.html">Textures</a></td> <td class="paramname"><span class="paramname"><em>texture</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Loads a texture from the cache. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">texture</td><td>The texture identifier. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A pointer to the <code>SDL_Texture</code> if found, or <code>nullptr</code> if not found.</dd></dl>
<p>This function looks up a texture within the cache and returns the corresponding <code>SDL_Texture*</code>. If the texture is not found, it logs an error message and returns <code>nullptr</code>. </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>include/<a class="el" href="TextureManager_8h_source.html">TextureManager.h</a></li>
<li>src/<b>TextureManager.cpp</b></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="classTextureManager.html">TextureManager</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </li>
</ul>
</div>
</body>
</html>