* move imageManager code into new imageManager.h/imageManager.cpp
[openc2e.git] / SDLBackend.h
blob35a0c15214ab92e06aa51d04f05b3fadbdb330f5
1 /*
2 * SDLBackend.h
3 * openc2e
5 * Created by Alyssa Milburn on Sun Oct 24 2004.
6 * Copyright (c) 2004-2006 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef _SDLBACKEND_H
21 #define _SDLBACKEND_H
23 #include "SDL.h"
24 #include <SDL_net.h>
25 #include "Backend.h"
27 class SDLSurface : public Surface {
28 friend class SDLBackend;
30 protected:
31 SDL_Surface *surface;
32 unsigned int width, height;
33 SDL_Color palette[256];
35 public:
36 void render(shared_ptr<creaturesImage> image, unsigned int frame, int x, int y, bool trans = false, unsigned char transparency = 0, bool mirror = false, bool is_background = false);
37 void renderLine(int x1, int y1, int x2, int y2, unsigned int colour);
38 void blitSurface(Surface *src, int x, int y, int w, int h);
39 unsigned int getWidth() const { return width; }
40 unsigned int getHeight() const { return height; }
41 void renderDone();
44 class SDLBackend : public Backend {
45 protected:
46 bool networkingup;
48 SDLSurface mainsurface;
49 TCPsocket listensocket;
51 void handleNetworking();
52 void resizeNotify(int _w, int _h);
53 int translateKey(int key);
55 SDL_Surface *getMainSDLSurface() { return mainsurface.surface; }
57 virtual int idealBpp();
59 public:
60 SDLBackend();
61 void init();
62 int networkInit();
63 void shutdown();
65 void resize(unsigned int w, unsigned int h) { resizeNotify(w, h); }
67 bool pollEvent(SomeEvent &e);
69 unsigned int ticks() { return SDL_GetTicks(); }
71 void handleEvents();
73 bool selfRender() { return false; }
74 void requestRender() { }
76 Surface *getMainSurface() { return &mainsurface; }
77 Surface *newSurface(unsigned int width, unsigned int height);
78 void freeSurface(Surface *surf);
80 bool keyDown(int key);
82 void setPalette(uint8 *data);
83 void delay(int msec);
86 #endif