~ubuntu-branches/ubuntu/utopic/castle-game-engine/utopic

« back to all changes in this revision

Viewing changes to doc/pasdoc/html/CastleBitmapFonts.TBitmapChar.html

  • Committer: Package Import Robot
  • Author(s): Abou Al Montacir
  • Date: 2013-04-27 18:06:40 UTC
  • Revision ID: package-import@ubuntu.com-20130427180640-eink4nmwzuivez1c
Tags: upstream-4.0.1
ImportĀ upstreamĀ versionĀ 4.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
 
2
<html>
 
3
<head>
 
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">
 
8
</head>
 
9
<body>
 
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">
 
14
<tr>
 
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>
 
17
<p class="unitlink">
 
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>
 
23
<p>
 
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>.
 
25
 
 
26
<p>Sample character may look like this :
 
27
 
 
28
<p></p>
 
29
 
 
30
<pre class="longcode">
 
31
      CharX = <span class="pascal_keyword">record</span>
 
32
        Info: TBitmapCharInfo
 
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>....
 
42
               );
 
43
      );
 
44
    </pre>
 
45
 
 
46
<p>
 
47
 
 
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.
 
49
 
 
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).
 
51
 
 
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.
 
53
 
 
54
<p>The precise formula to calculate how many bytes are used to store a character is
 
55
 
 
56
<p></p>
 
57
 
 
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>
 
62
</ul>
 
63
 
 
64
<p>
 
65
 
 
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).
 
67
 
 
68
<p>Note that this is <i>packed</i> record so I'm sure that
 
69
 
 
70
<p></p>
 
71
 
 
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)
 
77
    </pre>
 
78
 
 
79
<p>
 
80
 
 
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">
 
85
<tr class="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>
 
87
</tr>
 
88
<tr class="list2">
 
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>
 
90
</tr>
 
91
</table>
 
92
<h2 class="description">Description</h2>
 
93
<h3 class="detail">Fields</h3>
 
94
<table class="detail wide_list">
 
95
<tr class="list">
 
96
<td class="itemcode"><a name="Info"></a><code><b>Info</b>: <a  href="CastleBitmapFonts.TBitmapCharInfo.html">TBitmapCharInfo</a>;</code></td>
 
97
</tr>
 
98
<tr><td colspan="1">
 
99
&nbsp;</td></tr>
 
100
</table>
 
101
<table class="detail wide_list">
 
102
<tr class="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>
 
104
</tr>
 
105
<tr><td colspan="1">
 
106
&nbsp;</td></tr>
 
107
</table>
 
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>
 
109
</span>
 
110
</td></tr></table></body></html>