diff --git a/include/video/Color.hpp b/include/video/Color.hpp new file mode 100644 index 0000000..ede1e46 --- /dev/null +++ b/include/video/Color.hpp @@ -0,0 +1,88 @@ +//This file is part of Photon (http://photon.sourceforge.net) +//Copyright (C) 2004-2005 James Turk +// +// Author: +// James Turk (jpt2433@rit.edu) +// +// Version: +// $Id: Color.hpp,v 1.1 2005/03/02 08:40:11 cozman Exp $ + +#ifndef PHOTON_VIDEO_COLOR_HPP +#define PHOTON_VIDEO_COLOR_HPP + +#include + +#include "types.hpp" + +namespace photon +{ +namespace video +{ + +// Class: Color +// Class for storing components of a color. +// +// Operators: +// - ostream& << Color +class Color +{ +// Group: Variables +public: + // Variable: red + // Red component of color. (0-255) + ubyte red; + + // Variable: green + // Green component of color. (0-255) + ubyte green; + + // Variable: blue + // Blue component of color. (0-255) + ubyte blue; + + // Variable: alpha + // Alpha component of color. (0-255) + ubyte alpha; + +// Group: (Con/De)structors +public: + // Function: Color + // Initializes all components to 255. (Solid White) + Color(); + + // Function: Color + // Initializes color, component by component. + // + // Parameters: + // r - Value for red component. + // g - Value for green component. + // b - Value for blue component. + // a - Value for alpha component. [default: 255] + // + // See Also: + // + Color(ubyte r, ubyte g, ubyte b, ubyte a=255); + +// Group: Utility +public: + // Functions: setColor + // Creates color, component by component. + // + // Parameters: + // r - Value for red component. + // g - Value for green component. + // b - Value for blue component. + // a - Value for alpha component. [default: 255] + void setColor(ubyte r, ubyte g, ubyte b, ubyte a=255); + + // Functions: makeGLColor + // Makes the Color the current openGL color. (glColor4ub) + void makeGLColor() const; + + friend std::ostream& operator<<(std::ostream &o, const Color &rhs); +}; + +} +} + +#endif //PHOTON_VIDEO_COLOR_HPP diff --git a/include/video/VideoCore.hpp b/include/video/VideoCore.hpp new file mode 100644 index 0000000..5d106ef --- /dev/null +++ b/include/video/VideoCore.hpp @@ -0,0 +1,153 @@ +//This file is part of Photon (http://photon.sourceforge.net) +//Copyright (C) 2004-2005 James Turk +// +// Author: +// James Turk (jpt2433@rit.edu) +// +// Version: +// $Id: VideoCore.hpp,v 1.1 2005/03/02 08:40:11 cozman Exp $ + +#ifndef PHOTON_VIDEO_VIDEOCORE_HPP +#define PHOTON_VIDEO_VIDEOCORE_HPP + +#include "types.hpp" +#include "AppCore.hpp" +#include "util/Singleton.hpp" + +namespace photon +{ +namespace video +{ + +// Class: VideoCore +// 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: +// +// +// Parent: +// +class VideoCore : public util::Singleton +{ + +// 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 +// standard 3D perspective modes are available. +public: + // Function: setOrthoView + // Sets new ortho viewport within a rectangular portion of the screen. + // All drawing is relative to the rectangle, x,y becomes 0,0 and anything + // drawn outside rect is clipped. + // + // Parameters: + // x - X coord for top left corner of new viewport. + // y - Y coord for top left corner of new viewport. + // viewWidth - Width of new viewport. + // viewHeight - Height of new viewport. + // orthoWidth - Width of ortho perspective. + // 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. + // + // Parameters: + // 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(); + +// Group: Perspective +public: + // Function: setPerspectiveView + // Creates a viewport with a given 3D perspective inside of a rectangular + // portion of the screen. + // + // Parameters: + // x - X coord for top left corner of new viewport. + // y - Y coord for top left corner of new viewport. + // width - Width of new viewport. + // height - Height of new viewport. + // fovy - The y axis field of view angle, in degrees. + // zNear - Distance from viewer to near clipping plane. + // zFar - Distance from viewer to far clipping plane. + void setPerspectiveView(int x, int y, int width, int height, + scalar fovy, scalar zNear, scalar zFar); + + // Function: setPerspectiveView + // Sets entire screen as current viewport with a given 3D perspective. + // + // Same as call to setPerspective + // + // Parameters: + // fovy - The y axis field of view angle, in degrees. + // zNear - Distance from viewer to near clipping plane. + // zFar - Distance from viewer to far clipping plane. + void setPerspectiveView(scalar fovy, scalar zNear, scalar zFar); + +// Group: Viewport/Projection +// These functions are called by the above Ortho/Perspective functions, very +// rarely do they need to be called directly. +public: + // Function: setViewport + // Set the current viewport rectangle within the screen. + void setViewport(int x, int y, int width, int height); + + // Function: setOrthoProjection + // Sets an orthographic projection matrix. + // + // Parameters: + // width - Width of view. + // height - Height of view. + void setOrthoProjection(scalar width, scalar height); + + // Function: setPerspectiveProjection + // Sets a perspective projection matrix. + // + // Parameters: + // fovy - The y axis field of view angle, in degrees. + // zNear - Distance from viewer to near clipping plane. + // zFar - Distance from viewer to far clipping plane. + void setPerspectiveProjection(scalar fovy, scalar zNear, scalar zFar); + +// behind the scenes +private: + void initOpenGL(); + +// data members +private: + AppCore& appCore_; + uint viewportWidth_; + uint viewportHeight_; + +// Singleton-required code +private: + VideoCore(); + ~VideoCore(); + + friend class util::Singleton; + friend class std::auto_ptr; +}; + +} +} + +#endif //PHOTON_VIDEO_VIDEOCORE_HPP