* Replace VideoUpdate DirectX code with OpenGL initialization and a test sprite.
[matthijs/ABM2.git] / ABM2 / Engine / VideoUpdate.cpp
1 // VideoUpdate.cpp: implementation of the CVideoUpdate class.\r
2 //\r
3 //////////////////////////////////////////////////////////////////////\r
4 \r
5 #include "engine.h"\r
6 #include "../main.h"\r
7 #include "VideoUpdate.h"\r
8 \r
9 \r
10 // include the Direct3D Library file\r
11 #ifdef WIN32\r
12 #pragma comment (lib, "d3d9.lib")\r
13 #pragma comment (lib, "d3dx9.lib")\r
14 \r
15 //////////////////////////////////////////////////////////////////////\r
16 // Construction/Destruction\r
17 //////////////////////////////////////////////////////////////////////\r
18 LPDIRECT3DDEVICE9 d3ddev;    // the pointer to the device class\r
19 #endif //WIN32\r
20 CMMPointer<Dator<int> > CVideoUpdate::screenWidth=0;\r
21 CMMPointer<Dator<int> > CVideoUpdate::screenHeight=0;\r
22 CMMPointer<Dator<int> > CVideoUpdate::screenBPP=0;\r
23 int CVideoUpdate::scrWidth=640;\r
24 int CVideoUpdate::scrHeight=480;\r
25 int CVideoUpdate::scrBPP=16;\r
26 \r
27 CVideoUpdate::CVideoUpdate()\r
28 {\r
29 }\r
30 \r
31 CVideoUpdate::~CVideoUpdate()\r
32 {\r
33 }\r
34 \r
35 bool CVideoUpdate::Start()\r
36 {\r
37         assert(screenWidth && screenHeight && screenBPP);\r
38 /*\r
39         if(-1==SDL_InitSubSystem(SDL_INIT_VIDEO))\r
40         {\r
41                 CLog::Get().Write(LOG_CLIENT,IDS_GENERIC_SUB_INIT_FAIL,"Video",SDL_GetError());\r
42                 return false;\r
43         }\r
44         SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );\r
45         SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );\r
46         SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );\r
47         SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );\r
48         SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );\r
49         SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );\r
50 \r
51         int flags = SDL_OPENGL | SDL_ANYFORMAT | SDL_FULLSCREEN;\r
52 \r
53         if(!SDL_SetVideoMode(scrWidth, scrHeight, scrBPP, flags))\r
54         {\r
55                 CLog::Get().Write(LOG_CLIENT, IDS_BAD_DISPLAYMODE, scrWidth, scrHeight, scrBPP, SDL_GetError());\r
56                 return false;\r
57         }\r
58 \r
59         //hide the mouse cursor\r
60         SDL_ShowCursor(SDL_DISABLE);\r
61 */\r
62         this->g = new Graphics(scrWidth, scrHeight, 16, false);\r
63         if (this->g->createDisplay())\r
64                 return false;\r
65         this->g->setCullingMode(AM_CULL_NONE);\r
66         this->g->setBackground(COLOUR_RGBA(127, 127, 127, 255));\r
67 \r
68         this->s = new Sprite("Data/POWBOMB.png", COLOUR_RGBA(0, 0, 255, 255), 64, 64, this->g);\r
69         return true;\r
70 }\r
71 \r
72 void CVideoUpdate::Update()\r
73 {\r
74         this->g->beginScene();\r
75         this->s->blit(0, 0, 1.0, 1.0, 0, 0, COLOUR_RGBA(255, 255, 255, 255));\r
76         this->g->endScene();\r
77 }\r
78 \r
79 void CVideoUpdate::Stop()\r
80 {\r
81         delete this->g;\r
82 }\r