From b08a63790c0fbeacb3f96a74e3eb15abe8c70dab Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 25 Jun 2012 19:59:17 +0200 Subject: SDL project - added (very basic) SDL template in CApplication and CEngine - split project into two targets: colobot_old (dependent on DirectX and WinAPI) and colobot_new (dependent on SDL and OpenGL) - moved sound.h/cpp to old/ and created new template in Snd namespace - added platform-independent dialog boxes in app/system.h/cpp --- src/graphics/common/camera.h | 1 - src/graphics/common/cloud.h | 2 +- src/graphics/common/device.cpp | 14 ++++++++++++ src/graphics/common/device.h | 22 ++++++++++++++++++ src/graphics/common/engine.cpp | 50 +++++++++++++++++++++++++++++++++++++++++ src/graphics/common/lightning.h | 4 ++-- src/graphics/common/model.h | 1 - src/graphics/common/particle.h | 2 +- src/graphics/common/planet.h | 1 - src/graphics/common/pyro.h | 8 ++++--- 10 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 src/graphics/common/device.cpp (limited to 'src/graphics/common') diff --git a/src/graphics/common/camera.h b/src/graphics/common/camera.h index 59e7609..28397b9 100644 --- a/src/graphics/common/camera.h +++ b/src/graphics/common/camera.h @@ -20,7 +20,6 @@ #pragma once #include "engine.h" -#include "common/struct.h" #include "common/event.h" diff --git a/src/graphics/common/cloud.h b/src/graphics/common/cloud.h index 579eb9a..9ca8c11 100644 --- a/src/graphics/common/cloud.h +++ b/src/graphics/common/cloud.h @@ -19,10 +19,10 @@ #pragma once -#include "common/struct.h" #include "common/event.h" #include "graphics/common/color.h" #include "math/point.h" +#include "math/vector.h" diff --git a/src/graphics/common/device.cpp b/src/graphics/common/device.cpp new file mode 100644 index 0000000..2e3db61 --- /dev/null +++ b/src/graphics/common/device.cpp @@ -0,0 +1,14 @@ +#include "graphics/common/device.h" + +//! Sets the default values +Gfx::DeviceConfig::DeviceConfig() +{ + width = 800; + height = 600; + bpp = 16; + fullScreen = false; + resizeable = false; + hardwareAccel = true; + doubleBuf = true; + noFrame = false; +} \ No newline at end of file diff --git a/src/graphics/common/device.h b/src/graphics/common/device.h index a8bf32c..cd52fa5 100644 --- a/src/graphics/common/device.h +++ b/src/graphics/common/device.h @@ -22,6 +22,28 @@ namespace Gfx { +struct DeviceConfig +{ + //! Screen width + int width; + //! Screen height + int height; + //! Bits per pixel + int bpp; + //! Full screen + bool fullScreen; + //! Resizeable window + bool resizeable; + //! Hardware acceleration + bool hardwareAccel; + //! Double buffering + bool doubleBuf; + //! No window frame (also set with full screen) + bool noFrame; + + DeviceConfig(); +}; + class CDevice { // TODO diff --git a/src/graphics/common/engine.cpp b/src/graphics/common/engine.cpp index acd0995..29857ce 100644 --- a/src/graphics/common/engine.cpp +++ b/src/graphics/common/engine.cpp @@ -19,5 +19,55 @@ #include "graphics/common/engine.h" +#include +#include + // TODO implementation + +Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app) +{ + // TODO +} + +Gfx::CEngine::~CEngine() +{ + // TODO +} + +int Gfx::CEngine::Render() +{ + /* Just a hello world for now */ + + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glShadeModel(GL_SMOOTH); + glDisable(GL_DEPTH_TEST); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-10.0f, 10.0f, -10.0f, 10.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + //glTranslatef(0.0f, 0.0f, -6.0f); + + glBegin(GL_TRIANGLES); + { + glColor3f(1.0f, 0.0f, 0.0f); + glVertex2f(-2.0f, -1.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex2f(2.0f, -1.0f); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex2f(0.0f, 1.5f); + } + glEnd(); + + glFlush(); + + return 1; +} diff --git a/src/graphics/common/lightning.h b/src/graphics/common/lightning.h index 2077954..8edf9e5 100644 --- a/src/graphics/common/lightning.h +++ b/src/graphics/common/lightning.h @@ -20,11 +20,11 @@ #pragma once #include "common/misc.h" -#include "common/struct.h" -#include "object/object.h" +#include "math/vector.h" class CInstanceManager; +class CObject; class CSound; diff --git a/src/graphics/common/model.h b/src/graphics/common/model.h index d67c71a..349c15c 100644 --- a/src/graphics/common/model.h +++ b/src/graphics/common/model.h @@ -20,7 +20,6 @@ #pragma once #include "engine.h" -#include "common/struct.h" #include "common/event.h" #include "modfile.h" #include "vertex.h" diff --git a/src/graphics/common/particle.h b/src/graphics/common/particle.h index 9e9fd36..4047cb5 100644 --- a/src/graphics/common/particle.h +++ b/src/graphics/common/particle.h @@ -305,7 +305,7 @@ protected: void DrawParticuleWheel(int i); CObject* SearchObjectGun(Math::Vector old, Math::Vector pos, ParticuleType type, CObject *father); CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticuleType type, CObject *father); - void Play(Sound sound, Math::Vector pos, float amplitude); + void Play(Snd::Sound sound, Math::Vector pos, float amplitude); bool TrackMove(int i, Math::Vector pos, float progress); void TrackDraw(int i, ParticuleType type); diff --git a/src/graphics/common/planet.h b/src/graphics/common/planet.h index 2bf4d99..4ffccfc 100644 --- a/src/graphics/common/planet.h +++ b/src/graphics/common/planet.h @@ -19,7 +19,6 @@ #pragma once -#include "common/struct.h" #include "common/event.h" #include "math/point.h" diff --git a/src/graphics/common/pyro.h b/src/graphics/common/pyro.h index 704febf..e6b5844 100644 --- a/src/graphics/common/pyro.h +++ b/src/graphics/common/pyro.h @@ -19,9 +19,11 @@ #pragma once -#include "graphics/common/engine.h" -#include "object/object.h" #include "common/misc.h" +#include "graphics/common/engine.h" +//#include "object/object.h" +// TEMPORARILY! +enum ObjectType {}; class CInstanceManager; @@ -93,7 +95,7 @@ public: CPyro(CInstanceManager* iMan); ~CPyro(); - void DeleteObject(bool bAll=FALSE); + void DeleteObject(bool bAll=false); bool Create(PyroType type, CObject* pObj, float force=1.0f); bool EventProcess(const Event &event); Error IsEnded(); -- cgit v1.2.3-1-g7c22