1 /***************************************************************************
2                           main.cpp  -  description
3                              -------------------
4     begin                : Sat May 3 2003
5     copyright            : (C) 2003 by Gabor Torok
6     email                : cctorok@yahoo.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 #ifndef GRAPHICS_H
18 #define GRAPHICS_H
19 
20 #include <constants.h>
21 #include <preferences.h>
22 #include <render/renderlib.h>
23 #include "game.h"
24 
25 class Graphics : public MapAdapter {
26 private:
27   bool stencilBufferUsed;
28   int lastWidth, lastHeight;
29   SDL_Surface *screen;
30   GLint T0, Frames;
31   double fps;
32   int videoFlags;
33   Uint16 mouseX, mouseY;
34   bool mouseMovingOverMap;
35 
36 public:
37   Graphics();
38   ~Graphics();
39 
40   void mainLoop( Game *game );
41   void setVideoMode( Preferences * uc );
42 
43   // MapAdapter implementation
getScreenWidth()44   virtual inline int getScreenWidth() { return lastWidth; }
getScreenHeight()45   virtual inline int getScreenHeight() { return lastHeight; }
getMouseX()46   virtual inline Uint16 getMouseX() { return mouseX; }
getMouseY()47   virtual inline Uint16 getMouseY() { return mouseY; }
isMouseIsMovingOverMap()48   virtual inline bool isMouseIsMovingOverMap() { return mouseMovingOverMap; }
getPlayer()49   virtual inline RenderedCreature *getPlayer() { return NULL; }
setDebugStr(char * s)50   virtual inline void setDebugStr(char *s) {
51     //cerr << s << endl;
52   }
isMissionCreature(RenderedCreature * creature)53   virtual inline bool isMissionCreature( RenderedCreature *creature ) { return false; }
54   virtual inline void colorMiniMapPoint(int x, int y, Shape *shape, Location *pos=NULL) {}
eraseMiniMapPoint(int x,int y)55   virtual inline void eraseMiniMapPoint(int x, int y) {}
hasParty()56   virtual inline bool hasParty() { return false; }
getPartySize()57   virtual inline int getPartySize() { return 0; }
getParty(int index)58   virtual inline RenderedCreature *getParty( int index ) { return NULL; }
load(ItemInfo * info)59   virtual inline RenderedItem *load( ItemInfo *info ) { return NULL; }
load(CreatureInfo * info)60   virtual inline RenderedCreature *load( CreatureInfo *info ) { return NULL; }
loadMapData(const char * name)61   virtual inline void loadMapData( const char *name ) { }
saveMapData(const char * name)62   virtual inline void saveMapData( const char *name ) { }
getOutlineColor(Location * pos)63   virtual inline Color *getOutlineColor( Location *pos ) { return NULL; }
setView()64   virtual inline void setView() { setPerspective(); }
isLevelShaded()65   virtual bool isLevelShaded() { return false; }
66 
67 private:
68   void quit( int returnCode );
69   void setPerspective();
70   void resizeWindow( int width, int height );
71   void initGL( GLvoid );
72   bool testModesInFormat( SDL_PixelFormat *format, Uint32 flags );
73   int testModes( Uint32 flags, bool findMaxBpp );
74   void drawScreen( Game *game );
75 };
76 
77 #endif
78