1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created by texi2html 1.64 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
-->
<HTML>
<HEAD>
<TITLE>Crystal Space: TutIntro Basic Concepts</TITLE>
<META NAME="description" CONTENT="Crystal Space: TutIntro Basic Concepts">
<META NAME="keywords" CONTENT="Crystal Space: TutIntro Basic Concepts">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64">
</HEAD>
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<A NAME="SEC159"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_70.html#SEC158"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_72.html#SEC170"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_69.html#SEC157"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_70.html#SEC158"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_73.html#SEC171"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<HR SIZE=1>
<H3> 5.1.1 Basic Crystal Space Concepts </H3>
<!--docid::SEC159::-->
<P>
In order to write a Crystal Space application there are several concepts
that you need to know about. Here we will give a quick overview of all
important things you need to know about when writing Crystal Space
applications.
</P><P>
<A NAME="SEC160"></A>
<H4> The SCF Facility </H4>
<!--docid::SEC160::-->
<P>
The SCF (see section <A HREF="cs_134.html#SEC297">6.4 Shared Class Facility (SCF)</A>) system is the core low-level memory framework
for Crystal Space. You must initialize this before doing anything else
(one way is to use <CODE>csInitializer::InitializeSCF()</CODE>).
</P><P>
<A NAME="SEC161"></A>
<H4> Reference Counting </H4>
<!--docid::SEC161::-->
<P>
Reference counting is a very important part of the Crystal Space
framework. Read the SCF (see section <A HREF="cs_134.html#SEC297">6.4 Shared Class Facility (SCF)</A>) documentation for more information
about this but keep in mind that it is very important and try to make
sure you manage references correctly in your own code. Missing a
<CODE>DecRef()</CODE> can cause big memory leaks.
</P><P>
<A NAME="SEC162"></A>
<H4> The Object Registry </H4>
<!--docid::SEC162::-->
<P>
The object registry is the central repository for all objects in
Crystal Space. Everything in Crystal Space will use the object registry
to get the pointer to the objects it is interested in. One of the first
tasks a Crystal Space application has to do is to create the object
registry. You can create an object registry using
<CODE>csInitializer::CreateObjectRegistry()</CODE> or
<CODE>csInitializer::CreateEnvironment()</CODE>.
</P><P>
<A NAME="SEC163"></A>
<H4> The Plugin Manager </H4>
<!--docid::SEC163::-->
<P>
The plugin manager is responsible for loading and unloading plugins. A
plugin is a shared library of functions that can be loaded dynamically
into a running Crystal Space application. On Unix a plugin has the `<TT>.so</TT>'
extension and on Windows the `<TT>.dll</TT>' extension is used. Almost everything
in the Crystal Space framework is itself a plugin. So the plugin manager
is an important object. You can create the plugin manager with
<CODE>csInitializer::CreatePluginManager()</CODE> or
<CODE>csInitializer::CreateEnvironment()</CODE>.
</P><P>
<A NAME="SEC164"></A>
<H4> The Event Queue </H4>
<!--docid::SEC164::-->
<P>
Crystal Space is an event-driven framework. So a Crystal Space application
will also be event driven. The event queue manages the event system and
sends events to listeners. Every module or plugin that implements
<CODE>iEventHandler</CODE> can register itself with the event queue so it gets
notified when certain events happen. You can create the event queue
with <CODE>csInitializer::CreateEventQueue()</CODE> or
<CODE>csInitializer::CreateEnvironment()</CODE>.
</P><P>
A Crystal Space application will also have to create an event handler
on its own in order to actually be able to do something. This event handler
will be responsible for actually rendering to the screen (this has to be
done in response to the <CODE>cscmdProcess</CODE> event) and also catching
keyboard/mouse input. But there is much more. To setup an event handler
for the application you can use <CODE>csInitializer::SetupEventHandler()</CODE>.
</P><P>
<A NAME="SEC165"></A>
<H4> The Virtual Clock </H4>
<!--docid::SEC165::-->
<P>
Most Crystal Space applications will be time-based. The virtual clock
supports the notion of CURRENT TIME and ELAPSED TIME. It is
called a virtual clock because it doesn't necessarily have to correspond
with real time. A game can be paused for example. Note that a well-behaved
game should always take elapsed time (between two frames) into consideration
for calculating what could have happened in that time. This is important
especially for physics calculations and also for speed of moving objects.
You want an object moving at some speed to move with the same speed on a
system with low framerates compared to a system with high framerates.
The virtual clock can be created with
<CODE>csInitializer::CreateVirtualClock()</CODE> or
<CODE>csInitializer::CreateEnvironment()</CODE>.
</P><P>
<A NAME="SEC166"></A>
<H4> The Commandline Parser </H4>
<!--docid::SEC166::-->
<P>
The commandline parser is responsible for parsing options from
the commandline. If you properly initialize it with <CODE>argc</CODE> and
<CODE>argv</CODE> then you can use it to query options that have been given
to the commandline. Several Crystal Space plugins and modules will also
query the commandline so it is important to have this object correctly
initialized. The commandline parser can be created with
<CODE>csInitializer::CreateCommandLineParser()</CODE> or
<CODE>csInitializer::CreateEnvironment()</CODE>.
</P><P>
<A NAME="SEC167"></A>
<H4> The Configuration Manager </H4>
<!--docid::SEC167::-->
<P>
The configuration manager is responsible for reading options from configuration
files. All configuration files are put in a global pool which is managed by
the configuration manager. Several Crystal Space plugins and modules will
query options from the configuration manager and Crystal Space applications can
also do that if they want.
</P><P>
You can create the configuration manager with:
</P><P>
<CODE>csInitializer::CreateConfigManager()</CODE><BR>
</P><P>
or
</P><P>
<CODE>csInitializer::CreateEnvironment()</CODE>
</P><P>
You can setup the configuration manager with:
</P><P>
<CODE>csInitializer::SetupConfigManager()</CODE>.
</P><P>
<A NAME="SEC168"></A>
<H4> The Input Drivers </H4>
<!--docid::SEC168::-->
<P>
There are three standard input drivers included with Crystal Space:
keyboard, mouse, and joystick. Calling
</P><P>
<CODE>csInitializer::CreateInputDrivers()</CODE>
</P><P>
or
</P><P>
<CODE>csInitializer::CreateEnvironment()</CODE>
</P><P>
will create the drivers and publish them via the object registry. These
drivers will post events to the global event queue.
</P><P>
<A NAME="SEC169"></A>
<H4> The <CODE>csInitializer</CODE> class </H4>
<!--docid::SEC169::-->
<P>
We already mentioned several of the functions above. This class (for which
the definition can be found in `<TT>include/cstool/initapp.h</TT>') is a
conveniance class that can be used to help you setup everything needed to
get the application running. In the tutorial below we will use several of the
functions from <CODE>csInitializer</CODE>. This class contains only static member
functions.
</P><P>
<A NAME="TutIntro Minimum Requirements"></A>
<HR SIZE=1>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_70.html#SEC158"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_72.html#SEC170"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_69.html#SEC157"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_70.html#SEC158"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_73.html#SEC171"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
</BODY>
</HTML>
|