* Replace VideoUpdate DirectX code with OpenGL initialization and a test sprite.
authorMatthijs Kooijman <m.kooijman@student.utwente.nl>
Mon, 11 Jun 2007 14:05:00 +0000 (16:05 +0200)
committerMatthijs Kooijman <m.kooijman@student.utwente.nl>
Mon, 11 Jun 2007 14:05:00 +0000 (16:05 +0200)
 * Enable debugging in the Makefile.

ABM2/Engine/VideoUpdate.cpp
ABM2/Engine/VideoUpdate.h
ABM2/Makefile

index 21cf1ab3b9be296118e7b957b6578f1e2d918422..270a67b07a22f9da440f72075da83c601969f0f1 100755 (executable)
@@ -6,6 +6,7 @@
 #include "../main.h"\r
 #include "VideoUpdate.h"\r
 \r
+\r
 // include the Direct3D Library file\r
 #ifdef WIN32\r
 #pragma comment (lib, "d3d9.lib")\r
@@ -25,48 +26,10 @@ int CVideoUpdate::scrBPP=16;
 \r
 CVideoUpdate::CVideoUpdate()\r
 {\r
-#ifdef WIN32\r
-       d3d = Direct3DCreate9(D3D_SDK_VERSION);\r
-\r
-       D3DPRESENT_PARAMETERS d3dpp;\r
-       D3DDISPLAYMODE d3ddm;\r
-       d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);\r
-\r
-       ZeroMemory(&d3dpp, sizeof(d3dpp));\r
-       d3dpp.Windowed = true;\r
-       d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;\r
-       d3dpp.hDeviceWindow = hWnd;\r
-       //d3dpp.BackBufferFormat = d3ddm.Format;\r
-       d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;\r
-       d3dpp.BackBufferWidth = scrWidth;\r
-       d3dpp.BackBufferHeight = scrHeight;\r
-\r
-\r
-       // create a device class using this information and the info from the d3dpp stuct\r
-       d3d->CreateDevice(D3DADAPTER_DEFAULT,\r
-                                                                               D3DDEVTYPE_HAL,\r
-                                                                               hWnd,\r
-                                                                               D3DCREATE_SOFTWARE_VERTEXPROCESSING,\r
-                                                                               &d3dpp,\r
-                                                                               &d3ddev);\r
-\r
-           // Turn on alpha-blending\r
-    d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);\r
-    // Set the render state up for source alpha blending.\r
-    d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);\r
-    d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);\r
-    // Get the alpha information solely from the texture.\r
-    d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1);\r
-    d3ddev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);\r
-#endif // WIN32\r
 }\r
 \r
 CVideoUpdate::~CVideoUpdate()\r
 {\r
-#ifdef WIN32\r
-    if (d3ddev != NULL) d3ddev->Release();\r
-    if (d3d != NULL) d3d->Release();\r
-#endif // WIN32\r
 }\r
 \r
 bool CVideoUpdate::Start()\r
@@ -96,29 +59,24 @@ bool CVideoUpdate::Start()
        //hide the mouse cursor\r
        SDL_ShowCursor(SDL_DISABLE);\r
 */\r
-#ifdef WIN32\r
-    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_COLORVALUE(0.0f, 0.4f, 1.0f, 1.0f), 1.0f, 0);\r
-\r
-    d3ddev->BeginScene();    // begins the 3D scene\r
-#endif // WIN32\r
+       this->g = new Graphics(scrWidth, scrHeight, 16, false);\r
+       if (this->g->createDisplay())\r
+               return false;\r
+       this->g->setCullingMode(AM_CULL_NONE);\r
+       this->g->setBackground(COLOUR_RGBA(127, 127, 127, 255));\r
 \r
-               return true;\r
+       this->s = new Sprite("Data/POWBOMB.png", COLOUR_RGBA(0, 0, 255, 255), 64, 64, this->g);\r
+       return true;\r
 }\r
 \r
 void CVideoUpdate::Update()\r
 {\r
-#ifdef WIN32\r
-       // end frame\r
-       d3ddev->EndScene();\r
-       d3ddev->Present(NULL, NULL, NULL, NULL);\r
-\r
-       // start new frame\r
-       d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_COLORVALUE(0.0f, 0.4f, 1.0f, 1.0f), 1.0f, 0);\r
-       d3ddev->BeginScene();\r
-#endif // WIN32\r
+       this->g->beginScene();\r
+       this->s->blit(0, 0, 1.0, 1.0, 0, 0, COLOUR_RGBA(255, 255, 255, 255));\r
+       this->g->endScene();\r
 }\r
 \r
 void CVideoUpdate::Stop()\r
 {\r
-//     SDL_QuitSubSystem(SDL_INIT_VIDEO);\r
+       delete this->g;\r
 }\r
index a859bd163b56c73ff0cd03171d9a5b520f2848df..e0f4bc212fc934fb00eb6d128da67e8d653259d7 100755 (executable)
@@ -9,13 +9,18 @@
 #pragma once\r
 #endif // _MSC_VER > 1000\r
 \r
-#ifdef WIN32\r
+#ifdef WITH_SDL\r
+#include <Amaltheia/Graphics.h>\r
+#include <Amaltheia/Sprite.h>\r
+\r
+#else // WITH_SDL\r
 #include <d3d9.h>\r
 #include <d3dx9.h>\r
 \r
 #include "engine.h"\r
 extern LPDIRECT3DDEVICE9 d3ddev;    // the pointer to the device class\r
-#endif // WIN32\r
+#endif // WITH_SDL\r
+\r
 class CVideoUpdate : public ITask  \r
 {\r
 public:\r
@@ -29,10 +34,13 @@ public:
        bool Start();\r
        void Update();\r
        void Stop();\r
-#ifdef WIN32\r
 private:\r
+#ifdef WITH_SDL\r
+       Graphics *g;\r
+       Sprite *s;\r
+#else\r
        LPDIRECT3D9 d3d;    // the pointer to our Direct3D interface\r
-#endif //WIN32\r
+#endif //WITH_SDL\r
 \r
 };\r
 #endif // !defined(AFX_VIDEOUPDATE_H__FB4B263B_4FA7_4700_BB70_EE5CB1768E83__INCLUDED_)\r
index e8997e35f6f373aef1124c6c9d665fd08f3201eb..91782ea944b50e43cbcec24d2d19c84359bace0e 100644 (file)
@@ -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