Added static camera

This commit is contained in:
2007-03-14 17:02:22 +00:00
parent 2c66c10eed
commit 7fedbe263e
7 changed files with 64 additions and 31 deletions
+1
View File
@@ -3,6 +3,7 @@ project(aigolib)
set(AIGO_SRCS
camera.cpp
quickcam.cpp
staticcam.cpp
settings.cpp
state.cpp
image.cpp
+11
View File
@@ -9,6 +9,17 @@ Camera::Camera(int width, int height)
pixels = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, DEPTH, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
}
Camera::Camera( void )
: pixels(0)
{
//does not initialize anything
}
void Camera::init(int width, int height)
{
pixels = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, DEPTH, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
}
Camera::~Camera( void )
{
SDL_FreeSurface(pixels);
+2
View File
@@ -12,7 +12,9 @@ class Camera
SDL_Surface* getSurface ( void ) { return pixels; }
protected:
Camera( void );
SDL_Surface *pixels;
void init(int width, int height);
};
+19
View File
@@ -0,0 +1,19 @@
#include "staticcam.h"
StaticCam::StaticCam(char *filename)
: Camera()
{
loaded = SDL_LoadBMP(filename);
init(loaded->w, loaded->h);
SDL_CreateRGBSurface(SDL_SWSURFACE, loaded->w, loaded->h, 8, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
}
StaticCam::~StaticCam( void )
{
SDL_FreeSurface(loaded);
}
void StaticCam::update( void )
{
SDL_BlitSurface(loaded, 0, pixels, 0);
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef _STATICCAM_H_
#define _STATICCAM_H_
#include "camera.h"
class StaticCam : public Camera
{
public:
StaticCam( char *filename );
virtual ~StaticCam( void );
void update( void );
private:
SDL_Surface *loaded;
};
#endif /* ifndef _QUICKCAM_H_ */