of includes in a few source files.legacy
@@ -6,7 +6,8 @@ noinst_LIBRARIES = libcommon.a | |||
libcommon_a_SOURCES = \ | |||
game.cpp game.h tiler.cpp tiler.h tileset.cpp tileset.h \ | |||
scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \ | |||
joystick.cpp joystick.h asset.cpp asset.h ticker.cpp ticker.h | |||
joystick.cpp joystick.h asset.cpp asset.h ticker.cpp ticker.h \ | |||
video.cpp video.h | |||
libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` | |||
test_map_SOURCES = test-map.cpp sdlvideo.cpp sdlvideo.h sdlinput.cpp sdlinput.h | |||
@@ -10,11 +10,8 @@ | |||
#include <cstdio> | |||
#include <cmath> | |||
#include <SDL.h> | |||
#include <gtk/gtk.h> | |||
#include <gtkgl/gtkglarea.h> | |||
#include <GL/gl.h> | |||
#include "gtkvideo.h" | |||
#include "ticker.h" | |||
@@ -12,18 +12,8 @@ | |||
#include <gtk/gtk.h> | |||
#include <gtkgl/gtkglarea.h> | |||
#ifdef WIN32 | |||
# define WIN32_LEAN_AND_MEAN | |||
# include <windows.h> | |||
#endif | |||
#if defined __APPLE__ && defined __MACH__ | |||
# include <OpenGL/gl.h> | |||
#else | |||
# define GL_GLEXT_PROTOTYPES | |||
# include <GL/gl.h> | |||
#endif | |||
#include "gtkvideo.h" | |||
#include "video.h" | |||
/* | |||
* Gtk Video implementation class | |||
@@ -34,30 +24,6 @@ class GtkVideoData | |||
friend class GtkVideo; | |||
private: | |||
void SetupView() | |||
{ | |||
glViewport(0, 0, widget->allocation.width, | |||
widget->allocation.height); | |||
glMatrixMode(GL_PROJECTION); | |||
glLoadIdentity(); | |||
glOrtho(0, widget->allocation.width, | |||
widget->allocation.height, 0, -1, 10); | |||
glMatrixMode(GL_MODELVIEW); | |||
glLoadIdentity(); | |||
glEnable(GL_TEXTURE_2D); | |||
glShadeModel(GL_SMOOTH); | |||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |||
glClearDepth(1.0); | |||
glEnable(GL_DEPTH_TEST); | |||
glDepthFunc(GL_LEQUAL); | |||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); | |||
glEnable(GL_BLEND); | |||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |||
} | |||
static gint init(GtkWidget *widget) | |||
{ | |||
GtkVideoData *data = (GtkVideoData *) | |||
@@ -66,7 +32,8 @@ private: | |||
/* OpenGL functions can be called only if make_current returns true */ | |||
if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) | |||
{ | |||
data->SetupView(); | |||
Video::Setup(widget->allocation.width, | |||
widget->allocation.height); | |||
} | |||
return TRUE; | |||
} | |||
@@ -95,7 +62,8 @@ private: | |||
if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) | |||
{ | |||
data->SetupView(); | |||
Video::Setup(widget->allocation.width, | |||
widget->allocation.height); | |||
} | |||
return TRUE; | |||
} | |||
@@ -167,8 +135,7 @@ void GtkVideo::PreRender() | |||
/// XXX: is this right? | |||
gtk_gl_area_make_current(GTK_GL_AREA(data->widget)); | |||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||
glLoadIdentity(); | |||
Video::Clear(); | |||
data->drawing = 1; | |||
} | |||
@@ -189,13 +156,3 @@ void GtkVideo::PostRender(float milliseconds) | |||
#endif | |||
} | |||
void GtkVideo::FullScreen() | |||
{ | |||
// FIXME | |||
} | |||
GtkVideo::~GtkVideo() | |||
{ | |||
// FIXME | |||
} | |||
@@ -11,22 +11,18 @@ | |||
#if !defined __DH_GTKVIDEO_H__ | |||
#define __DH_GTKVIDEO_H__ | |||
#include "video.h" | |||
class GtkVideoData; | |||
class GtkVideo : public Video | |||
class GtkVideo | |||
{ | |||
public: | |||
GtkVideo(char const *title, int width, int height); | |||
virtual ~GtkVideo(); | |||
// Inherited | |||
virtual int GetWidth() const; | |||
virtual int GetHeight() const; | |||
virtual void PreRender(); | |||
virtual void PostRender(float milliseconds); | |||
virtual void FullScreen(); | |||
int GetWidth() const; | |||
int GetHeight() const; | |||
void PreRender(); | |||
void PostRender(float milliseconds); | |||
// New | |||
void *GetWidget(); | |||
@@ -7,20 +7,10 @@ | |||
# include "config.h" | |||
#endif | |||
#ifdef WIN32 | |||
# define WIN32_LEAN_AND_MEAN | |||
# include <windows.h> | |||
#endif | |||
#if defined __APPLE__ && defined __MACH__ | |||
# include <OpenGL/gl.h> | |||
#else | |||
# define GL_GLEXT_PROTOTYPES | |||
# include <GL/gl.h> | |||
#endif | |||
#include <SDL.h> | |||
#include "sdlvideo.h" | |||
#include "video.h" | |||
/* | |||
* SDL Video implementation class | |||
@@ -63,24 +53,7 @@ SdlVideo::SdlVideo(char const *title, int width, int height) | |||
SDL_ShowCursor(0); | |||
SDL_WM_GrabInput(SDL_GRAB_ON); | |||
/* Initialise OpenGL */ | |||
glViewport(0, 0, data->video->w, data->video->h); | |||
glMatrixMode(GL_PROJECTION); | |||
glLoadIdentity(); | |||
glOrtho(0, data->video->w, data->video->h, 0, -1, 10); | |||
glMatrixMode(GL_MODELVIEW); | |||
glLoadIdentity(); | |||
glEnable(GL_TEXTURE_2D); | |||
glShadeModel(GL_SMOOTH); | |||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |||
glClearDepth(1.0); | |||
glEnable(GL_DEPTH_TEST); | |||
glDepthFunc(GL_LEQUAL); | |||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); | |||
glEnable(GL_BLEND); | |||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |||
Video::Setup(data->video->w, data->video->h); | |||
/* Initialise timer */ | |||
data->start = data->ticks = SDL_GetTicks(); | |||
@@ -99,8 +72,7 @@ int SdlVideo::GetHeight() const | |||
void SdlVideo::PreRender() | |||
{ | |||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||
glLoadIdentity(); | |||
Video::Clear(); | |||
} | |||
void SdlVideo::PostRender(float milliseconds) | |||
@@ -11,21 +11,19 @@ | |||
#if !defined __DH_SDLVIDEO_H__ | |||
#define __DH_SDLVIDEO_H__ | |||
#include "video.h" | |||
class SdlVideoData; | |||
class SdlVideo : public Video | |||
class SdlVideo | |||
{ | |||
public: | |||
SdlVideo(char const *title, int width, int height); | |||
virtual ~SdlVideo(); | |||
~SdlVideo(); | |||
virtual int GetWidth() const; | |||
virtual int GetHeight() const; | |||
virtual void PreRender(); | |||
virtual void PostRender(float milliseconds); | |||
virtual void FullScreen(); | |||
int GetWidth() const; | |||
int GetHeight() const; | |||
void PreRender(); | |||
void PostRender(float milliseconds); | |||
void FullScreen(); | |||
private: | |||
SdlVideoData *data; | |||
@@ -19,7 +19,7 @@ | |||
int main(int argc, char **argv) | |||
{ | |||
Video *video = new SdlVideo("Deus Hax", 640, 480); | |||
SdlVideo *video = new SdlVideo("Deus Hax", 640, 480); | |||
Game *game = new Game("maps/testmap.tmx"); | |||
/* Register the input driver */ | |||
@@ -73,6 +73,11 @@ TileSet::~TileSet() | |||
delete data; | |||
} | |||
Asset::Group TileSet::GetGroup() | |||
{ | |||
return GROUP_BEFORE; | |||
} | |||
void TileSet::TickRender(float delta_time) | |||
{ | |||
Asset::TickRender(delta_time); | |||
@@ -26,9 +26,12 @@ public: | |||
TileSet(char const *path); | |||
virtual ~TileSet(); | |||
protected: | |||
/* Inherited from Asset */ | |||
virtual Group GetGroup(); | |||
virtual void TickRender(float delta_time); | |||
public: | |||
/* New implementations */ | |||
char const *GetName(); | |||
@@ -0,0 +1,54 @@ | |||
// | |||
// Deus Hax (working title) | |||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||
// | |||
#if defined HAVE_CONFIG_H | |||
# include "config.h" | |||
#endif | |||
#ifdef WIN32 | |||
# define WIN32_LEAN_AND_MEAN | |||
# include <windows.h> | |||
#endif | |||
#if defined __APPLE__ && defined __MACH__ | |||
# include <OpenGL/gl.h> | |||
#else | |||
# define GL_GLEXT_PROTOTYPES | |||
# include <GL/gl.h> | |||
#endif | |||
#include "video.h" | |||
/* | |||
* Public Video class | |||
*/ | |||
void Video::Setup(int width, int height) | |||
{ | |||
/* Initialise OpenGL */ | |||
glViewport(0, 0, width, height); | |||
glMatrixMode(GL_PROJECTION); | |||
glLoadIdentity(); | |||
glOrtho(0, width, height, 0, -1, 10); | |||
glMatrixMode(GL_MODELVIEW); | |||
glLoadIdentity(); | |||
glEnable(GL_TEXTURE_2D); | |||
glShadeModel(GL_SMOOTH); | |||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |||
glClearDepth(1.0); | |||
glEnable(GL_DEPTH_TEST); | |||
glDepthFunc(GL_LEQUAL); | |||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); | |||
glEnable(GL_BLEND); | |||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |||
} | |||
void Video::Clear() | |||
{ | |||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||
glLoadIdentity(); | |||
} | |||
@@ -6,7 +6,7 @@ | |||
// | |||
// The Video interface | |||
// ------------------- | |||
// Not sure yet whether this should exist. | |||
// Helper GL functions to set up the scene. | |||
// | |||
#if !defined __DH_VIDEO_H__ | |||
@@ -15,11 +15,8 @@ | |||
class Video | |||
{ | |||
public: | |||
virtual int GetWidth() const = 0; | |||
virtual int GetHeight() const = 0; | |||
virtual void PreRender() = 0; | |||
virtual void PostRender(float milliseconds) = 0; | |||
virtual void FullScreen() = 0; | |||
static void Setup(int width, int height); | |||
static void Clear(); | |||
}; | |||
#endif // __DH_VIDEO_H__ | |||