2010-04-05 23:38:59 +02:00
|
|
|
#ifndef _VIEWBASE_H
|
|
|
|
#define _VIEWBASE_H
|
|
|
|
|
|
|
|
#include "Engine.h"
|
2010-06-06 01:22:01 +02:00
|
|
|
#include "EngineEnums.h"
|
2010-04-14 22:01:45 +02:00
|
|
|
#include "OverlayBase.h"
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
// forward declarations for the OGLFT fonts
|
|
|
|
namespace OGLFT {
|
|
|
|
class Monochrome;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Engine {
|
|
|
|
|
|
|
|
class Module;
|
|
|
|
class ModelBase;
|
|
|
|
class CameraBase;
|
|
|
|
|
|
|
|
/** \brief Performs the actual drawing based on Camera and Model
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ViewBase : public Module{
|
|
|
|
public:
|
2010-05-02 22:39:49 +02:00
|
|
|
ViewBase() : mModel(NULL), mCamera(NULL), mCurrentFont(NULL) {}
|
2010-04-14 22:01:45 +02:00
|
|
|
virtual ~ViewBase() {};
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
/** \brief Resizes the View */
|
|
|
|
void Resize (int width, int height);
|
|
|
|
|
2010-09-11 02:28:50 +02:00
|
|
|
/** \brief Performs actions before drawing (e.g. timer stuff) */
|
|
|
|
void PreDraw();
|
|
|
|
/** \brief Performs actions after drawing (e.g. swapping of buffers, etc.) */
|
|
|
|
void PostDraw();
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
/** \brief Performs all drawing */
|
|
|
|
virtual void Draw ();
|
|
|
|
|
2010-05-02 22:39:49 +02:00
|
|
|
/* Fonts */
|
2010-11-01 22:33:14 +01:00
|
|
|
|
|
|
|
/** \brief Selects a font with a given specification or loads it if it was not found
|
|
|
|
*
|
|
|
|
* Fonts can be specified by strings such as
|
|
|
|
* "name=default.ttf color=#ff0000 size=12"
|
|
|
|
* "color=#ff00ff size=12 otherfont.ttf"
|
|
|
|
* "myfont.ttf"
|
|
|
|
* for which the appropriate values will be parsed.
|
2010-06-06 00:58:11 +02:00
|
|
|
*
|
2010-11-01 22:33:14 +01:00
|
|
|
* Default size is 12 and default color is white (#ffffff).
|
2010-06-06 00:58:11 +02:00
|
|
|
*/
|
2010-11-01 22:33:14 +01:00
|
|
|
void SelectFont (const char *font_spec);
|
|
|
|
void SetFontJustification (FontJustification justification);
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
/** \brief Draws a string at the given position using current projection
|
|
|
|
* and modelview matrices */
|
|
|
|
void DrawGLString (float x, float y, const char* str);
|
2010-08-29 23:59:24 +02:00
|
|
|
/** \brief Computes the width and height of the rasterized string */
|
|
|
|
void DrawGLStringMeasure (const char* str, float *width, float *height);
|
2010-05-02 22:39:49 +02:00
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
/** \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; }
|
|
|
|
|
2010-06-06 00:58:11 +02:00
|
|
|
// void AddOverlay (OverlayBasePtr overlay) { mOverlays.push_back (overlay); };
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
/* Input forwarding for the overlays */
|
2010-06-06 00:58:11 +02:00
|
|
|
/*
|
2010-04-05 23:38:59 +02:00
|
|
|
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);
|
2010-06-06 00:58:11 +02:00
|
|
|
*/
|
2010-04-05 23:38:59 +02:00
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
private:
|
2010-04-05 23:38:59 +02:00
|
|
|
protected:
|
|
|
|
/** \brief Initializes the system */
|
2010-04-14 22:01:45 +02:00
|
|
|
virtual int OnInit (int argc, char* argv[]);
|
2010-04-05 23:38:59 +02:00
|
|
|
/** \brief Destroys the system (must be called!) */
|
2010-04-14 22:01:45 +02:00
|
|
|
virtual void OnDestroy ();
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
/** \brief Updates the camera for further drawing */
|
|
|
|
virtual void UpdateCamera ();
|
|
|
|
/** \brief Draws the level and all the visible Entities */
|
|
|
|
virtual void DrawWorld ();
|
|
|
|
/** \brief Draws orthographic overlay*/
|
|
|
|
void DrawOverlay2D ();
|
|
|
|
|
2010-09-16 00:04:39 +02:00
|
|
|
/** \brief Draws a grid of 16 x 16 tiles */
|
|
|
|
void DrawGrid ();
|
|
|
|
bool mDrawGrid;
|
|
|
|
|
2010-11-01 22:33:14 +01:00
|
|
|
/** \brief Loads a font that was not yet loaded */
|
|
|
|
bool LoadFont (const std::string &font_spec_string);
|
2010-09-16 00:04:39 +02:00
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
ModelBase *mModel;
|
|
|
|
CameraBase *mCamera;
|
|
|
|
|
2010-06-06 00:58:11 +02:00
|
|
|
OverlayManager mOverlayManager;
|
|
|
|
|
|
|
|
// std::vector<OverlayBasePtr> mOverlays;
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
/** \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;
|
|
|
|
|
|
|
|
int mGridSizeX;
|
|
|
|
int mGridSizeZ;
|
|
|
|
|
2010-05-02 22:39:49 +02:00
|
|
|
/** \brief The font that is currently used */
|
|
|
|
OGLFT::Monochrome* mCurrentFont;
|
|
|
|
|
|
|
|
/** \brief Contains all the fonts that are to be used */
|
|
|
|
std::map<std::string, OGLFT::Monochrome*> mFonts;
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
friend class Engine;
|
2010-06-06 00:58:11 +02:00
|
|
|
friend class ControllerBase;
|
2010-04-05 23:38:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "ViewBaseGlobal.h"
|
|
|
|
|
|
|
|
#endif // _VIEWBase_H
|