00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- 00002 this file is part of rcssserver3D 00003 Fri May 9 2003 00004 Copyright (C) 2003 Koblenz University 00005 $Id: rendercontrol.cpp,v 1.3 2004/12/22 16:29:23 rollmark Exp $ 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; version 2 of the License. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 #include "rendercontrol.h" 00021 #include "customrender.h" 00022 #include <zeitgeist/logserver/logserver.h> 00023 #include <kerosin/renderserver/renderserver.h> 00024 #include <kerosin/openglserver/openglserver.h> 00025 00026 using namespace kerosin; 00027 using namespace oxygen; 00028 using namespace zeitgeist; 00029 using namespace boost; 00030 using namespace std; 00031 00032 RenderControl::RenderControl() 00033 { 00034 mFramesRendered = 0; 00035 } 00036 00037 RenderControl::~RenderControl() 00038 { 00039 } 00040 00041 void RenderControl::OnLink() 00042 { 00043 mRenderServer = shared_dynamic_cast<RenderServer> 00044 (GetCore()->Get("/sys/server/render")); 00045 00046 if (mRenderServer.get() == 0) 00047 { 00048 GetLog()->Error() 00049 << "(RenderControl) ERROR: RenderServer not found\n"; 00050 } 00051 00052 mOpenGLServer = shared_dynamic_cast<OpenGLServer> 00053 (GetCore()->Get("/sys/server/opengl")); 00054 00055 if (mOpenGLServer.get() == 0) 00056 { 00057 GetLog()->Error() 00058 << "(RenderControl) ERROR: OpenGLServer not found\n"; 00059 } 00060 } 00061 00062 void RenderControl::OnUnlink() 00063 { 00064 mRenderServer.reset(); 00065 mOpenGLServer.reset(); 00066 } 00067 00068 void RenderControl::RenderCustom() 00069 { 00070 // get list of registered CustomMonitor objects 00071 TLeafList customList; 00072 ListChildrenSupportingClass<CustomRender>(customList); 00073 00074 for ( 00075 TLeafList::iterator iter = customList.begin(); 00076 iter != customList.end(); 00077 ++iter 00078 ) 00079 { 00080 shared_static_cast<CustomRender>((*iter)) 00081 ->Render(); 00082 } 00083 } 00084 00085 void RenderControl::EndCycle() 00086 { 00087 // update the window (pumps event loop, etc..) and render the 00088 // current frame 00089 mOpenGLServer->Update(); 00090 mRenderServer->Render(); 00091 RenderCustom(); 00092 mOpenGLServer->SwapBuffers(); 00093 ++mFramesRendered; 00094 } 00095 00096 int RenderControl::GetFramesRendered() 00097 { 00098 return mFramesRendered; 00099 } 00100 00101 00102 00103 00104