From f69a7933273e0992d9fc1c8fe26063a6b2d569ca Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 15 Mar 2005 18:52:07 +0000 Subject: [PATCH] post-Kernel --- include/video/VideoCore.hpp | 58 +++++++++++++++++++++++++------------ src/util/Timer.cpp | 5 ++-- src/video/VideoCore.cpp | 46 +++++++++++++++++++---------- 3 files changed, 72 insertions(+), 37 deletions(-) diff --git a/include/video/VideoCore.hpp b/include/video/VideoCore.hpp index 5d106ef..1e86ecb 100644 --- a/include/video/VideoCore.hpp +++ b/include/video/VideoCore.hpp @@ -5,13 +5,12 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: VideoCore.hpp,v 1.1 2005/03/02 08:40:11 cozman Exp $ +// $Id: VideoCore.hpp,v 1.2 2005/03/15 18:53:12 cozman Exp $ #ifndef PHOTON_VIDEO_VIDEOCORE_HPP #define PHOTON_VIDEO_VIDEOCORE_HPP #include "types.hpp" -#include "AppCore.hpp" #include "util/Singleton.hpp" namespace photon @@ -33,16 +32,22 @@ namespace video // class VideoCore : public util::Singleton { - +// Group: (Con/De)structors +public: + // Function: VideoCore + // Initialize underlying APIs and setup internals. + VideoCore(); + + // Function: ~VideoCore + // Shutdown underlying APIs. + ~VideoCore(); + // Group: Display Management public: + // Function: clearDisplay // Clears the display. void clear(); - - // Function: update - // Updates the video display. - void update(); // Group: Viewport // Functions to set the working viewport and perspective. Orthographic and @@ -62,7 +67,7 @@ public: // orthoHeight - Height of ortho perspective. void setOrthoView(int x, int y, int viewWidth, int viewHeight, scalar orthoWidth, scalar orthoHeight); - + // Function: setOrthoView // Sets entire screen as current viewport with a given ortho perspective. // @@ -70,7 +75,7 @@ public: // width - Width of view. // height - Height of view. void setOrthoView(scalar width, scalar height); - + // Function: setOrthoView // Sets entire screen as current viewport with a given ortho perspective. void setOrthoView(); @@ -127,6 +132,30 @@ public: // zNear - Distance from viewer to near clipping plane. // zFar - Distance from viewer to far clipping plane. void setPerspectiveProjection(scalar fovy, scalar zNear, scalar zFar); + +// Group: Display +public: + // Function: setDisplaySize + // Set the new display size, should be called whenever window size changes. + // + // Parameters: + // width - Width of display. + // height - height of display + void setDisplaySize(uint width, uint height); + + // 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(); // behind the scenes private: @@ -134,17 +163,10 @@ private: // data members private: - AppCore& appCore_; + uint displayWidth_; + uint displayHeight_; uint viewportWidth_; uint viewportHeight_; - -// Singleton-required code -private: - VideoCore(); - ~VideoCore(); - - friend class util::Singleton; - friend class std::auto_ptr; }; } diff --git a/src/util/Timer.cpp b/src/util/Timer.cpp index 39fe02c..bb4e9c3 100644 --- a/src/util/Timer.cpp +++ b/src/util/Timer.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: Timer.cpp,v 1.1 2005/03/02 08:44:16 cozman Exp $ +// $Id: Timer.cpp,v 1.2 2005/03/15 18:52:07 cozman Exp $ #include "util/Timer.hpp" @@ -55,8 +55,7 @@ double Timer::getTime() const if(paused_) { //when paused timer adjusted to subtract currently paused time - return appCore_.getTime() - - (pausedTime_ + (appCore_.getTime() - lastPause_)); + return lastPause_ - pausedTime_; } else { diff --git a/src/video/VideoCore.cpp b/src/video/VideoCore.cpp index 145f6f8..aff13ed 100644 --- a/src/video/VideoCore.cpp +++ b/src/video/VideoCore.cpp @@ -5,17 +5,30 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: VideoCore.cpp,v 1.1 2005/03/02 08:45:58 cozman Exp $ +// $Id: VideoCore.cpp,v 1.2 2005/03/15 18:53:27 cozman Exp $ #include "video/VideoCore.hpp" +#include "exceptions.hpp" + #include "gl/gl.h" -#include "glfw.h" +#include "gl/glu.h" namespace photon { namespace video { + +VideoCore::VideoCore() : + displayWidth_(0), displayHeight_(0), + viewportWidth_(0), viewportHeight_(0) +{ + initOpenGL(); +} + +VideoCore::~VideoCore() +{ +} void VideoCore::clear() { @@ -23,11 +36,6 @@ void VideoCore::clear() glClear(GL_COLOR_BUFFER_BIT); } -void VideoCore::update() -{ - // do nothing at the moment, handled in AppCore -} - void VideoCore::setOrthoView(int x, int y, int viewWidth, int viewHeight, scalar orthoWidth, scalar orthoHeight) { @@ -39,15 +47,15 @@ void VideoCore::setOrthoView(int x, int y, int viewWidth, int viewHeight, void VideoCore::setOrthoView(scalar width, scalar height) { // set viewport to fullscreen, then set ortho (alternative ratio) - setViewport(0, 0, appCore_.getDisplayWidth(), appCore_.getDisplayHeight()); + setViewport(0, 0, displayWidth_, displayHeight_); setOrthoProjection(width,height); } void VideoCore::setOrthoView() { // set viewport to fullscreen, then set ortho (1:1 ratio) - setViewport(0, 0, appCore_.getDisplayWidth(), appCore_.getDisplayHeight()); - setOrthoProjection(appCore_.getDisplayWidth(), appCore_.getDisplayHeight()); + setViewport(0, 0, displayWidth_, displayHeight_); + setOrthoProjection(displayWidth_, displayHeight_); } void VideoCore::setPerspectiveView(int x, int y, int width, int height, @@ -61,14 +69,14 @@ void VideoCore::setPerspectiveView(int x, int y, int width, int height, void VideoCore::setPerspectiveView(scalar fovy, scalar zNear, scalar zFar) { // set viewport fullscreen, then set perspective - setViewport(0, 0, appCore_.getDisplayWidth(), appCore_.getDisplayHeight()); + setViewport(0, 0, displayWidth_, displayHeight_); setPerspectiveProjection(fovy, zNear, zFar); } void VideoCore::setViewport(int x, int y, int width, int height) { // viewport described from bottom corner, so flip y - glViewport(x, appCore_.getDisplayHeight()-(y+height), width, height); + glViewport(x, displayHeight_-(y+height), width, height); viewportWidth_ = width; viewportHeight_ = height; } @@ -121,14 +129,20 @@ void VideoCore::initOpenGL() glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); } -VideoCore::VideoCore() : - appCore_(AppCore::getInstance()), viewportWidth_(0), viewportHeight_(0) +void VideoCore::setDisplaySize(uint width, uint height) { - initOpenGL(); + displayWidth_ = width; + displayHeight_ = height; } -VideoCore::~VideoCore() +uint VideoCore::getDisplayWidth() { + return displayWidth_; +} + +uint VideoCore::getDisplayHeight() +{ + return displayHeight_; } }