From b17f47041c9259eb6b7487df06da0be5fc5d1609 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 11 Jun 2007 16:05:00 +0200 Subject: [PATCH] * Replace VideoUpdate DirectX code with OpenGL initialization and a test sprite. * Enable debugging in the Makefile. --- ABM2/Engine/VideoUpdate.cpp | 66 +++++++------------------------------ ABM2/Engine/VideoUpdate.h | 16 ++++++--- ABM2/Makefile | 4 +-- 3 files changed, 26 insertions(+), 60 deletions(-) diff --git a/ABM2/Engine/VideoUpdate.cpp b/ABM2/Engine/VideoUpdate.cpp index 21cf1ab..270a67b 100755 --- a/ABM2/Engine/VideoUpdate.cpp +++ b/ABM2/Engine/VideoUpdate.cpp @@ -6,6 +6,7 @@ #include "../main.h" #include "VideoUpdate.h" + // include the Direct3D Library file #ifdef WIN32 #pragma comment (lib, "d3d9.lib") @@ -25,48 +26,10 @@ int CVideoUpdate::scrBPP=16; CVideoUpdate::CVideoUpdate() { -#ifdef WIN32 - 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); -#endif // WIN32 } CVideoUpdate::~CVideoUpdate() { -#ifdef WIN32 - if (d3ddev != NULL) d3ddev->Release(); - if (d3d != NULL) d3d->Release(); -#endif // WIN32 } bool CVideoUpdate::Start() @@ -96,29 +59,24 @@ bool CVideoUpdate::Start() //hide the mouse cursor SDL_ShowCursor(SDL_DISABLE); */ -#ifdef WIN32 - 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 -#endif // WIN32 + this->g = new Graphics(scrWidth, scrHeight, 16, false); + if (this->g->createDisplay()) + return false; + this->g->setCullingMode(AM_CULL_NONE); + this->g->setBackground(COLOUR_RGBA(127, 127, 127, 255)); - return true; + this->s = new Sprite("Data/POWBOMB.png", COLOUR_RGBA(0, 0, 255, 255), 64, 64, this->g); + return true; } void CVideoUpdate::Update() { -#ifdef WIN32 - // 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(); -#endif // WIN32 + this->g->beginScene(); + this->s->blit(0, 0, 1.0, 1.0, 0, 0, COLOUR_RGBA(255, 255, 255, 255)); + this->g->endScene(); } void CVideoUpdate::Stop() { -// SDL_QuitSubSystem(SDL_INIT_VIDEO); + delete this->g; } diff --git a/ABM2/Engine/VideoUpdate.h b/ABM2/Engine/VideoUpdate.h index a859bd1..e0f4bc2 100755 --- a/ABM2/Engine/VideoUpdate.h +++ b/ABM2/Engine/VideoUpdate.h @@ -9,13 +9,18 @@ #pragma once #endif // _MSC_VER > 1000 -#ifdef WIN32 +#ifdef WITH_SDL +#include +#include + +#else // WITH_SDL #include #include #include "engine.h" extern LPDIRECT3DDEVICE9 d3ddev; // the pointer to the device class -#endif // WIN32 +#endif // WITH_SDL + class CVideoUpdate : public ITask { public: @@ -29,10 +34,13 @@ public: bool Start(); void Update(); void Stop(); -#ifdef WIN32 private: +#ifdef WITH_SDL + Graphics *g; + Sprite *s; +#else LPDIRECT3D9 d3d; // the pointer to our Direct3D interface -#endif //WIN32 +#endif //WITH_SDL }; #endif // !defined(AFX_VIDEOUPDATE_H__FB4B263B_4FA7_4700_BB70_EE5CB1768E83__INCLUDED_) diff --git a/ABM2/Makefile b/ABM2/Makefile index e8997e3..91782ea 100644 --- a/ABM2/Makefile +++ b/ABM2/Makefile @@ -1,11 +1,11 @@ MAKE := make -CFLAGS := -I. -DWITH_SDL $(shell pkg-config --cflags ftgl) +CFLAGS := -I. -DWITH_SDL $(shell pkg-config --cflags ftgl) -g -O0 LDFLAGS := -lSDL $(shell pkg-config --libs ftgl) -lGL -lGLU -lILUT OBJS := main.o Engine/Log.o SchemeReader.o Engine/Settings.o \ Engine/mmanager.o Engine/Kernel.o Engine/ProfileLogHandler.o \ Engine/VideoUpdate.o Engine/GlobalTimer.o Engine/SoundTask.o \ Engine/profiler.o Playground.o Engine/InputTask.o \ - Amaltheia/Graphics.o + Amaltheia/Graphics.o Amaltheia/Sprite.o #include these in linking. Linking with -lftgl doesn't work for some stupid reason... EXTRA_OBJS := /usr/lib/libftgl.a -- 2.30.2