X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=ABM2%2FEngine%2FVideoUpdate.cpp;h=e3f36c585e29616602c53f7f1f8fcd7b04afb29d;hb=75d4212e8548f64904bad6d7f8978c077e6687d0;hp=14f60440f6f99518e7efe50a83a3c6da6e5e854f;hpb=6332ae522f34b2811b62b83e9a44545f0c72cba3;p=matthijs%2FABM2.git diff --git a/ABM2/Engine/VideoUpdate.cpp b/ABM2/Engine/VideoUpdate.cpp index 14f6044..e3f36c5 100755 --- a/ABM2/Engine/VideoUpdate.cpp +++ b/ABM2/Engine/VideoUpdate.cpp @@ -6,16 +6,7 @@ #include "../main.h" #include "VideoUpdate.h" -// include the Direct3D Library file -#ifdef WIN32 -#pragma comment (lib, "d3d9.lib") -#pragma comment (lib, "d3dx9.lib") -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -LPDIRECT3DDEVICE9 d3ddev; // the pointer to the device class -#endif //WIN32 CMMPointer > CVideoUpdate::screenWidth=0; CMMPointer > CVideoUpdate::screenHeight=0; CMMPointer > CVideoUpdate::screenBPP=0; @@ -23,52 +14,18 @@ int CVideoUpdate::scrWidth=640; int CVideoUpdate::scrHeight=480; int CVideoUpdate::scrBPP=16; -#ifdef WIN32 -CVideoUpdate::CVideoUpdate() +CVideoUpdate::CVideoUpdate(CKernel* kernel) : ITask(kernel) { - d3d = Direct3DCreate9(D3D_SDK_VERSION); - - D3DPRESENT_PARAMETERS d3dpp; - D3DDISPLAYMODE d3ddm; - d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); - - ZeroMemory(&d3dpp, sizeof(d3dpp)); - d3dpp.Windowed = true; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.hDeviceWindow = hWnd; - //d3dpp.BackBufferFormat = d3ddm.Format; - d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; - d3dpp.BackBufferWidth = scrWidth; - d3dpp.BackBufferHeight = scrHeight; - - - // create a device class using this information and the info from the d3dpp stuct - d3d->CreateDevice(D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, - hWnd, - D3DCREATE_SOFTWARE_VERTEXPROCESSING, - &d3dpp, - &d3ddev); - - // Turn on alpha-blending - d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - // Set the render state up for source alpha blending. - d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - // Get the alpha information solely from the texture. - d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - d3ddev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + assert(screenWidth && screenHeight && screenBPP); + this->g = new Graphics(scrWidth, scrHeight, 16, false); } CVideoUpdate::~CVideoUpdate() { - if (d3ddev != NULL) d3ddev->Release(); - if (d3d != NULL) d3d->Release(); } bool CVideoUpdate::Start() { - assert(screenWidth && screenHeight && screenBPP); /* if(-1==SDL_InitSubSystem(SDL_INIT_VIDEO)) { @@ -93,26 +50,25 @@ bool CVideoUpdate::Start() //hide the mouse cursor SDL_ShowCursor(SDL_DISABLE); */ - d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_COLORVALUE(0.0f, 0.4f, 1.0f, 1.0f), 1.0f, 0); - - d3ddev->BeginScene(); // begins the 3D scene - - return true; + if (this->g->createDisplay()) + return false; + this->g->setCullingMode(AM_CULL_NONE); + this->g->setBackground(COLOUR_RGBA(127, 127, 127, 255)); + + /* Start a first scene */ + this->g->beginScene(); + return true; } void CVideoUpdate::Update() { - // end frame - d3ddev->EndScene(); - d3ddev->Present(NULL, NULL, NULL, NULL); - - // start new frame - d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_COLORVALUE(0.0f, 0.4f, 1.0f, 1.0f), 1.0f, 0); - d3ddev->BeginScene(); + this->g->endScene(); + this->g->beginScene(); } void CVideoUpdate::Stop() { -// SDL_QuitSubSystem(SDL_INIT_VIDEO); + /* End the last scene */ + this->g->endScene(); + delete this->g; } -#endif // WIN32