post-Kernel
This commit is contained in:
parent
0ef66e5017
commit
f69a793327
@ -5,13 +5,12 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// 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
|
#ifndef PHOTON_VIDEO_VIDEOCORE_HPP
|
||||||
#define PHOTON_VIDEO_VIDEOCORE_HPP
|
#define PHOTON_VIDEO_VIDEOCORE_HPP
|
||||||
|
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
#include "AppCore.hpp"
|
|
||||||
#include "util/Singleton.hpp"
|
#include "util/Singleton.hpp"
|
||||||
|
|
||||||
namespace photon
|
namespace photon
|
||||||
@ -33,17 +32,23 @@ namespace video
|
|||||||
// <Singleton>
|
// <Singleton>
|
||||||
class VideoCore : public util::Singleton<VideoCore>
|
class VideoCore : public util::Singleton<VideoCore>
|
||||||
{
|
{
|
||||||
|
// Group: (Con/De)structors
|
||||||
|
public:
|
||||||
|
// Function: VideoCore
|
||||||
|
// Initialize underlying APIs and setup <Task> internals.
|
||||||
|
VideoCore();
|
||||||
|
|
||||||
|
// Function: ~VideoCore
|
||||||
|
// Shutdown underlying APIs.
|
||||||
|
~VideoCore();
|
||||||
|
|
||||||
// Group: Display Management
|
// Group: Display Management
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Function: clearDisplay
|
// Function: clearDisplay
|
||||||
// Clears the display.
|
// Clears the display.
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// Function: update
|
|
||||||
// Updates the video display.
|
|
||||||
void update();
|
|
||||||
|
|
||||||
// Group: Viewport
|
// Group: Viewport
|
||||||
// Functions to set the working viewport and perspective. Orthographic and
|
// Functions to set the working viewport and perspective. Orthographic and
|
||||||
// standard 3D perspective modes are available.
|
// standard 3D perspective modes are available.
|
||||||
@ -128,23 +133,40 @@ public:
|
|||||||
// zFar - Distance from viewer to far clipping plane.
|
// zFar - Distance from viewer to far clipping plane.
|
||||||
void setPerspectiveProjection(scalar fovy, scalar zNear, scalar zFar);
|
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
|
// behind the scenes
|
||||||
private:
|
private:
|
||||||
void initOpenGL();
|
void initOpenGL();
|
||||||
|
|
||||||
// data members
|
// data members
|
||||||
private:
|
private:
|
||||||
AppCore& appCore_;
|
uint displayWidth_;
|
||||||
|
uint displayHeight_;
|
||||||
uint viewportWidth_;
|
uint viewportWidth_;
|
||||||
uint viewportHeight_;
|
uint viewportHeight_;
|
||||||
|
|
||||||
// Singleton-required code
|
|
||||||
private:
|
|
||||||
VideoCore();
|
|
||||||
~VideoCore();
|
|
||||||
|
|
||||||
friend class util::Singleton<VideoCore>;
|
|
||||||
friend class std::auto_ptr<VideoCore>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// 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"
|
#include "util/Timer.hpp"
|
||||||
|
|
||||||
@ -55,8 +55,7 @@ double Timer::getTime() const
|
|||||||
if(paused_)
|
if(paused_)
|
||||||
{
|
{
|
||||||
//when paused timer adjusted to subtract currently paused time
|
//when paused timer adjusted to subtract currently paused time
|
||||||
return appCore_.getTime() -
|
return lastPause_ - pausedTime_;
|
||||||
(pausedTime_ + (appCore_.getTime() - lastPause_));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5,29 +5,37 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// 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 "video/VideoCore.hpp"
|
||||||
|
|
||||||
|
#include "exceptions.hpp"
|
||||||
|
|
||||||
#include "gl/gl.h"
|
#include "gl/gl.h"
|
||||||
#include "glfw.h"
|
#include "gl/glu.h"
|
||||||
|
|
||||||
namespace photon
|
namespace photon
|
||||||
{
|
{
|
||||||
namespace video
|
namespace video
|
||||||
{
|
{
|
||||||
|
|
||||||
|
VideoCore::VideoCore() :
|
||||||
|
displayWidth_(0), displayHeight_(0),
|
||||||
|
viewportWidth_(0), viewportHeight_(0)
|
||||||
|
{
|
||||||
|
initOpenGL();
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoCore::~VideoCore()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void VideoCore::clear()
|
void VideoCore::clear()
|
||||||
{
|
{
|
||||||
// TODO: clear depth/stencil if requested
|
// TODO: clear depth/stencil if requested
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
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,
|
void VideoCore::setOrthoView(int x, int y, int viewWidth, int viewHeight,
|
||||||
scalar orthoWidth, scalar orthoHeight)
|
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)
|
void VideoCore::setOrthoView(scalar width, scalar height)
|
||||||
{
|
{
|
||||||
// set viewport to fullscreen, then set ortho (alternative ratio)
|
// set viewport to fullscreen, then set ortho (alternative ratio)
|
||||||
setViewport(0, 0, appCore_.getDisplayWidth(), appCore_.getDisplayHeight());
|
setViewport(0, 0, displayWidth_, displayHeight_);
|
||||||
setOrthoProjection(width,height);
|
setOrthoProjection(width,height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoCore::setOrthoView()
|
void VideoCore::setOrthoView()
|
||||||
{
|
{
|
||||||
// set viewport to fullscreen, then set ortho (1:1 ratio)
|
// set viewport to fullscreen, then set ortho (1:1 ratio)
|
||||||
setViewport(0, 0, appCore_.getDisplayWidth(), appCore_.getDisplayHeight());
|
setViewport(0, 0, displayWidth_, displayHeight_);
|
||||||
setOrthoProjection(appCore_.getDisplayWidth(), appCore_.getDisplayHeight());
|
setOrthoProjection(displayWidth_, displayHeight_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoCore::setPerspectiveView(int x, int y, int width, int height,
|
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)
|
void VideoCore::setPerspectiveView(scalar fovy, scalar zNear, scalar zFar)
|
||||||
{
|
{
|
||||||
// set viewport fullscreen, then set perspective
|
// set viewport fullscreen, then set perspective
|
||||||
setViewport(0, 0, appCore_.getDisplayWidth(), appCore_.getDisplayHeight());
|
setViewport(0, 0, displayWidth_, displayHeight_);
|
||||||
setPerspectiveProjection(fovy, zNear, zFar);
|
setPerspectiveProjection(fovy, zNear, zFar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoCore::setViewport(int x, int y, int width, int height)
|
void VideoCore::setViewport(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
// viewport described from bottom corner, so flip y
|
// 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;
|
viewportWidth_ = width;
|
||||||
viewportHeight_ = height;
|
viewportHeight_ = height;
|
||||||
}
|
}
|
||||||
@ -121,14 +129,20 @@ void VideoCore::initOpenGL()
|
|||||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoCore::VideoCore() :
|
void VideoCore::setDisplaySize(uint width, uint height)
|
||||||
appCore_(AppCore::getInstance()), viewportWidth_(0), viewportHeight_(0)
|
|
||||||
{
|
{
|
||||||
initOpenGL();
|
displayWidth_ = width;
|
||||||
|
displayHeight_ = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoCore::~VideoCore()
|
uint VideoCore::getDisplayWidth()
|
||||||
{
|
{
|
||||||
|
return displayWidth_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint VideoCore::getDisplayHeight()
|
||||||
|
{
|
||||||
|
return displayHeight_;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user