post-florida update

This commit is contained in:
James Turk 2005-08-02 23:07:51 +00:00
parent 766db32ed9
commit 84e61a622d
19 changed files with 195 additions and 116 deletions

View File

@ -5,14 +5,13 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: AppCore.hpp,v 1.8 2005/07/19 05:45:22 cozman Exp $
// $Id: AppCore.hpp,v 1.9 2005/08/02 23:07:51 cozman Exp $
#ifndef PHOTON_APPCORE_HPP
#define PHOTON_APPCORE_HPP
#include "types.hpp"
#include "util/VersionInfo.hpp"
#include "util/Singleton.hpp"
#include "Task.hpp"
#include "InputListener.hpp"
@ -22,20 +21,21 @@ namespace photon
{
// Class: AppCore
// Photon's <Singleton> core for application behavior. Defines the interface
// through which all "application" related functions are performed.
// Photon's core for application behavior. Defines the interface through which
// all "application" related functions are performed. This means input,
// display creation, etc.
//
// AppCore is the Core that essentially represents the window management,
// input, and timing systems.
//
// Parent:
// <Singleton>
class AppCore : public util::Singleton<AppCore>
class AppCore
{
public:
AppCore();
~AppCore();
void init();
void shutdown();
// Group: Video
public:

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Application.hpp,v 1.9 2005/07/19 01:31:37 cozman Exp $
// $Id: Application.hpp,v 1.10 2005/08/02 23:07:51 cozman Exp $
#ifndef PHOTON_APPLICATION_HPP
#define PHOTON_APPLICATION_HPP
@ -18,6 +18,10 @@
#include "types.hpp"
#include "util/VersionInfo.hpp"
#include "Task.hpp"
#include "Kernel.hpp"
#include "AppCore.hpp"
#include "video/VideoCore.hpp"
#include "audio/AudioCore.hpp"
namespace photon
{
@ -55,6 +59,15 @@ public:
// See Also:
// <ENTRYPOINT>
virtual int main(const StrVec& args)=0;
// Group: Core Access
public:
static Kernel& getKernel();
static AppCore& getAppCore();
static video::VideoCore& getVideoCore();
static audio::AudioCore& getAudioCore();
static void initVideoCore(uint width, uint height);
static void initAudioCore(const std::string& deviceName);
// behind the scenes
public:
@ -67,6 +80,12 @@ private:
private:
// version number for photon
util::VersionInfo photonVer_;
// Cores and Kernel
static Kernel kernel_;
static AppCore appCore_;
static std::auto_ptr<video::VideoCore> videoCore_;
static std::auto_ptr<audio::AudioCore> audioCore_;
static std::string arg0_;
};

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Kernel.hpp,v 1.1 2005/03/15 19:22:07 cozman Exp $
// $Id: Kernel.hpp,v 1.2 2005/08/02 23:07:52 cozman Exp $
#ifndef PHOTON_KERNEL_HPP
#define PHOTON_KERNEL_HPP
@ -13,21 +13,20 @@
#include <list>
#include <algorithm>
#include "util/Singleton.hpp"
#include "Task.hpp"
namespace photon
{
// Class: Kernel
// Singleton Kernel class, maintains a list of <Tasks> and manages their
// status, including adding, deleting, pausing, and unpausing tasks.
// Kernel class, maintains a list of <Tasks> and manages their status,
// handles adding, deleting, pausing, and unpausing tasks.
//
// To use Kernel:
// - (1) Add any tasks (should be derived from <Task>)
// - (2) call <Kernel::run>
// - (3) in order to avoid running forever, all tasks should eventually die
class Kernel : public util::Singleton<Kernel>
class Kernel
{
// Group: (Con/De)structors

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Log.hpp,v 1.7 2005/07/19 01:31:37 cozman Exp $
// $Id: Log.hpp,v 1.8 2005/08/02 23:07:52 cozman Exp $
#ifndef PHOTON_LOG_HPP
#define PHOTON_LOG_HPP
@ -14,7 +14,6 @@
#include <list>
#include <sstream>
#include "util/Singleton.hpp"
#include "LogSink.hpp"
namespace photon

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: AudioCore.hpp,v 1.9 2005/07/19 05:56:08 cozman Exp $
// $Id: AudioCore.hpp,v 1.10 2005/08/02 23:07:52 cozman Exp $
#ifdef PHOTON_USE_OPENAL
@ -24,20 +24,18 @@ namespace audio
{
// Class: AudioCore
// Photon's <Singleton> core for audio manipulation/control. Defines the
// interface through which all audio related functions are performed.
//
// Parent:
// <Singleton>
class AudioCore : public util::Singleton<AudioCore>
// Photon's core for audio manipulation/control. Defines the interface through
// which all audio related functions are performed.
class AudioCore
{
// Group: (Con/De)structors
public:
// Function: AudioCore
// Initialize underlying APIs and setup <Task> internals.
//AudioCore();
AudioCore(const std::string& deviceName);
// Function: ~AudioCore
// Shutdown underlying APIs.
~AudioCore();

View File

@ -5,13 +5,12 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: VideoCore.hpp,v 1.4 2005/07/20 06:12:54 cozman Exp $
// $Id: VideoCore.hpp,v 1.5 2005/08/02 23:07:52 cozman Exp $
#ifndef PHOTON_VIDEO_VIDEOCORE_HPP
#define PHOTON_VIDEO_VIDEOCORE_HPP
#include "types.hpp"
#include "util/Singleton.hpp"
#include "Task.hpp"
namespace photon
@ -20,24 +19,25 @@ namespace video
{
// Class: VideoCore
// Photon's <Singleton> core for graphics behavior. Defines the interface
// through which all graphics related functions are performed.
// Photon's core for graphics behavior. Defines the interface through which
// all graphics related functions are performed.
//
// VideoCore is the Core that interfaces with the actual drawing/updating of
// the display.
//
// See Also:
// <AppCore>
//
// Parent:
// <Singleton>
class VideoCore : public util::Singleton<VideoCore>
class VideoCore
{
// Group: (Con/De)structors
public:
// Function: VideoCore
// Initialize underlying APIs and setup <Task> internals.
VideoCore();
//
// Parameters:
// width - Width of display.
// height - height of display
VideoCore(uint width, uint height);
// Function: ~VideoCore
// Shutdown underlying APIs.

View File

@ -35,7 +35,9 @@
</node>
</node>
</node>
<node ID="Freemind_Link_700471537" TEXT="dependencies / licensing clarification"/>
<node ID="Freemind_Link_700471537" TEXT="dependencies / licensing clarification">
<icon BUILTIN="button_ok"/>
</node>
<node ID="Freemind_Link_1153941464" TEXT="test compilation on fresh systems">
<node ID="Freemind_Link_1403005191" TEXT="test compilation on clean linux system"/>
<node ID="Freemind_Link_617919930" TEXT="test compilation on windows system">
@ -159,7 +161,7 @@
</node>
</node>
</node>
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.22 2005/07/20 07:30:13 cozman Exp $">
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.23 2005/08/02 23:07:51 cozman Exp $">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node>
</node>

View File

@ -5,13 +5,14 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: AppCore.cpp,v 1.13 2005/07/20 06:12:54 cozman Exp $
// $Id: AppCore.cpp,v 1.14 2005/08/02 23:07:52 cozman Exp $
#include "AppCore.hpp"
#include <boost/lexical_cast.hpp>
#include "GL/glfw.h" //This file depends on glfw
#include "Application.hpp"
#include "Kernel.hpp"
#include "exceptions.hpp"
#include "video/VideoCore.hpp"
@ -26,19 +27,24 @@ std::vector<KeyCode> AppCore::pressedKeys_;
AppCore::AppCore() :
dispWidth_(0), dispHeight_(0),
task_(new UpdateTask())
{ }
AppCore::~AppCore()
{
}
void AppCore::init()
{
util::VersionInfo glfwReq(2,4,2); // requires GLFW 2.4.2
util::ensureVersion("GLFW", initGLFW(), glfwReq);
Kernel::getInstance().addTask(task_); // add updater task
Application::getKernel().addTask(task_); // add updater task
}
AppCore::~AppCore()
void AppCore::shutdown()
{
if(dispWidth_ && dispHeight_)
{
video::VideoCore::destroy(); // destroy videocore
glfwCloseWindow(); //close GLFW window
}
@ -66,10 +72,9 @@ void AppCore::createDisplay(uint width, uint height,
glfwSetMousePosCallback(AppCore::mouseMoveCallback);
//glfwSetMouseWheelCallback(AppCore::mouseWheelCallback);
Application::initVideoCore(width, height);
dispWidth_ = width;
dispHeight_ = height;
new video::VideoCore; // _MUST_ create the VideoCore after the window!
video::VideoCore::getInstance().setDisplaySize(width,height);
glfwSetWindowTitle(title.c_str()); // title is set separately
}
@ -314,7 +319,7 @@ void AppCore::UpdateTask::update()
( (glfwGetKey(GLFW_KEY_LALT) || glfwGetKey(GLFW_KEY_RALT)) &&
(glfwGetKey(GLFW_KEY_F4) || glfwGetKey('X')) ) )
{
Kernel::getInstance().killAllTasks();
Application::getKernel().killAllTasks();
}
// hold active-state

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Application.cpp,v 1.13 2005/07/19 18:35:20 cozman Exp $
// $Id: Application.cpp,v 1.14 2005/08/02 23:07:52 cozman Exp $
#include "Application.hpp"
@ -25,25 +25,84 @@
namespace photon
{
Kernel Application::kernel_;
AppCore Application::appCore_;
std::auto_ptr<video::VideoCore> Application::videoCore_;
std::auto_ptr<audio::AudioCore> Application::audioCore_;
std::string Application::arg0_;
Application::Application() :
photonVer_(0,0,1) // this is the current version
{
util::VersionInfo physfsReq(1,0,0); // requires PhysFS 1.0.0
// create the singletons
new Kernel;
new AppCore;
util::ensureVersion("PhysFS", initPhysFS(), physfsReq);
appCore_.init(); // init appcore
}
Application::~Application()
{
PHYSFS_deinit(); //shutdown PhysFS
appCore_.shutdown(); // shutdown appcore
PHYSFS_deinit(); // shutdown PhysFS
}
// destroy the singletons
AppCore::destroy();
Kernel::destroy();
Kernel& Application::getKernel()
{
return kernel_;
}
AppCore& Application::getAppCore()
{
return appCore_;
}
video::VideoCore& Application::getVideoCore()
{
// return VideoCore if it has been created
if(videoCore_.get() == 0)
{
throw PreconditionException("call to Application::getVideoCore() before"
" Application::initAudioDevice");
}
return *videoCore_;
}
audio::AudioCore& Application::getAudioCore()
{
// return AudioCore if it has been created
if(audioCore_.get() == 0)
{
throw PreconditionException("call to Application::getAudioCore() before"
" Application::initAudioDevice");
}
return *audioCore_;
}
void Application::initVideoCore(uint width, uint height)
{
// create VideoCore, avoid double initializaiton
if(videoCore_.get() == 0)
{
videoCore_.reset(new video::VideoCore(width, height));
}
else
{
throw PreconditionException("Attempt to double initialize VideoCore");
}
}
void Application::initAudioCore(const std::string& deviceName)
{
// create AudioCore, avoid double initializaiton
if(audioCore_.get() == 0)
{
audioCore_.reset(new audio::AudioCore(deviceName));
}
else
{
throw PreconditionException("Attempt to double initialize AudioCore");
}
}
void Application::setInitOptions(const char* arg0)
@ -60,6 +119,4 @@ util::VersionInfo Application::initPhysFS()
return util::VersionInfo(ver.major, ver.minor, ver.patch);
}
std::string Application::arg0_;
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: AudioCore.cpp,v 1.10 2005/07/19 18:35:20 cozman Exp $
// $Id: AudioCore.cpp,v 1.11 2005/08/02 23:07:52 cozman Exp $
#ifdef PHOTON_USE_OPENAL
@ -19,12 +19,13 @@ namespace photon
namespace audio
{
AudioCore::AudioCore(const std::string& deviceName)
{
//AudioCore::AudioCore()
AudioCore::AudioCore(const std::string& deviceName)
{
//util::VersionInfo oalReq(0,0,7); // requires OpenAL 1.0 (TODO: check?)
//util::ensureVersion("OpenAL", initOpenAL(), oalReq);
initOpenAL(deviceName); // don't check version for now
initOpenAL(deviceName); // don't check version for now
}
AudioCore::~AudioCore()
@ -36,7 +37,7 @@ AudioCore::~AudioCore()
// destroy context & device
alcDestroyContext(context);
alcCloseDevice(device);
// set current context to null
alcMakeContextCurrent(0);
}
@ -147,7 +148,7 @@ util::VersionInfo AudioCore::initOpenAL(const std::string& deviceName)
void AudioCore::initAudioDevice(const std::string& deviceName)
{
new AudioCore(deviceName);
// new AudioCore(deviceName);
}

View File

@ -5,9 +5,10 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Timer.cpp,v 1.3 2005/07/18 06:18:50 cozman Exp $
// $Id: Timer.cpp,v 1.4 2005/08/02 23:07:52 cozman Exp $
#include "util/Timer.hpp"
#include "Application.hpp"
namespace photon
{
@ -15,7 +16,7 @@ namespace util
{
Timer::Timer(bool appTimeLinked) :
appCore_(AppCore::getInstance()),
appCore_(Application::getAppCore()),
appTimeLinked_(appTimeLinked)
{
reset(); //initializes other members

View File

@ -5,35 +5,36 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: VideoCore.cpp,v 1.8 2005/07/20 06:12:54 cozman Exp $
// $Id: VideoCore.cpp,v 1.9 2005/08/02 23:07:53 cozman Exp $
#include "video/VideoCore.hpp"
#include "Application.hpp"
#include "Kernel.hpp"
#include "exceptions.hpp"
#include "GL/gl.h"
#include "GL/glu.h"
#include <iostream>
namespace photon
{
namespace video
{
VideoCore::VideoCore() :
displayWidth_(0), displayHeight_(0),
VideoCore::VideoCore(uint width, uint height) :
displayWidth_(width), displayHeight_(height),
viewportWidth_(0), viewportHeight_(0)
{
initOpenGL();
setOrthoView();
//add updater task
Kernel::getInstance().addTask(shared_ptr<Task>(new UpdateTask()));
Application::getKernel().addTask(shared_ptr<Task>(new UpdateTask()));
}
VideoCore::~VideoCore()
{ }
void VideoCore::setOrthoView(int x, int y, int viewWidth, int viewHeight,
scalar orthoWidth, scalar orthoHeight)
{

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Audio_test.cpp,v 1.7 2005/07/20 07:30:13 cozman Exp $
// $Id: Audio_test.cpp,v 1.8 2005/08/02 23:07:53 cozman Exp $
#include "photon.hpp"
using namespace photon;
@ -23,7 +23,7 @@ class MainTask : public Task , public InputListener
public:
MainTask() :
Task("MainTask"),
video(video::VideoCore::getInstance())
video(Application::getVideoCore())
{
video.setOrthoView(800,600); // setup view
@ -197,20 +197,17 @@ public:
int main(const StrVec& args)
{
// create window
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
Application::getAppCore().createDisplay(800,600,32,0,0,false);
// create sound device
AudioCore::initAudioDevice("OSS");
Application::initAudioCore("OSS");
// be sure to add FPSDisplayTask
Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
Application::getKernel().addTask(TaskPtr(new FPSDisplayTask()));
// add the main task to the Kernel
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
Application::getKernel().addTask(TaskPtr(new MainTask()));
// run Kernel until task finishes
Kernel::getInstance().run();
Application::getKernel().run();
// destroy AudioCore, shuts down audio system
AudioCore::destroy();
return 0;
}
};

View File

@ -12,7 +12,7 @@ class FPSDisplayTask : public photon::Task
public:
FPSDisplayTask() :
Task("FPSDisplayTask", 1000000), // extremely low priority
app(photon::AppCore::getInstance()),
app(photon::Application::getAppCore()),
lastUpdate(0)
{ }

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Font_test.cpp,v 1.8 2005/07/20 07:30:13 cozman Exp $
// $Id: Font_test.cpp,v 1.9 2005/08/02 23:07:53 cozman Exp $
#include "photon.hpp"
using namespace photon;
@ -17,8 +17,8 @@ class MainTask : public Task
public:
MainTask() :
Task("MainTask"),
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
app(Application::getAppCore()),
video(Application::getVideoCore())
{
video.setOrthoView(800,600);
@ -59,13 +59,13 @@ public:
int main(const StrVec& args)
{
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
Application::getAppCore().createDisplay(800,600,32,0,0,false);
// be sure to add FPSDisplayTask
Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
Application::getKernel().addTask(TaskPtr(new FPSDisplayTask()));
Application::getKernel().addTask(TaskPtr(new MainTask()));
Kernel::getInstance().run();
Application::getKernel().run();
return 0;
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Image_test.cpp,v 1.7 2005/07/20 06:12:13 cozman Exp $
// $Id: Image_test.cpp,v 1.8 2005/08/02 23:07:53 cozman Exp $
#include "photon.hpp"
using namespace photon;
@ -17,8 +17,8 @@ class MainTask : public Task
public:
MainTask() :
Task("MainTask"),
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
app(Application::getAppCore()),
video(Application::getVideoCore())
{
video.setOrthoView(800,600);
@ -68,13 +68,13 @@ public:
int main(const StrVec& args)
{
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
Application::getAppCore().createDisplay(800,600,32,0,0,false);
// be sure to add FPSDisplayTask
Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
Kernel::getInstance().run();
Application::getKernel().addTask(TaskPtr(new FPSDisplayTask()));
Application::getKernel().addTask(TaskPtr(new MainTask()));
Application::getKernel().run();
return 0;
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Input_test.cpp,v 1.5 2005/07/20 07:30:13 cozman Exp $
// $Id: Input_test.cpp,v 1.6 2005/08/02 23:07:53 cozman Exp $
#include "photon.hpp"
using namespace photon;
@ -17,8 +17,8 @@ class MainTask : public Task, public InputListener
public:
MainTask() :
Task("MainTask"),
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
app(Application::getAppCore()),
video(Application::getVideoCore())
{
video.setOrthoView(800,600);
@ -123,13 +123,13 @@ public:
int main(const StrVec& args)
{
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
Application::getAppCore().createDisplay(800,600,32,0,0,false);
// be sure to add FPSDisplayTask
Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
Application::getKernel().addTask(TaskPtr(new FPSDisplayTask()));
Application::getKernel().addTask(TaskPtr(new MainTask()));
Kernel::getInstance().run();
Application::getKernel().run();
return 0;
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Pen_test.cpp,v 1.5 2005/07/20 06:12:13 cozman Exp $
// $Id: Pen_test.cpp,v 1.6 2005/08/02 23:07:53 cozman Exp $
#include "photon.hpp"
using namespace photon;
@ -17,8 +17,8 @@ class MainTask : public Task
public:
MainTask() :
Task("MainTask"),
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
app(Application::getAppCore()),
video(Application::getVideoCore())
{
video.setOrthoView(800,600);
@ -83,13 +83,13 @@ public:
int main(const StrVec& args)
{
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
Application::getAppCore().createDisplay(800,600,32,0,0,false);
// be sure to add FPSDisplayTask
Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
Application::getKernel().addTask(TaskPtr(new FPSDisplayTask()));
Application::getKernel().addTask(TaskPtr(new MainTask()));
Kernel::getInstance().run();
Application::getKernel().run();
return 0;
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Texture_test.cpp,v 1.6 2005/07/20 06:12:13 cozman Exp $
// $Id: Texture_test.cpp,v 1.7 2005/08/02 23:07:53 cozman Exp $
#include "photon.hpp"
using namespace photon;
@ -17,8 +17,8 @@ class MainTask : public Task
public:
MainTask() :
Task("MainTask"),
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
app(Application::getAppCore()),
video(Application::getVideoCore())
{
video.setOrthoView(800,600);
@ -83,13 +83,13 @@ public:
int main(const StrVec& args)
{
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
Application::getAppCore().createDisplay(800,600,32,0,0,false);
// be sure to add FPSDisplayTask
Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
Application::getKernel().addTask(TaskPtr(new FPSDisplayTask()));
Application::getKernel().addTask(TaskPtr(new MainTask()));
Kernel::getInstance().run();
Application::getKernel().run();
return 0;
}