1 // VideoUpdate.cpp: implementation of the CVideoUpdate class.
\r
3 //////////////////////////////////////////////////////////////////////
\r
7 #include "VideoUpdate.h"
\r
10 // include the Direct3D Library file
\r
12 #pragma comment (lib, "d3d9.lib")
\r
13 #pragma comment (lib, "d3dx9.lib")
\r
15 //////////////////////////////////////////////////////////////////////
\r
16 // Construction/Destruction
\r
17 //////////////////////////////////////////////////////////////////////
\r
18 LPDIRECT3DDEVICE9 d3ddev; // the pointer to the device class
\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
27 CVideoUpdate::CVideoUpdate()
\r
29 assert(screenWidth && screenHeight && screenBPP);
\r
30 this->g = new Graphics(scrWidth, scrHeight, 16, false);
\r
33 CVideoUpdate::~CVideoUpdate()
\r
37 bool CVideoUpdate::Start()
\r
40 if(-1==SDL_InitSubSystem(SDL_INIT_VIDEO))
\r
42 CLog::Get().Write(LOG_CLIENT,IDS_GENERIC_SUB_INIT_FAIL,"Video",SDL_GetError());
\r
45 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
\r
46 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
\r
47 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
\r
48 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
\r
49 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
\r
50 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
\r
52 int flags = SDL_OPENGL | SDL_ANYFORMAT | SDL_FULLSCREEN;
\r
54 if(!SDL_SetVideoMode(scrWidth, scrHeight, scrBPP, flags))
\r
56 CLog::Get().Write(LOG_CLIENT, IDS_BAD_DISPLAYMODE, scrWidth, scrHeight, scrBPP, SDL_GetError());
\r
60 //hide the mouse cursor
\r
61 SDL_ShowCursor(SDL_DISABLE);
\r
63 if (this->g->createDisplay())
\r
65 this->g->setCullingMode(AM_CULL_NONE);
\r
66 this->g->setBackground(COLOUR_RGBA(127, 127, 127, 255));
\r
68 /* Start a first scene */
\r
69 this->g->beginScene();
\r
73 void CVideoUpdate::Update()
\r
75 this->g->endScene();
\r
76 this->g->beginScene();
\r
79 void CVideoUpdate::Stop()
\r
81 /* End the last scene */
\r
82 this->g->endScene();
\r