fysxasteroids/engine/ViewBase.h

99 lines
2.7 KiB
C++

#ifndef _VIEWBASE_H
#define _VIEWBASE_H
#include "Engine.h"
// forward declarations for the OGLFT fonts
namespace OGLFT {
class Monochrome;
}
namespace Engine {
class Module;
class ModelBase;
class CameraBase;
class OverlayBase;
/** \brief Performs the actual drawing based on Camera and Model
*/
class ViewBase : public Module{
public:
/** \brief Resizes the View */
void Resize (int width, int height);
/** \brief Performs all drawing */
virtual void Draw ();
/** \brief Draws a string at the given position using current projection
* and modelview matrices */
void DrawGLString (float x, float y, const char* str);
/** \brief Stores the eye poisition in eye_out */
void GetCamereEye (float *eye_out);
/** \brief Calculates the world coordinates to given screen coordinates */
void CalcWorldCoordinates (int screen_x, int screen_y, float world_y, float *pos_out);
unsigned int GetWindowWidth () { return mWindowWidth; };
unsigned int GetWindowHeight () { return mWindowHeight; };
int GetFrameRate() { return mFrameRate; };
void SetDrawAxis (bool draw_axis) { mDrawGrid = draw_axis; };
bool GetDrawAxis () { return mDrawGrid; };
void SetDrawGrid (bool draw_grid) { mDrawGrid = draw_grid; };
bool GetDrawGrid () { return mDrawGrid; };
void SetGridSize (int x, int z) { mGridSizeX = x; mGridSizeZ = z; }
void AddOverlay (OverlayBase *overlay) { mOverlays.push_back (overlay); };
/* Input forwarding for the overlays */
bool SendKeyDown (const SDL_keysym &keysym);
bool SendKeyUp (const SDL_keysym &keysym);
bool SendMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos);
bool SendMouseButtonDown (Uint8 button, Uint16 xpos, Uint16 ypos);
protected:
/** \brief Initializes the system */
int OnInit (int argc, char* argv[]);
/** \brief Destroys the system (must be called!) */
void OnDestroy ();
/** \brief Updates the camera for further drawing */
virtual void UpdateCamera ();
/** \brief Draws a grid of 16 x 16 tiles */
void DrawGrid ();
/** \brief Draws the level and all the visible Entities */
virtual void DrawWorld ();
/** \brief Draws orthographic overlay*/
void DrawOverlay2D ();
ModelBase *mModel;
CameraBase *mCamera;
std::vector<OverlayBase*> mOverlays;
/** \brief The height of the canvas we're drawing on */
unsigned int mWindowHeight;
/** \brief The width of the canvas we're drawing on */
unsigned int mWindowWidth;
/** \brief Stores the current frame rate */
int mFrameRate;
bool mDrawAxis;
bool mDrawGrid;
int mGridSizeX;
int mGridSizeZ;
/** \brief Font that is used in the console */
OGLFT::Monochrome* mConsoleFont;
friend class Engine;
};
}
#include "ViewBaseGlobal.h"
#endif // _VIEWBase_H