AppCore now does Applications job completely

This commit is contained in:
James Turk 2005-03-02 08:40:51 +00:00
parent 51bed3105e
commit a9eebf6266
3 changed files with 43 additions and 20 deletions

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: AppCore.hpp,v 1.2 2005/03/01 07:51:04 cozman Exp $
// $Id: AppCore.hpp,v 1.3 2005/03/02 08:40:51 cozman Exp $
#ifndef PHOTON_APPCORE_HPP
#define PHOTON_APPCORE_HPP
@ -67,10 +67,6 @@ public:
uint depthBits, uint stencilBits, bool fullscreen,
const std::string &title);
// Function: updateDisplay
// Updates the display, usually involves flipping the front/back buffers.
void updateDisplay();
// Group: Input
public:
@ -127,10 +123,10 @@ public:
// been running.
scalar getTime();
// Group: Application
// Group: General
public:
// Function: update
// Updates the
// Updates the internals of the application, including the display.
void update();
// Function: setTitle
@ -175,8 +171,26 @@ public:
// Current frames per second.
double getFramerate();
// Group: Accessors
public:
// Function: getDisplayWidth
// Get the width of the display.
//
// Returns:
// Width of display in pixels.
uint getDisplayWidth();
// Function: getDisplayHeight
// Get the height of the display.
//
// Returns:
// Height of display in pixels.
uint getDisplayHeight();
// data members
private:
uint dispWidth_;
uint dispHeight_;
bool quitRequested_;
bool active_;
bool timerPaused_;

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Application.hpp,v 1.5 2005/03/01 07:51:04 cozman Exp $
// $Id: Application.hpp,v 1.6 2005/03/02 08:40:51 cozman Exp $
#ifndef PHOTON_APPLICATION_HPP
#define PHOTON_APPLICATION_HPP
@ -76,12 +76,6 @@ private:
// Data Members
private:
scalar secPerFrame_;
scalar lastUpdate_;
bool active_;
bool unpauseOnActive_;
bool quitRequested_;
// version number for photon
util::VersionInfo photonVer_;

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: AppCore.cpp,v 1.2 2005/03/01 07:52:20 cozman Exp $
// $Id: AppCore.cpp,v 1.3 2005/03/02 08:43:33 cozman Exp $
#include "AppCore.hpp"
@ -30,6 +30,9 @@ void AppCore::createDisplay(uint width, uint height,
throw APIError("Failed to create display.");
}
dispWidth_ = width;
dispHeight_ = height;
glfwSetWindowTitle(title.c_str()); // title is set separately
}
@ -56,14 +59,12 @@ void AppCore::createDisplay(uint width, uint height, uint bpp,
createDisplay(width, height, 8, 8, 8, 8, depthBits, stencilBits,
fullscreen, title);
break;
default:
throw ArgumentException("bpp argument of createDisplay must be "
"8,16,24, or 32.");
}
}
void AppCore::updateDisplay()
{
glfwSwapBuffers();
}
bool AppCore::keyPressed(KeyCode key)
{
return glfwGetKey(key) == GLFW_PRESS;
@ -102,6 +103,9 @@ void AppCore::update()
{
scalar curTime = getTime();
// update the display here instead of VideoCore (since it belongs to glfw)
glfwSwapBuffers();
// keep track of time between frames
secPerFrame_ = curTime-lastUpdate_;
lastUpdate_ = curTime;
@ -162,6 +166,16 @@ double AppCore::getFramerate()
return 1/secPerFrame_;
}
uint AppCore::getDisplayWidth()
{
return dispWidth_;
}
uint AppCore::getDisplayHeight()
{
return dispHeight_;
}
util::VersionInfo AppCore::initGLFW()
{
int maj,min,patch;
@ -174,6 +188,7 @@ util::VersionInfo AppCore::initGLFW()
}
AppCore::AppCore() :
dispWidth_(0), dispHeight_(0),
quitRequested_(true), active_(false), timerPaused_(false),
unpauseOnActive_(false), lastPause_(0), pausedTime_(0),
secPerFrame_(0), lastUpdate_(0)