Revision: 30437
http://crystal.svn.sourceforge.net/crystal/?rev=30437&view=rev
Author: erluk
Date: 2008-07-18 16:00:28 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
Merged revisions 30422-30436 via svnmerge from
https://crystal.svn.sourceforge.net/svnroot/crystal/CS/trunk
........
r30422 | erluk | 2008-07-18 04:13:38 +0200 (Fr, 18 Jul 2008) | 1 line
- Fix compilation on gcc
........
r30423 | erluk | 2008-07-18 14:55:10 +0200 (Fr, 18 Jul 2008) | 1 line
- Ported pysimp to the current simple1 codebase
........
r30424 | erluk | 2008-07-18 15:03:20 +0200 (Fr, 18 Jul 2008) | 1 line
- Changed pathtut to use the new event system
........
r30425 | erluk | 2008-07-18 15:10:11 +0200 (Fr, 18 Jul 2008) | 1 line
- Changed phystut to use the new event system
........
r30426 | erluk | 2008-07-18 15:25:33 +0200 (Fr, 18 Jul 2008) | 1 line
- Changed simpvs to use the new event system
........
r30427 | erluk | 2008-07-18 16:09:51 +0200 (Fr, 18 Jul 2008) | 1 line
- Updated the simple1 tutorial to more accurately match the current code. Probably needs some proof-reading, though.
........
r30428 | erluk | 2008-07-18 16:12:57 +0200 (Fr, 18 Jul 2008) | 1 line
- Removed the frame sub event test
........
r30429 | erluk | 2008-07-18 16:15:08 +0200 (Fr, 18 Jul 2008) | 1 line
- (Blindly) changed the linux joystick plugin to use the new event system
........
r30430 | erluk | 2008-07-18 16:30:37 +0200 (Fr, 18 Jul 2008) | 2 lines
- Fixed linux joystick plugin compilation
........
r30431 | erluk | 2008-07-18 16:42:21 +0200 (Fr, 18 Jul 2008) | 2 lines
- Changed the xwindow plugin to use the new event system
........
r30432 | erluk | 2008-07-18 16:43:26 +0200 (Fr, 18 Jul 2008) | 2 lines
- Changed the libCG configure test to actually fail for versions that are too old
........
r30433 | erluk | 2008-07-18 17:19:14 +0200 (Fr, 18 Jul 2008) | 2 lines
- Fixed compilation of xwindow plugin
........
r30434 | erluk | 2008-07-18 17:22:42 +0200 (Fr, 18 Jul 2008) | 1 line
- (Blindly) changed SimpleRoom.java to use the new event system
........
r30435 | erluk | 2008-07-18 17:24:36 +0200 (Fr, 18 Jul 2008) | 2 lines
- Removed duplicate event subscription from SDL canvas
........
r30436 | erluk | 2008-07-18 17:32:34 +0200 (Fr, 18 Jul 2008) | 2 lines
- Fixed typo
........
Modified Paths:
--------------
CS/branches/feature/unittest/apps/pysimp/pysimp.cpp
CS/branches/feature/unittest/apps/pysimp/pysimp.h
CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.cpp
CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.h
CS/branches/feature/unittest/apps/tutorial/phystut/phystut.cpp
CS/branches/feature/unittest/apps/tutorial/phystut/phystut.h
CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.cpp
CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.h
CS/branches/feature/unittest/apps/walktest/walktest.h
CS/branches/feature/unittest/configure.ac
CS/branches/feature/unittest/docs/texinfo/usingcs/tutorials/simple.txi
CS/branches/feature/unittest/libs/csutil/t/eventqueue.t
CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.cpp
CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.h
CS/branches/feature/unittest/plugins/video/canvas/sdl/sdl2d.cpp
CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.cpp
CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.h
CS/branches/feature/unittest/scripts/java/SimpleRoom.java
Property Changed:
----------------
CS/branches/feature/unittest/
Property changes on: CS/branches/feature/unittest
___________________________________________________________________
Modified: svnmerge-integrated
- /CS/branches/feature/newanim:1-29424 /CS/branches/feature/rendermanager:1-27020,28047,28050-28058,28682,28684-28686,28696-28697,28700-28701,28705-28707,28709,28712-28713,28718 /CS/trunk:1-30420
+ /CS/branches/feature/newanim:1-29424 /CS/branches/feature/rendermanager:1-27020,28047,28050-28058,28682,28684-28686,28696-28697,28700-28701,28705-28707,28709,28712-28713,28718 /CS/trunk:1-30436
Modified: CS/branches/feature/unittest/apps/pysimp/pysimp.cpp
===================================================================
--- CS/branches/feature/unittest/apps/pysimp/pysimp.cpp 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/pysimp/pysimp.cpp 2008-07-18 16:00:28 UTC (rev 30437)
@@ -30,7 +30,6 @@
PySimple::PySimple ()
{
SetApplicationName ("CrystalSpace.PySimp");
- motion_flags = 0;
}
PySimple::~PySimple ()
@@ -46,6 +45,8 @@
CS_REQUEST_FONTSERVER,
CS_REQUEST_IMAGELOADER,
CS_REQUEST_LEVELLOADER,
+ CS_REQUEST_REPORTER,
+ CS_REQUEST_REPORTERLISTENER,
CS_REQUEST_PLUGIN( "crystalspace.script.python", iScript ),
CS_REQUEST_END))
return ReportError ("Couldn't init app!");
@@ -56,73 +57,118 @@
csevAllEvents (GetObjectRegistry())))
return ReportError("Failed to set up event handler!");
- Process = csevProcess (GetObjectRegistry());
- FinalProcess = csevFinalProcess (GetObjectRegistry());
- KeyboardDown = csevKeyboardDown (GetObjectRegistry());
-
return true;
}
+void PySimple::OnExit()
+{
+ // Shut down the event handlers we spawned earlier.
+ drawer.Invalidate();
+ printer.Invalidate();
+}
+
bool PySimple::Application()
{
- vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry());
+ // Open the main system. This will open all the previously loaded plug-ins.
+ // i.e. all windows will be opened.
+ if (!OpenApplication(GetObjectRegistry()))
+ return ReportError("Error opening system!");
- // Find the pointer to engine plugin
+ if (SetupModules())
+ {
+ // This calls the default runloop. This will basically just keep
+ // broadcasting process events to keep the game going.
+ Run();
+ }
+
+ return true;
+}
+
+bool PySimple::SetupModules ()
+{
+ // Now get the pointer to various modules we need. We fetch them
+ // from the object registry. The RequestPlugins() call we did earlier
+ // registered all loaded plugins with the object registry.
+ g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry());
+ if (!g3d) return ReportError("Failed to locate 3D renderer!");
+
engine = csQueryRegistry<iEngine> (GetObjectRegistry());
- if (!engine)
- return ReportError ("No iEngine plugin!");
+ if (!engine) return ReportError("Failed to locate 3D engine!");
- myG3D = csQueryRegistry<iGraphics3D> (GetObjectRegistry());
- if (!myG3D)
- return ReportError ("No iGraphics3D loader plugin!");
+ vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry());
+ if (!vc) return ReportError("Failed to locate Virtual Clock!");
- LevelLoader = csQueryRegistry<iLoader> (GetObjectRegistry());
- if (!LevelLoader)
- return ReportError ("No iLoader plugin!");
-
kbd = csQueryRegistry<iKeyboardDriver> (GetObjectRegistry());
- if (!kbd)
- return ReportError ("No iKeyboardDriver!");
+ if (!kbd) return ReportError("Failed to locate Keyboard Driver!");
- // Open the main system. This will open all the previously loaded plug-ins.
- iNativeWindow* nw = myG3D->GetDriver2D ()->GetNativeWindow ();
+ loader = csQueryRegistry<iLoader> (GetObjectRegistry());
+ if (!loader) return ReportError("Failed to locate Loader!");
+
+ // We need a View to the virtual world.
+ view.AttachNew(new csView (engine, g3d));
+ iGraphics2D* g2d = g3d->GetDriver2D ();
+ // We use the full window to draw the world.
+ view->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());
+
+ iNativeWindow* nw = g2d->GetNativeWindow ();
if (nw) nw->SetTitle ("Simple Crystal Space Python Application");
- if (!csInitializer::OpenApplication (GetObjectRegistry()))
- return ReportError ("Error opening system!");
- // Some commercials...
- ReportInfo ("Simple Crystal Space Python Application version 0.1.");
-
// First disable the lighting cache. Our app is simple enough
// not to need this.
engine->SetLightingCacheMode (0);
+ // Here we create our world.
+ CreateRoom();
+
+ // Let the engine prepare all lightmaps for use and also free all images
+ // that were loaded for the texture manager.
+ engine->Prepare ();
+ rm = engine->GetRenderManager();
+
+ // these are used store the current orientation of the camera
+ rotY = rotX = 0;
+
+ // Now we need to position the camera in our world.
+ view->GetCamera ()->SetSector (room);
+ view->GetCamera ()->GetTransform ().SetOrigin (csVector3 (0, 5, -3));
+
+ // We use some other "helper" event handlers to handle
+ // pushing our work into the 3D engine and rendering it
+ // to the screen.
+ //drawer.AttachNew(new FrameBegin3DDraw (GetObjectRegistry (), view));
+ printer.AttachNew(new FramePrinter (GetObjectRegistry ()));
+
+ return true;
+}
+
+void PySimple::CreateRoom ()
+{
// Create our world.
ReportInfo ("Creating world!...");
- LevelLoader->LoadTexture ("stone", "/lib/std/stone4.gif");
+ loader->LoadTexture ("stone", "/lib/std/stone4.gif");
iSector *room = engine->CreateSector ("room");
csRef<iPluginManager> plugin_mgr (
- csQueryRegistry<iPluginManager> (GetObjectRegistry()));
+ csQueryRegistry<iPluginManager> (GetObjectRegistry()));
// Initialize the python plugin.
csRef<iScript> is = csQueryRegistry<iScript> (GetObjectRegistry());
if (is)
{
char const* module = "pysimp";
csRef<iCommandLineParser> cmd =
- csQueryRegistry<iCommandLineParser> (GetObjectRegistry());
+ csQueryRegistry<iCommandLineParser> (GetObjectRegistry());
if (cmd.IsValid())
{
char const* file = cmd->GetName(0);
if (file != 0)
- module = file;
+ module = file;
}
// Load a python module.
ReportInfo ("Loading script file `%s'...", module);
if (!is->LoadModule (module))
- return false;
+ return;
// Set up our room.
// Execute one method defined in pysimp.py
@@ -144,24 +190,8 @@
csRef<iLight> light;
light = engine->CreateLight (0, csVector3 (0, 5, 0), 10,
- csColor (1, 0, 0));
+ csColor (1, 0, 0));
room->GetLights ()->Add (light);
-
- engine->Prepare ();
-
- // csView is a view encapsulating both a camera and a clipper.
- // You don't have to use csView as you can do the same by
- // manually creating a camera and a clipper but it makes things a little
- // easier.
- view = csPtr<iView> (new csView (engine, myG3D));
- view->GetCamera ()->SetSector (room);
- view->GetCamera ()->GetTransform ().SetOrigin (csVector3 (0, 2, 0));
- iGraphics2D* g2d = myG3D->GetDriver2D ();
- view->SetRectangle (2, 2, g2d->GetWidth () - 4, g2d->GetHeight () - 4);
-
- Run ();
-
- return true;
}
void PySimple::OnCommandLineHelp ()
@@ -176,54 +206,85 @@
"by PYTHONPATH).\n\n");
}
-void PySimple::ProcessFrame ()
+void PySimple::Frame ()
{
- csTicks elapsed_time, current_time;
- elapsed_time = vc->GetElapsedTicks ();
- current_time = vc->GetCurrentTicks ();
-
+ // First get elapsed time from the virtual clock.
+ csTicks elapsed_time = vc->GetElapsedTicks ();
// Now rotate the camera according to keyboard state
- float speed = (elapsed_time / 1000.) * (0.03 * 20);
+ float speed = (elapsed_time / 1000.0) * (0.06 * 20);
- if (kbd->GetKeyState (CSKEY_RIGHT))
- view->GetCamera ()->GetTransform ().RotateThis (CS_VEC_ROT_RIGHT, speed);
- if (kbd->GetKeyState (CSKEY_LEFT))
- view->GetCamera ()->GetTransform ().RotateThis (CS_VEC_ROT_LEFT, speed);
- if (kbd->GetKeyState (CSKEY_PGUP))
- view->GetCamera ()->GetTransform ().RotateThis (CS_VEC_TILT_UP, speed);
- if (kbd->GetKeyState (CSKEY_PGDN))
- view->GetCamera ()->GetTransform ().RotateThis (CS_VEC_TILT_DOWN, speed);
- if (kbd->GetKeyState (CSKEY_UP))
- view->GetCamera ()->Move (CS_VEC_FORWARD * 4 * speed);
- if (kbd->GetKeyState (CSKEY_DOWN))
- view->GetCamera ()->Move (CS_VEC_BACKWARD * 4 * speed);
+ iCamera* c = view->GetCamera();
- // Tell 3D driver we're going to display 3D things.
- if (!myG3D->BeginDraw (CSDRAW_3DGRAPHICS)) return;
+ if (kbd->GetKeyState (CSKEY_SHIFT))
+ {
+ // If the user is holding down shift, the arrow keys will cause
+ // the camera to strafe up, down, left or right from it's
+ // current position.
+ if (kbd->GetKeyState (CSKEY_RIGHT))
+ c->Move (CS_VEC_RIGHT * 4 * speed);
+ if (kbd->GetKeyState (CSKEY_LEFT))
+ c->Move (CS_VEC_LEFT * 4 * speed);
+ if (kbd->GetKeyState (CSKEY_UP))
+ c->Move (CS_VEC_UP * 4 * speed);
+ if (kbd->GetKeyState (CSKEY_DOWN))
+ c->Move (CS_VEC_DOWN * 4 * speed);
+ }
+ else
+ {
+ // left and right cause the camera to rotate on the global Y
+ // axis; page up and page down cause the camera to rotate on the
+ // _camera's_ X axis (more on this in a second) and up and down
+ // arrows cause the camera to go forwards and backwards.
+ if (kbd->GetKeyState (CSKEY_RIGHT))
+ rotY += speed;
+ if (kbd->GetKeyState (CSKEY_LEFT))
+ rotY -= speed;
+ if (kbd->GetKeyState (CSKEY_PGUP))
+ rotX += speed;
+ if (kbd->GetKeyState (CSKEY_PGDN))
+ rotX -= speed;
+ if (kbd->GetKeyState (CSKEY_UP))
+ c->Move (CS_VEC_FORWARD * 4 * speed);
+ if (kbd->GetKeyState (CSKEY_DOWN))
+ c->Move (CS_VEC_BACKWARD * 4 * speed);
+ }
- if (view)
- view->Draw ();
-}
+ // We now assign a new rotation transformation to the camera. You
+ // can think of the rotation this way: starting from the zero
+ // position, you first rotate "rotY" radians on your Y axis to get
+ // the first rotation. From there you rotate "rotX" radians on the
+ // your X axis to get the final rotation. We multiply the
+ // individual rotations on each axis together to get a single
+ // rotation matrix. The rotations are applied in right to left
+ // order .
+ csMatrix3 rot = csXRotMatrix3 (rotX) * csYRotMatrix3 (rotY);
+ csOrthoTransform ot (rot, c->GetTransform().GetOrigin ());
+ c->SetTransform (ot);
-void PySimple::FinishFrame ()
-{
- // Drawing code ends here.
- myG3D->FinishDraw ();
- // Print the final output.
- myG3D->Print (0);
+ rm->RenderView (view);
}
-bool PySimple::OnKeyboard (iEvent& Event)
+bool PySimple::OnKeyboard (iEvent& ev)
{
- if ((Event.Name == KeyboardDown) &&
- (csKeyEventHelper::GetCookedCode (&Event) == CSKEY_ESC))
+ // We got a keyboard event.
+ csKeyEventType eventtype = csKeyEventHelper::GetEventType(&ev);
+ if (eventtype == csKeyEventTypeDown)
{
- csRef<iEventQueue> q (csQueryRegistry<iEventQueue> (GetObjectRegistry()));
- if (q)
- q->GetEventOutlet()->Broadcast (csevQuit (GetObjectRegistry()));
- return true;
+ // The user pressed a key (as opposed to releasing it).
+ utf32_char code = csKeyEventHelper::GetCookedCode(&ev);
+ if (code == CSKEY_ESC)
+ {
+ // The user pressed escape to exit the application.
+ // The proper way to quit a Crystal Space application
+ // is by broadcasting a csevQuit event. That will cause the
+ // main runloop to stop. To do that we get the event queue from
+ // the object registry and then post the event.
+ csRef<iEventQueue> q =
+ csQueryRegistry<iEventQueue> (GetObjectRegistry());
+ if (q.IsValid()) q->GetEventOutlet()->Broadcast(
+ csevQuit(GetObjectRegistry()));
+ }
}
-
return false;
}
Modified: CS/branches/feature/unittest/apps/pysimp/pysimp.h
===================================================================
--- CS/branches/feature/unittest/apps/pysimp/pysimp.h 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/pysimp/pysimp.h 2008-07-18 16:00:28 UTC (rev 30437)
@@ -23,30 +23,94 @@
class PySimple : public csApplicationFramework, public csBaseEventHandler
{
-public:
- csRef<iView> view;
+private:
+ /// A pointer to the 3D engine.
csRef<iEngine> engine;
- int motion_flags;
- csRef<iLoader> LevelLoader;
- csRef<iGraphics3D> myG3D;
+
+ /// A pointer to the map loader plugin.
+ csRef<iLoader> loader;
+
+ /// A pointer to the 3D renderer plugin.
+ csRef<iGraphics3D> g3d;
+
+ /// A pointer to the keyboard driver.
csRef<iKeyboardDriver> kbd;
+
+ /// A pointer to the virtual clock.
csRef<iVirtualClock> vc;
- csEventID Process;
- csEventID FinalProcess;
- csEventID KeyboardDown;
+ /// A pointer to the view which contains the camera.
+ csRef<iView> view;
+ /// The render manager, cares about selecting lights+meshes to render
+ csRef<iRenderManager> rm;
+
+ /// A pointer to the sector the camera will be in.
+ iSector* room;
+
+ /// Current orientation of the camera.
+ float rotX, rotY;
+
+ /// Event handlers to draw and print the 3D canvas on each frame
+ csRef<FrameBegin3DDraw> drawer;
+ csRef<FramePrinter> printer;
+
+ void OnCommandLineHelp ();
+
public:
+ bool SetupModules ();
+
+ /**
+ * Handle keyboard events - ie key presses and releases.
+ * This routine is called from the event handler in response to a
+ * csevKeyboard event.
+ */
+ bool OnKeyboard (iEvent&);
+
+ /**
+ * Setup everything that needs to be rendered on screen. This routine
+ * is called from the event handler in response to a csevFrame
+ * message, and is called in the "logic" phase (meaning that all
+ * event handlers for 3D, 2D, Console, Debug, and Frame phases
+ * will be called after this one).
+ */
+ void Frame ();
+
+ /// Here we will create our little, simple world.
+ void CreateRoom ();
+
+ /// Construct our game. This will just set the application ID for now.
PySimple ();
+
+ /// Destructor.
~PySimple ();
+ /// Final cleanup.
+ void OnExit ();
+
+ /**
+ * Main initialization routine. This routine will set up some basic stuff
+ * (like load all needed plugins, setup the event handler, ...).
+ * In case of failure this routine will return false. You can assume
+ * that the error message has been reported to the user.
+ */
bool OnInitialize (int argc, char* argv[]);
+
+ /**
+ * Run the application.
+ * First, there are some more initialization (everything that is needed
+ * by Simple1 to use Crystal Space), then this routine fires up the main
+ * event loop. This is where everything starts. This loop will basically
+ * start firing events which actually causes Crystal Space to function.
+ * Only when the program exits this function will return.
+ */
bool Application ();
- void OnCommandLineHelp ();
- void ProcessFrame ();
- void FinishFrame ();
- bool OnKeyboard (iEvent&);
+ /* Declare the name by which this class is identified to the event scheduler.
+ * Declare that we want to receive the frame event in the "LOGIC" phase,
+ * and that we're not terribly interested in having other events
+ * delivered to us before or after other modules, plugins, etc. */
+ CS_EVENTHANDLER_PHASE_LOGIC("application.pysimp")
};
#endif // __CS_PYSIMP_H__
Modified: CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.cpp
===================================================================
--- CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.cpp 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.cpp 2008-07-18 16:00:28 UTC (rev 30437)
@@ -68,24 +68,13 @@
view->Draw ();
}
-void PathTut::FinishFrame ()
-{
- g3d->FinishDraw ();
- g3d->Print (0);
-}
-
bool PathTut::HandleEvent (iEvent& ev)
{
- if (ev.Name == csevProcess (object_reg))
+ if (ev.Name == Frame)
{
pathtut->SetupFrame ();
return true;
}
- else if (ev.Name == csevFinalProcess (object_reg))
- {
- pathtut->FinishFrame ();
- return true;
- }
else if ((ev.Name == csevKeyboardDown (object_reg)) &&
(csKeyEventHelper::GetCookedCode (&ev) == CSKEY_ESC))
{
@@ -127,8 +116,7 @@
return false;
}
- Process = csevProcess (object_reg);
- FinalProcess = csevFinalProcess (object_reg);
+ Frame = csevFrame (object_reg);
KeyboardDown = csevKeyboardDown (object_reg);
if (!csInitializer::SetupEventHandler (object_reg, PathTutEventHandler))
@@ -257,6 +245,8 @@
iGraphics2D* g2d = g3d->GetDriver2D ();
view->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());
+ printer.AttachNew (new FramePrinter (object_reg));
+
// Load a texture for our sprite.
iTextureWrapper* txt = loader->LoadTexture ("spark",
"/lib/std/spark.png");
@@ -308,6 +298,11 @@
return true;
}
+void PathTut::Shutdown ()
+{
+ printer.Invalidate ();
+}
+
void PathTut::Animate (csTicks elapsedTime)
{
csVector3 pos, forward, up;
@@ -399,6 +394,8 @@
if (pathtut->Initialize (argc, argv))
pathtut->Start ();
+ pathtut->Shutdown ();
+
delete pathtut;
pathtut = 0;
Modified: CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.h
===================================================================
--- CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.h 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/tutorial/pathtut/pathtut.h 2008-07-18 16:00:28 UTC (rev 30437)
@@ -26,14 +26,14 @@
{
private:
iObjectRegistry* object_reg;
- csEventID Process;
- csEventID FinalProcess;
+ csEventID Frame;
csEventID KeyboardDown;
csRef<iEngine> engine;
csRef<iLoader> loader;
csRef<iGraphics3D> g3d;
csRef<iKeyboardDriver> kbd;
csRef<iVirtualClock> vc;
+ csRef<FramePrinter> printer;
iSector* room;
csRef<iView> view;
csRef<iMeshWrapper> sprite;
@@ -43,7 +43,6 @@
static bool PathTutEventHandler (iEvent& ev);
bool HandleEvent (iEvent& ev);
void SetupFrame ();
- void FinishFrame ();
void InitializePath();
void Animate(csTicks elapsedTime);
public:
@@ -52,6 +51,7 @@
bool Initialize (int argc, const char* const argv[]);
void Start ();
+ void Shutdown ();
};
#endif // __PATHTUT_H__
Modified: CS/branches/feature/unittest/apps/tutorial/phystut/phystut.cpp
===================================================================
--- CS/branches/feature/unittest/apps/tutorial/phystut/phystut.cpp 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/tutorial/phystut/phystut.cpp 2008-07-18 16:00:28 UTC (rev 30437)
@@ -111,24 +111,13 @@
WriteShadow( 10, 430, g2d->FindRGB (255, 150, 100),"AutoDisable ON");
}
-void Simple::FinishFrame ()
-{
- g3d->FinishDraw ();
- g3d->Print (0);
-}
-
bool Simple::HandleEvent (iEvent& ev)
{
- if (ev.Name == Process)
+ if (ev.Name == Frame)
{
simple->SetupFrame ();
return true;
}
- else if (ev.Name == FinalProcess)
- {
- simple->FinishFrame ();
- return true;
- }
else if (CS_IS_KEYBOARD_EVENT(object_reg, ev))
{
if (ev.Name == KeyboardDown)
@@ -366,6 +355,8 @@
return false;
}
+ printer.AttachNew (new FramePrinter (object_reg));
+
csRef<iFontServer> fs = g3d->GetDriver2D()->GetFontServer ();
if (fs)
courierFont = fs->LoadFont (CSFONT_COURIER);
@@ -520,6 +511,11 @@
return true;
}
+void Simple::Shutdown ()
+{
+ printer.Invalidate ();
+}
+
iRigidBody* Simple::CreateBox ()
{
objcnt++;
@@ -794,6 +790,7 @@
simple = new Simple (object_reg);
if (simple->Initialize ())
simple->Start ();
+ simple->Shutdown ();
delete simple; simple = 0;
csInitializer::DestroyApplication (object_reg);
Modified: CS/branches/feature/unittest/apps/tutorial/phystut/phystut.h
===================================================================
--- CS/branches/feature/unittest/apps/tutorial/phystut/phystut.h 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/tutorial/phystut/phystut.h 2008-07-18 16:00:28 UTC (rev 30437)
@@ -34,7 +34,8 @@
csRef<iKeyboardDriver> kbd;
csRef<iVirtualClock> vc;
csRef<iView> view;
- csRef<iCollideSystem> cdsys;
+ csRef<iCollideSystem> cdsys;
+ csRef<FramePrinter> printer;
iSector* room;
int objcnt;
int solver;
@@ -54,7 +55,6 @@
static bool SimpleEventHandler (iEvent& ev);
bool HandleEvent (iEvent& ev);
void SetupFrame ();
- void FinishFrame ();
void WriteShadow (int x,int y,int fg,const char *str,...);
void Write(int x,int y,int fg,int bg,const char *str,...);
@@ -79,6 +79,7 @@
bool Initialize ();
void Start ();
+ void Shutdown ();
};
#endif // __PHYSTUT_H__
Modified: CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.cpp
===================================================================
--- CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.cpp 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.cpp 2008-07-18 16:00:28 UTC (rev 30437)
@@ -31,6 +31,11 @@
{
}
+void Simple::OnExit ()
+{
+ printer.Invalidate ();
+}
+
bool Simple::Setup ()
{
// The virtual clock.
@@ -116,10 +121,12 @@
CreateGui();
+ printer.AttachNew (new FramePrinter (object_reg));
+
return true;
}
-void Simple::SetupFrame ()
+void Simple::Frame ()
{
// First get elapsed time from the virtual clock.
csTicks elapsed_time = vc->GetElapsedTicks ();
@@ -154,26 +161,11 @@
cegui->Render();
}
-void Simple::FinishFrame ()
-{
- g3d->FinishDraw ();
- g3d->Print (0);
-}
-bool Simple::HandleEvent (iEvent& ev)
+bool Simple::OnKeyboard (iEvent& ev)
{
bool res = false;
- if (ev.Name == csevProcess(object_reg))
- {
- SetupFrame ();
- res = true;
- }
- else if (ev.Name == csevFinalProcess(object_reg))
- {
- FinishFrame ();
- res = true;
- }
- else if ((ev.Name == csevKeyboardDown(object_reg)) &&
+ if ((ev.Name == csevKeyboardDown(object_reg)) &&
(csKeyEventHelper::GetCookedCode (&ev) == CSKEY_ESC))
{
csRef<iEventQueue> q (csQueryRegistry<iEventQueue> (GetObjectRegistry ()));
@@ -199,8 +191,6 @@
GetApplicationName()))
return ReportError("Failed to initialize config!");
- Process = csevProcess (GetObjectRegistry ());
- FinalProcess = csevFinalProcess (GetObjectRegistry ());
KeyboardDown = csevKeyboardDown (GetObjectRegistry ());
Quit = csevQuit (GetObjectRegistry ());
Modified: CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.h
===================================================================
--- CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.h 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/tutorial/simpvs/simpvs.h 2008-07-18 16:00:28 UTC (rev 30437)
@@ -33,21 +33,19 @@
csRef<iVFS> vfs;
csRef<iView> view;
csRef<iCEGUI> cegui;
+ csRef<FramePrinter> printer;
iSector* room;
csString mode;
- bool HandleEvent (iEvent& ev);
- void SetupFrame ();
- void FinishFrame ();
+ void Frame ();
void SaveVideoPreference();
bool Setup ();
+ void OnExit ();
- csEventID Process;
- csEventID FinalProcess;
csEventID KeyboardDown;
csEventID Quit;
@@ -65,8 +63,9 @@
bool OnInitialize (int argc, char* argv[]);
bool Application ();
- CS_EVENTHANDLER_NAMES("crystalspace.simpvs")
- CS_EVENTHANDLER_NIL_CONSTRAINTS
+ bool OnKeyboard (iEvent&);
+
+ CS_EVENTHANDLER_PHASE_3D("crystalspace.simpvs")
};
#endif // __SIMPVS_H__
Modified: CS/branches/feature/unittest/apps/walktest/walktest.h
===================================================================
--- CS/branches/feature/unittest/apps/walktest/walktest.h 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/apps/walktest/walktest.h 2008-07-18 16:00:28 UTC (rev 30437)
@@ -625,7 +625,7 @@
};
csRef<FrameEventHandler> frameEventHandler;
- CS_DECLARE_FRAME_EVENT_SHORTCUTS
+ CS_DECLARE_FRAME_EVENT_SHORTCUTS;
};
extern csVector2 coord_check_vector;
Modified: CS/branches/feature/unittest/configure.ac
===================================================================
--- CS/branches/feature/unittest/configure.ac 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/configure.ac 2008-07-18 16:00:28 UTC (rev 30437)
@@ -1657,7 +1657,8 @@
AS_IF([test $cs_cv_libCg = yes],
[CS_CHECK_BUILD([if Cg is sufficiently recent], [cs_cv_libCg_recent],
[AC_LANG_PROGRAM(
- [[#include <Cg/cg.h>]], [cgSetErrorHandler(0,0);])],
+ [[#include <Cg/cg.h>]], [cgSetErrorHandler(0,0);
+ CGprofile profile = CG_PROFILE_GPU_VP])],
[], [C++], [], [], [],
[$cs_cv_libCg_cflags],
[$cs_cv_libCg_lflags],
Modified: CS/branches/feature/unittest/docs/texinfo/usingcs/tutorials/simple.txi
===================================================================
--- CS/branches/feature/unittest/docs/texinfo/usingcs/tutorials/simple.txi 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/docs/texinfo/usingcs/tutorials/simple.txi 2008-07-18 16:00:28 UTC (rev 30437)
@@ -101,10 +101,10 @@
csRef<iGraphics3D> g3d;
csRef<iKeyboardDriver> kbd;
csRef<iVirtualClock> vc;
+ csRef<iRenderManager> rm;
+
+ csRef<FramePrinter> printer;
- void ProcessFrame ();
- void FinishFrame ();
-
public:
Simple ();
~Simple ();
@@ -113,9 +113,12 @@
bool OnInitialize (int argc, char* argv[]);
bool Application ();
+
+ void Frame ();
+
+ bool SetupModules ();
- CS_EVENTHANDLER_NAMES("application.simple1")
- CS_EVENTHANDLER_NIL_CONSTRAINTS
+ CS_EVENTHANDLER_PHASE_LOGIC("application.simple1")
@};
#endif // __SIMPLE1_H__
@@ -132,12 +135,11 @@
references. That makes it easier to manage reference counting. We let
the smart pointer take care of this for us.
-The event handler macros are used because our tutorial application also
+The event handler macro is used because our tutorial application also
needs to be an event handler (it inherits from @code{csBaseEventHandler} for
-that). The two macros indicate the name of this event handler and also the
-desired priority mechanism. In this case we use
-@...} which means that we don't care about
-the order in which our events arrive (relative to other modules in CS).
+that). The macro indicates the name of this event handler and specifies that
+the application wants to handle the frame event in the first (or 'logic')
+phase.
In the source file @file{simple.cpp} we place the following:
@@ -155,14 +157,10 @@
@{
@}
-void Simple::ProcessFrame ()
+void Simple::Frame ()
@{
@}
-void Simple::FinishFrame ()
-@{
-@}
-
bool Simple::OnInitialize(int argc, char* argv[])
@{
if (!csInitializer::RequestPlugins(GetObjectRegistry(),
@@ -178,7 +176,12 @@
return ReportError("Failed to initialize plugins!");
csBaseEventHandler::Initialize(GetObjectRegistry());
- if (!RegisterQueue(GetObjectRegistry(), csevAllEvents(GetObjectRegistry())))
+ csEventID events[] = @{
+ csevFrame (GetObjectRegistry()),
+ csevKeyboardEvent (GetObjectRegistry()),
+ CS_EVENTLIST_END
+ @};
+ if (!RegisterQueue(GetObjectRegistry(), events))
return ReportError("Failed to set up event handler!");
return true;
@@ -193,6 +196,16 @@
if (!OpenApplication(GetObjectRegistry()))
return ReportError("Error opening system!");
+ if (SetupModules())
+ @{
+ Run();
+ @}
+
+ return true;
+@}
+
+bool Simple::SetupModules ()
+@{
g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry());
if (!g3d) return ReportError("Failed to locate 3D renderer!");
@@ -208,10 +221,8 @@
loader = csQueryRegistry<iLoader> (GetObjectRegistry());
if (!loader) return ReportError("Failed to locate Loader!");
- Run();
-
return true;
-@}
+}
/*---------------*
* Main function
@@ -241,10 +252,6 @@
command-line options).
@item
-It will give command-line help when you use the @samp{-help} command-line
-option.
-
-@...
It has the following plugins initialized and ready to use: engine, 3D
renderer, canvas, reporter, reporter listener, font server, image loader,
map loader, and @sc{vfs}.
@@ -273,7 +280,7 @@
the 3D renderer which will then open its window (or enable graphics
on a non-windowing operating system).
-After that, we query the object registry to locate all the
+After that, we call @code{Simple::SetupModules()} to locate all the
common objects that we will need later, and store references to them
in our main class. Because we use @code{csRef<>} or smart pointers,
we don't have to worry about invoking @code{IncRef()} and @code{DecRef()}
@@ -345,9 +352,7 @@
header file:
@example
-@...{}
-struct iSector;
-@...{}
+
class Simple
@{
private:
@@ -363,7 +368,7 @@
@file{simple.cpp}:
@example
-bool Simple::Application ()
+bool Simple::SetupModules ()
@{
@dots{}
// First disable the lighting cache. Our app is simple enough
@@ -374,19 +379,30 @@
rotY = rotX = 0;
@dots{}
CreateRoom ()
+
+ engine->Prepare ();
+ rm = engine->GetRenderManager();
@dots{}
@}
@dots{}
void Simple::CreateRoom ()
@{
- // Load the texture from the standard library. This is located in
- // CS/data/standard.zip and mounted as /lib/std using the Virtual
- // File System (VFS) plugin.
- if (!loader->LoadTexture ("stone", "/lib/std/stone4.gif"))
- ReportError("Error loading 'stone4' texture!");
+ if (!loader->LoadTexture ("brick", "/lib/std/castle/brick1_d.jpg"))
+ ReportError("Error loading 'brick1_d' texture!");
- iMaterialWrapper* tm =
- engine->GetMaterialList ()->FindByName ("stone");
+ iMaterialWrapper* tm = engine->GetMaterialList ()->FindByName ("brick");
+
+ @{
+ csRef<iShaderVarStringSet> svStrings =
+ csQueryRegistryTagInterface<iShaderVarStringSet> (GetObjectRegistry(),
+ "crystalspace.shader.variablenameset");
+ csRef<iTextureHandle> normalMap = loader->LoadTexture (
+ "/lib/std/castle/brick1_n.jpg");
+ normalMap->SetTextureClass ("normalmap");
+ csShaderVariable* svNormalMap =
+ tm->GetMaterial()->GetVariableAdd (svStrings->Request ("tex normal"));
+ svNormalMap->SetValue (normalMap);
+ @}
room = engine->CreateSector ("room");
@@ -421,23 +437,20 @@
light = engine->CreateLight (0, csVector3 (0, 5, -3), 10,
csColor (0, 1, 0));
ll->Add (light);
-
- engine->Prepare ();
@}
@end example
This extra code first loads a texture with @code{LoadTexture()}.
The first parameter is the name of the texture as it will be known in the
engine; and the second is the
-actual filename on the @sc{vfs} volume (@pxref{VFS}). Note, if you don't have
-the @file{stone4.gif} texture you can use another one. The only requirement
-is that it must have sizes which are a power of 2 (e.g. 64x64); note that
-Crystal Space will scale them automatically if this requirement is not met
-but this can
-reduce quality. This function returns a @samp{iTextureWrapper} which we
+actual filename on the @sc{vfs} volume (@pxref{VFS}). This function returns
+a @samp{iTextureWrapper} which we
don't use. Instead we use the @samp{iMaterialWrapper} which is created
automatically by @code{LoadTexture()}.
+The next block of code shows how to add a normal map to the texture we just
+loaded.
+
Then, we create our room with @code{CreateSector()}. This room will initially
be empty. A room in Crystal Space is represented by @samp{iSector} which is
basically a container which can hold geometrical objects. Objects
@@ -555,16 +568,15 @@
@dots{}
csRef<iView> view;
@dots{}
- void ProcessFrame ();
- void FinishFrame ();
+ void Frame ();
@dots{}
@end example
Then, edit @file{simple.cpp} and make the following changes at the end of
-our @code{Application()} function:
+our @code{SetupModules()} function:
@example
-bool Simple::Application ()
+bool Simple::SetupModules ()
@{
@dots{}
view.AttachNew(new csView (engine, g3d));
@@ -573,6 +585,8 @@
@dots{}
view->GetCamera ()->SetSector (room);
view->GetCamera ()->GetTransform ().SetOrigin (csVector3 (0, 5, -3));
+
+ printer.AttachNew (new FramePrinter (GetObjectRegistry ()));
return true;
@}
@@ -599,60 +613,21 @@
by the event handler. Add the following code somewhere in the source file:
@example
-void Simple::ProcessFrame ()
+void Simple::Frame ()
@{
- // Tell 3D driver we're going to display 3D things.
- if (!g3d->BeginDraw(
- engine->GetBeginDrawFlags() | CSDRAW_3DGRAPHICS))
- return;
-
- // Tell the camera to render into the frame buffer.
- view->Draw ();
+ rm->RenderView (view);
@}
-
-void Simple::FinishFrame ()
-@{
- g3d->FinishDraw ();
- g3d->Print (0);
-@}
@end example
Drawing the screen is done in two steps. First there is the part that
-is done in @code{ProcessFrame()}. Here, we will actually fill the display.
+is done in @code{Frame()}. Here, we will actually fill the display.
In this case we let the engine do most of that work by calling
-@...()}. But, in principle, you can do any kind of drawing here.
+@code{rm->RenderView (view)}. But, in principle, you can do any kind of
+drawing here.
-In @code{ProcessFrame()} we first have to indicate to the 3D rasterizer that
-we want to start drawing 3D graphics. This call makes sure that the
-needed buffers are set up and
-performs all necessary initialization. The engine often needs extra settings
-for this as well so you @emph{must} call @code{engine->GetBeginDrawFlags()} to
-get these flags and bitwise-or them with the ones that you want.
+The @code{FramePrinter} instance we created earlier will take care of updating
+the display.
-The second part is in @code{FinishFrame()} where we actually dump the
-frame to the screen. The reason this is split is that other components
-(plugins) in Crystal Space may choose to listen to events and draw additional
-things on top of the 3D view rendered in @code{ProcessFrame()}. When a frame
-needs to be rendered, the Crystal Space framework will send four messages:
-
-@... @bullet
-@...
-@...} is sent first. This allows plugins to preprocess
-things before drawing can happen.
-
-@...
-@...} follows. In this pass the application will render.
-
-@...
-@...} is after that. This is the pass that can be used
-by external components to render on top of the view rendered by the
-application.
-
-@...
-@...} is last. In this pass the application will display
-the frame on screen.
-@... itemize
-
Compile and run this example. For the first time you should see something: A
solid wall. Congratulations, you have created your first almost useful
Crystal Space application.
@@ -666,10 +641,10 @@
Staring at that solid wall gets a bit boring after some time. The problem is
that we can't move the camera to change our view point. Let's add some code
to do exactly this. Edit @file{simple.cpp} again and change
-@...()} as follows:
+@file{Frame()} as follows:
@example
-void Simple::ProcessFrame ()
+void Simple::Frame ()
@{
// First get elapsed time from the virtual clock.
csTicks elapsed_time = vc->GetElapsedTicks ();
Modified: CS/branches/feature/unittest/libs/csutil/t/eventqueue.t
===================================================================
--- CS/branches/feature/unittest/libs/csutil/t/eventqueue.t 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/libs/csutil/t/eventqueue.t 2008-07-18 16:00:28 UTC (rev 30437)
@@ -115,7 +115,6 @@
CPPUNIT_TEST_SUITE (csEventQueueTest);
CPPUNIT_TEST (testSmokeTest);
CPPUNIT_TEST (testPhaseHandlers);
- CPPUNIT_TEST (testFrameSubEvents);
CPPUNIT_TEST (testMixedHandlers);
CPPUNIT_TEST_SUITE_END ();
};
@@ -230,57 +229,6 @@
}
/**
- * Make sure PreProcess/Process/PostProcess/FinalProcess dispatch in order.
- */
-void csEventQueueTest::testFrameSubEvents ()
-{
- csEventQueue *queue = new csEventQueue (objreg);
-
- iEventHandler *h1 = new HandlerOther (objreg, "PreProcess");
- iEventHandler *h2 = new HandlerOther (objreg, "Process");
- iEventHandler *h3 = new HandlerOther (objreg, "PostProcess");
- iEventHandler *h4 = new HandlerOther (objreg, "FinalProcess");
-
- queue->RegisterListener (h3, csevPostProcess (objreg));
- queue->RegisterListener (h1, csevPreProcess (objreg));
- queue->RegisterListener (h2, csevProcess (objreg));
- queue->RegisterListener (h4, csevFinalProcess (objreg));
-
- handlers = new csList<csString *> ();
- queue->Process ();
-
- dumpHandlers ();
-
- CPPUNIT_ASSERT_MESSAGE ("List is empty", !handlers->IsEmpty());
-
- std::string message ("Expected PreProcess, got ");
- message += handlers->Front()->GetData();
- CPPUNIT_ASSERT_MESSAGE (message,
- handlers->Front ()->Compare ("PreProcess"));
- handlers->PopFront ();
-
- message = "Expected Process, got ";
- message += handlers->Front()->GetData();
- CPPUNIT_ASSERT_MESSAGE (message,
- handlers->Front ()->Compare ("Process"));
- handlers->PopFront ();
-
- message = "Expected PostProcess, got ";
- message += handlers->Front()->GetData();
- CPPUNIT_ASSERT_MESSAGE (message,
- handlers->Front ()->Compare ("PostProcess"));
- handlers->PopFront ();
-
- message = "Expected FinalProcess, got ";
- message += handlers->Front()->GetData();
- CPPUNIT_ASSERT_MESSAGE (message,
- handlers->Front ()->Compare ("FinalProcess"));
- handlers->PopFront ();
-
- CPPUNIT_ASSERT_MESSAGE ("List not empty", handlers->IsEmpty());
-}
-
-/**
* Make sure combination of PreProc/Proc/PostProc/FinalProc and
* phased Frame handlers get interleaved properly.
*/
Modified: CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.cpp
===================================================================
--- CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.cpp 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.cpp 2008-07-18 16:00:28 UTC (rev 30437)
@@ -28,6 +28,7 @@
#include "csutil/csstring.h"
#include "csutil/event.h"
#include "csutil/eventnames.h"
+#include "csutil/eventhandlers.h"
#include "csjoylin.h"
@@ -72,7 +73,7 @@
#define CS_MAX_LINUX_JOYSTICK_AXES CS_MAX_JOYSTICK_AXES
bool csLinuxJoystick::HandleEvent (iEvent& ev)
{
- if (ev.Name != PreProcess)
+ if (ev.Name != Frame)
return false;
struct js_event js;
@@ -202,11 +203,11 @@
}
// hook into eventqueue
- PreProcess = csevPreProcess (object_reg);
+ Frame = csevFrame (object_reg);
csRef<iEventQueue> eq (csQueryRegistry<iEventQueue> (object_reg));
if (eq != 0)
{
- eq->RegisterListener (static_cast<iEventHandler*> (this), PreProcess);
+ eq->RegisterListener (static_cast<iEventHandler*> (this), Frame);
EventOutlet = eq->CreateEventOutlet (static_cast<iEventPlug*> (this));
bHooked = true;
}
Modified: CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.h
===================================================================
--- CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.h 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/plugins/device/joystick/linux/csjoylin.h 2008-07-18 16:00:28 UTC (rev 30437)
@@ -66,7 +66,7 @@
bool Close ();
void Report (int severity, const char* msg, ...);
- csEventID PreProcess;
+ csEventID Frame;
public:
csLinuxJoystick (iBase *parent);
@@ -79,8 +79,7 @@
{ return CSEVTYPE_Joystick; }
virtual unsigned QueryEventPriority (unsigned) { return 110; }
- CS_EVENTHANDLER_NAMES("crystalspace.device.joystick")
- CS_EVENTHANDLER_NIL_CONSTRAINTS
+ CS_EVENTHANDLER_PHASE_LOGIC("crystalspace.device.joystick")
};
}
Modified: CS/branches/feature/unittest/plugins/video/canvas/sdl/sdl2d.cpp
===================================================================
--- CS/branches/feature/unittest/plugins/video/canvas/sdl/sdl2d.cpp 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/plugins/video/canvas/sdl/sdl2d.cpp 2008-07-18 16:00:28 UTC (rev 30437)
@@ -380,13 +380,10 @@
pfmt.complete ();
Clear(0);
- csEventID PreProcess = csevPreProcess (object_reg);
- csEventID PostProcess = csevPostProcess (object_reg);
-
csRef<iEventQueue> q = csQueryRegistry<iEventQueue> (object_reg);
if (q != 0)
{
- csEventID events[] = { PreProcess, PostProcess, CS_EVENTLIST_END };
+ csEventID events[] = { csevFrame (object_reg), CS_EVENTLIST_END };
// csGraphics2D::Initialize already setup weakEventHandler using
// RegisterWeakListener so we use plain RegisterListener here.
q->RegisterListener (weakEventHandler, events);
Modified: CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.cpp
===================================================================
--- CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.cpp 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.cpp 2008-07-18 16:00:28 UTC (rev 30437)
@@ -22,6 +22,7 @@
#include "cssysdef.h"
#include "csutil/sysfunc.h"
#include "csutil/event.h"
+#include "csutil/eventhandlers.h"
#include "xwindow.h"
#include "csgeom/csrect.h"
#include "csutil/callstack.h"
@@ -361,7 +362,7 @@
scfiEventHandler.AttachNew (new EventHandler (this));
csRef<iEventQueue> q (csQueryRegistry<iEventQueue> (object_reg));
if (q != 0) {
- csEventID events[3] = { csevPreProcess(name_reg),
+ csEventID events[3] = { csevFrame(name_reg),
csevCommandLineHelp(name_reg),
CS_EVENTLIST_END };
q->RegisterListener (scfiEventHandler, events);
Modified: CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.h
===================================================================
--- CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.h 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/plugins/video/canvas/xwindow/xwindow.h 2008-07-18 16:00:28 UTC (rev 30437)
@@ -29,6 +29,7 @@
#include "iutil/eventh.h"
#include "iutil/comp.h"
#include "iutil/event.h"
+#include "csutil/eventhandlers.h"
#include "ivaria/xwindow.h"
#include "plugins/video/canvas/xwindowcommon/xextf86vm.h"
#include "ivideo/graph2d.h"
@@ -174,8 +175,7 @@
}
virtual ~EventHandler () { }
virtual bool HandleEvent (iEvent& e) { return parent ? parent->HandleEvent(e) : false; }
- CS_EVENTHANDLER_NAMES("crystalspace.window")
- CS_EVENTHANDLER_NIL_CONSTRAINTS
+ CS_EVENTHANDLER_PHASE_LOGIC("crystalspace.window")
};
csRef<EventHandler> scfiEventHandler;
Modified: CS/branches/feature/unittest/scripts/java/SimpleRoom.java
===================================================================
--- CS/branches/feature/unittest/scripts/java/SimpleRoom.java 2008-07-18 15:32:34 UTC (rev 30436)
+++ CS/branches/feature/unittest/scripts/java/SimpleRoom.java 2008-07-18 16:00:28 UTC (rev 30437)
@@ -27,6 +27,7 @@
public iVirtualClock vc;
public iLoader loader;
public iEngine engine;
+ public FramePrinter printer;
private static GlobRefs instance = null;
public static GlobRefs Get()
@@ -46,6 +47,7 @@
kbd = (iKeyboardDriver) objreg.Get (iKeyboardDriver.class);
loader = (iLoader) objreg.Get (iLoader.class);
engine = (iEngine) objreg.Get (iEngine.class);
+ printer = new FramePrinter (objreg);
}
};
@@ -80,8 +82,7 @@
protected csView view;
protected iKeyboardDriver kbd;
protected iVirtualClock vc;
- protected long evPreProcess;
- protected long evFinalProcess;
+ protected long evFrame;
public EventHandler (csView v)
{
@@ -90,8 +91,7 @@
vc = r.vc;
kbd = r.kbd;
view = v;
- evPreProcess = CS.csevPreProcess (CS.getTheObjectRegistry());
- evFinalProcess = CS.csevFinalProcess (CS.getTheObjectRegistry());
+ evFrame = CS.csevFrame (CS.getTheObjectRegistry());
}
protected void SetupFrame ()
@@ -125,12 +125,6 @@
view.Draw();
}
- protected void FinishFrame ()
- {
- myG3D.FinishDraw();
- myG3D.Print(null);
- }
-
public boolean HandleEvent (iEvent ev)
{
if (CS.CS_IS_KEYBOARD_EVENT (CS.getTheObjectRegistry(), ev) &&
@@ -147,10 +141,8 @@
return true;
}
}
- else if (ev.getName() == evPreProcess)
+ else if (ev.getName() == evFrame)
SetupFrame();
- else if (ev.getName() == evFinalProcess)
- FinishFrame();
return true;
}
};
@@ -265,8 +257,7 @@
System.out.println("Setting up event handlers...");
EventHandler eventHandler = new EventHandler(view);
long events[] = {
- CS.csevPreProcess (CS.getTheObjectRegistry()),
- CS.csevFinalProcess (CS.getTheObjectRegistry()),
+ CS.csevFrame (CS.getTheObjectRegistry()),
CS.csevKeyboardEvent (CS.getTheObjectRegistry()),
-1 /* CS.CS_EVENTLIST_END */
};
@@ -276,6 +267,8 @@
System.out.println("Starting the main runloop...");
csDefaultRunLoop(object_reg);
+
+ GlobRefs.Get().printer = null;
}
catch(Exception e)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|