📄 main_hints.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- http://hge.relishgames.com -->
<html>
<head>
<meta name="Keywords" content="game engine, 2d, hardware accelerated, hge, engine, relish games, game development">
<meta name="Description" content="Haaf's Game Engine - Hardware accelerated 2D games engine">
<title>Haaf's Game Engine - Hardware accelerated 2D games engine</title>
<link rel=stylesheet type=text/css href=hge.css>
<script language="JavaScript" src="hge.js"></script>
</head>
<body onload="setContents('cnt_main.html');" bgcolor=#ffffff text=#000000 link=#7F0000 vlink=#7F0000 alink=#7F0000 marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>
<table height=100% cellspacing=0 cellpadding=0 border=0><tr>
<td valign=top>
<table width=566 cellspacing=0 cellpadding=20 border=0><tr><td>
<h1 style="margin-top:0px">Hints & Tips</h1>
<h2>Video cards support</h2>
<p>
<b>HGE</b> will run even on low-end video cards, including built in video cards
such as <b>Intel Solano</b> (i815 chipset).
</p>
<h2>Exact texel to pixel rendering</h2>
<p>
<b>DirectX</b> treats texture coordinates relative to the top-left
corner of a texel, and it treats screen coordinates relative
to a pixel's center.
So, to render a part of texture to the screen with exact texel
to pixel mapping (without affecting it by interpolation),
just shift all your vertices screen coordinates by -0.5.
</p>
<h2>Quads batching</h2>
<p>
For performance reasons <b>Gfx_RenderQuad</b> accumulates consecutive quads
with the same texture and blending mode and then renders them with a
single call to <b>DirectX</b>.
In most cases you will not see any difference and don't have to deal with this
batching at all. But to be sure and safe it is recommended to group your
<b>Gfx_RenderQuad</b> calls by texture and blending mode.
</p>
<h2>Texture dimensions</h2>
<p>
The dimensions of any texture must be a power of 2. And it is not recommended to use textures bigger than 1024x1024,
because they can be slow and some video cards may have no support for them.
Try to place all your graphics onto several big textures to minimize texture switching that affects performance.
</p>
<h2>Using Z-buffer</h2>
<p>
Use Z-buffer only if you need to, because this affects performance. By default the
Z-buffer is turned off. To turn it on set the <a href="hgeconst_systemstate.html#HGE_ZBUFFER">HGE_ZBUFFER</a> system state
to <b>true</b> with <a href="hgefunc_systemsetstate.html">System_SetState</a> call.
When the Z-buffer is turned on, it is a good idea to sort your rendering in front-to-back
order for better performance.
</p>
<h2>Clearing screen</h2>
<p>
Clear the screen only if you need to, because this affects performance. If you
cover the whole screen with graphics each frame - there is no need to clear.
Although, when using Z-buffer you probably have to clear the screen anyway
to reset it.
</p>
<h2>Scaling and rotation</h2>
<p>
If you plan to scale or rotate your sprite - ensure that the graphics spread at least
for 1 pixel beneath the alpha mask and sprite edges to avoid distortion.
<p>
</p>
<h2>Sprite and tile libraries</h2>
<p>
You can use <a href="hgeanim__main.html">hgeAnimation</a> helper class as a sprite or tile library.
Just don't call the <a href="hgeanim_update.html">Update</a> method and select the needed sprite
manually with the <a href="hgeanim_setframe.html">SetFrame</a> method.
</p>
<h2>Displaying a mouse cursor</h2>
<p>
To display a mouse cursor, render anything you want at the coordinates
returned by <a href="hgefunc_inputgetmousepos.html">Input_GetMousePos</a>
in your frame function.
</p>
<h2>Using external sound routines</h2>
<p>
If you don't want to use <b>BASS</b> for handling sound, and have your own sound routines,
set <a href="hgeconst_systemstate.html#HGE_USESOUND">HGE_USESOUND</a> system state to <b>false</b> with <a href="hgefunc_systemsetstate.html">System_SetState</a>
function before calling <a href="hgefunc_systeminitiate.html">System_Initiate</a>.
</p>
<h2>Managing HGE interface pointer</h2>
<p>
Any time you need access to <b>HGE</b>, you may call the <a href="hgefunc_interfaceget.html">hgeCreate</a>
function, then use the received pointer and release it with <a href="hgefunc_interfacerelease.html">Release</a>.
Or you may get the interface once during startup and store it in a global variable, then release during cleanup.
Although the latter is supposed to be 'bad style', this works fine with not very big projects
and all <b>HGE</b> helper classes use this approach.
</p>
<h2>Float to int conversion</h2>
<p>
If there are a plenty of <b>float</b> to <b>int</b> conversions in your code, you
may use the <b>/QIfist</b> option of <b>Visual C++</b> compiler. With that you can't
be sure of the rounding method being used, but in most cases it doesn't matter and
you'll receive improvement in performance. To activate this option, type it into
<b>Project Options</b> text box in the <b>Project->Settings...->C/C++</b> dialog tab
for debug and release configurations.
</p>
<h2>Speed synchronization</h2>
<p>
To make your game independent of execution speed,
scale all your internal speeds by the value, returned by
<a href="hgefunc_timergetdelta.html">Timer_GetDelta</a>.
If you use acceleration or other non-linear functions,
there still may be a problem: approximation with linear
segments will make different results depending on the
number of segments. To fix this, accumulate the values returned by
<a href="hgefunc_timergetdelta.html">Timer_GetDelta</a>
and update these functions in fixed intervals of time.
</p>
<h2>Resources</h2>
<p>
While developing, you may keep all your data in plain disk files.
Then just compile the resource pack with <b>pkzip</b> and set
<a href="hgeconst_systemstate.html#HGE_RESOURCEFILE">HGE_RESOURCEFILE</a>
system state to it's name. Nothing else need to be modified
in your code to use resource pack. See the
<a href="main_respack.html">Compiling resource pack</a>
section for more information.
</p>
<br>
</td></tr></table>
</td>
</tr></table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -