Changeset 90


Ignore:
Timestamp:
Aug 11, 2010, 5:39:36 PM (10 years ago)
Author:
sam
Message:

Change the Video class into an interface, implemented by SdlVideo and,
soon, GtkVideo.

Location:
trunk/src
Files:
1 added
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile

    r87 r90  
    11
    2 SRC = test-map.cpp \
    3       game.cpp video.cpp tiler.cpp tileset.cpp scene.cpp \
    4       font.cpp layer.cpp map.cpp
     2COMMON = test-map.cpp \
     3      game.cpp tiler.cpp tileset.cpp scene.cpp \
     4      font.cpp layer.cpp map.cpp joystick.cpp
     5TEST_SRC = test-map.cpp sdlvideo.cpp $(COMMON)
     6EDITOR_SRC = editor.cpp gtkvideo.cpp $(COMMON)
    57
    68all: test-map
    79
    8 test-map: $(SRC:%.cpp=%.o)
     10test-map: $(TEST_SRC:%.cpp=%.o)
     11        g++ -g -Wall -O3 $^ -o $@ `pkg-config --libs sdl gl SDL_image`
     12
     13editor-map: $(EDITOR_SRC:%.cpp=%.o)
    914        g++ -g -Wall -O3 $^ -o $@ `pkg-config --libs sdl gl SDL_image`
    1015
  • trunk/src/sdlvideo.cpp

    r88 r90  
    1313#include <SDL.h>
    1414
    15 #include "video.h"
     15#include "sdlvideo.h"
    1616
    1717/*
    18  * Video implementation class
     18 * SDL Video implementation class
    1919 */
    2020
    21 class VideoData
     21class SdlVideoData
    2222{
    23     friend class Video;
     23    friend class SdlVideo;
    2424
    2525private:
     
    3030
    3131/*
    32  * Public Video class
     32 * Public SdlVideo class
    3333 */
    3434
    35 Video::Video(char const *title, int width, int height)
     35SdlVideo::SdlVideo(char const *title, int width, int height)
    3636{
    37     data = new VideoData();
     37    data = new SdlVideoData();
    3838
    3939    /* Initialise SDL */
     
    8080}
    8181
    82 int Video::GetWidth() const
     82int SdlVideo::GetWidth() const
    8383{
    8484    return data->video->w;
    8585}
    8686
    87 int Video::GetHeight() const
     87int SdlVideo::GetHeight() const
    8888{
    8989    return data->video->h;
    9090}
    9191
    92 void Video::Clear()
     92void SdlVideo::Clear()
    9393{
    9494    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
    9696}
    9797
    98 void Video::Refresh(float milliseconds)
     98void SdlVideo::Refresh(float milliseconds)
    9999{
    100100    if (milliseconds > 0.0f)
     
    107107}
    108108
    109 void Video::FullScreen()
     109void SdlVideo::FullScreen()
    110110{
    111111    SDL_WM_ToggleFullScreen(data->video);
    112112}
    113113
    114 Video::~Video()
     114SdlVideo::~SdlVideo()
    115115{
    116116    Uint32 total = SDL_GetTicks() - data->start;
  • trunk/src/test-map.cpp

    r79 r90  
    66#include <math.h>
    77
    8 #include "video.h"
     8#include "sdlvideo.h"
    99#include "game.h"
    1010
    1111int main(int argc, char **argv)
    1212{
    13     Video *video = new Video("Deus Hax", 640, 480);
     13    Video *video = new SdlVideo("Deus Hax", 640, 480);
    1414    Game *game = new Game("maps/testmap-library.tmx");
    1515
  • trunk/src/video.h

    r47 r90  
    11
    22/*
    3  * The video driver
     3 * The video interface
    44 */
    55
     
    77#define __DH_VIDEO_H__
    88
    9 class VideoData;
    10 
    119class Video
    1210{
    1311public:
    14     Video(char const *title, int width, int height);
    15     ~Video();
     12    //Video(char const *title, int width, int height);
     13    //virtual ~Video();
    1614
    17     int GetWidth() const;
    18     int GetHeight() const;
    19     void Clear();
    20     void Refresh(float milliseconds);
    21     void FullScreen();
    22 
    23 private:
    24     VideoData *data;
     15    virtual int GetWidth() const = 0;
     16    virtual int GetHeight() const = 0;
     17    virtual void Clear() = 0;
     18    virtual void Refresh(float milliseconds) = 0;
     19    virtual void FullScreen() = 0;
    2520};
    2621
Note: See TracChangeset for help on using the changeset viewer.