1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
4
<title>Castle Game Engine: CastleBitmapFonts: packed record TBitmapChar</title>
5
<meta name="generator" content="PasDoc 0.12.1">
6
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
7
<link rel="StyleSheet" type="text/css" href="pasdoc.css">
10
<table class="container"><tr><td class="navigation">
11
<h2>Castle Game Engine</h2><p><a href="introduction.html" class="navigation">Introduction</a></p><p><a href="AllUnits.html" class="navigation">Units</a></p><p><a href="ClassHierarchy.html" class="navigation">Class Hierarchy</a></p><p><a href="AllClasses.html" class="navigation">Classes, Interfaces, Objects and Records</a></p><p><a href="AllTypes.html" class="navigation">Types</a></p><p><a href="AllVariables.html" class="navigation">Variables</a></p><p><a href="AllConstants.html" class="navigation">Constants</a></p><p><a href="AllFunctions.html" class="navigation">Functions and Procedures</a></p><p><a href="AllIdentifiers.html" class="navigation">Identifiers</a></p></td><td class="content">
12
<a name="TBitmapChar"></a><h1 class="cio">packed record TBitmapChar</h1>
13
<table class="sections wide_list">
15
<td><a class="section" href="#PasDoc-Description">Description</a></td><td>Hierarchy</td><td><a class="section" href="#PasDoc-Fields">Fields</a></td><td>Methods</td><td>Properties</td></tr></table>
16
<a name="PasDoc-Description"></a><h2 class="unit">Unit</h2>
18
<a href="CastleBitmapFonts.html">CastleBitmapFonts</a></p>
19
<h2 class="declaration">Declaration</h2>
20
<p class="declaration">
21
<code>type TBitmapChar = packed record</code></p>
22
<h2 class="description">Description</h2>
24
<code>TBitmapChar</code> record defines the bitmap character. <code>TBitmapChar</code> will not be directly used as a type of some variable. Instead, we use it only to define <a class="normal" href="CastleBitmapFonts.html#PBitmapChar">PBitmapChar</a>.
26
<p>Sample character may look like this :
30
<pre class="longcode">
31
CharX = <span class="pascal_keyword">record</span>
33
Data: <span class="pascal_keyword">packed</span> <span class="pascal_keyword">array</span>[<span class="pascal_numeric">0</span>..23]<span class="pascal_keyword">of</span> byte;
34
<span class="pascal_keyword">end</span> =
35
( Info : ( Alignment : <span class="pascal_numeric">2</span>;
36
XOrig : <span class="pascal_numeric">0</span>; YOrig : <span class="pascal_numeric">0</span>;
37
XMove : <span class="pascal_numeric">10</span>; YMove : <span class="pascal_numeric">0</span>;
38
Width : <span class="pascal_numeric">8</span>; Height : <span class="pascal_numeric">12</span> );
39
Data : (<span class="pascal_hex">$AA</span>, <span class="pascal_hex">$00</span>,
40
<span class="pascal_hex">$BB</span>, <span class="pascal_hex">$00</span>,
41
<span class="pascal_numeric"></span>....
48
<p>Notes about example above: The row has <a class="normal" href="CastleBitmapFonts.TBitmapCharInfo.html#Width">Width</a> = 8 which means that we need only 8 bits (one byte) to store it. But since <a class="normal" href="CastleBitmapFonts.TBitmapCharInfo.html#Alignment">Alignment</a> = 2, we need to use some multiply of 2 bytes to store a row, which means that each row actually uses 2 bytes (even though the contents of 2nd byte are always meaningless). E.g. if you will pass this data to OpenGL, you should appropriately use <code>glPixelStorei</code>, so that OpenGL knows that data is aligned to 2 bytes, and then 2nd byte of each row will indeed be ignored by OpenGL.
50
<p>Sure, this is rather extreme example, since in this case we're wasting half memory just to get Alignment = 2. Well, this is only an example. Also, Alignment may sometimes give us better speed. E.g. for OpenGL's glBitmap (even though if you will use OpenGL's display list, it will not actually matter that much, since then OpenGL will probably internally convert to the best alignment anyway).
52
<p>Summing the example, we have 2 bytes and 12 rows (<a class="normal" href="CastleBitmapFonts.TBitmapCharInfo.html#Height">Height</a> = 2) so we need 24 bytes to store this character.
54
<p>The precise formula to calculate how many bytes are used to store a character is
58
<ul class="paragraph_spacing">
59
<li><p> <code>RoundUpToMultiple( (Char.Info.Width + 7) div 8, Char.Info.Alignment ) * Char.Info.Height</code> </p></li>
60
<li><p> Or, more readable, <code> <a class="normal" href="CastleBitmapFonts.html#BitmapCharRowByteLength">BitmapCharRowByteLength</a>(Char.Info.Width, Char.Info.Alignment) * Char.Info.Height </code> </p></li>
61
<li><p> Or, even more readable, just <code> <a class="normal" href="CastleBitmapFonts.html#BitmapCharRowByteLength">BitmapCharRowByteLength</a>(Char) * Char.Info.Height</code> </p></li>
66
<p>Rows are specified in <a class="normal" href="CastleBitmapFonts.TBitmapChar.html#Data">Data</a> from lower to upper (just like OpenGL's <code>glBitmap</code> likes).
68
<p>Note that this is <i>packed</i> record so I'm sure that
72
<pre class="longcode">
73
SizeOf(<span class="pascal_keyword">record</span>
74
Info: TBitmapCharInfo;
75
Data: <span class="pascal_keyword">packed</span> <span class="pascal_keyword">array</span>[<span class="pascal_numeric">0</span>..n]<span class="pascal_keyword">of</span> byte;
76
) = SizeOf(TBitmapCharInfo) + (n+<span class="pascal_numeric">1</span>) * SizeOf(Byte)
81
<p>I.e. there's no padding between Info and Data.</p>
82
<h2 class="overview">Overview</h2>
83
<a name="PasDoc-Fields"></a><h3 class="summary">Fields</h3>
84
<table class="summary wide_list">
86
<td class="itemcode"><code><b><a href="CastleBitmapFonts.TBitmapChar.html#Info">Info</a></b>: <a href="CastleBitmapFonts.TBitmapCharInfo.html">TBitmapCharInfo</a>;</code></td>
89
<td class="itemcode"><code><b><a href="CastleBitmapFonts.TBitmapChar.html#Data">Data</a></b>: packed[0 .. MaxInt - 1 - SizeOf(<a href="CastleBitmapFonts.TBitmapCharInfo.html">TBitmapCharInfo</a>)]of byte;</code></td>
92
<h2 class="description">Description</h2>
93
<h3 class="detail">Fields</h3>
94
<table class="detail wide_list">
96
<td class="itemcode"><a name="Info"></a><code><b>Info</b>: <a href="CastleBitmapFonts.TBitmapCharInfo.html">TBitmapCharInfo</a>;</code></td>
101
<table class="detail wide_list">
103
<td class="itemcode"><a name="Data"></a><code><b>Data</b>: packed[0 .. MaxInt - 1 - SizeOf(<a href="CastleBitmapFonts.TBitmapCharInfo.html">TBitmapCharInfo</a>)]of byte;</code></td>
108
<hr noshade size="1"><span class="appinfo"><em>Generated by <a href="http://pasdoc.sourceforge.net/">PasDoc 0.12.1</a> on 2013-02-04 20:26:49</em>
110
</td></tr></table></body></html>