* move imageManager code into new imageManager.h/imageManager.cpp
[openc2e.git] / Backend.h
blobafb32da372870781728c33904b7684d2d52e0bfb
1 /*
2 * Backend.h
3 * openc2e
5 * Created by Alyssa Milburn on Sat Dec 2 2006.
6 * Copyright (c) 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 _BACKEND_H
21 #define _BACKEND_H
23 #include "endianlove.h"
24 #include <boost/shared_ptr.hpp>
26 using boost::shared_ptr;
28 enum eventtype { eventquit, eventkeydown, eventspecialkeyup, eventspecialkeydown, eventmousebuttondown, eventmousebuttonup, eventmousemove, eventresizewindow };
29 enum eventbuttons { buttonleft=0x1, buttonright=0x2, buttonmiddle=0x4, buttonwheeldown=0x8, buttonwheelup=0x10 };
31 struct SomeEvent {
32 eventtype type;
33 int x, y, xrel, yrel;
34 int key;
35 unsigned int button;
38 class creaturesImage;
40 class Surface {
41 public:
42 virtual void render(boost::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) = 0;
43 virtual void renderLine(int x1, int y1, int x2, int y2, unsigned int colour) = 0;
44 virtual void blitSurface(Surface *src, int x, int y, int w, int h) = 0;
45 virtual unsigned int getWidth() const = 0;
46 virtual unsigned int getHeight() const = 0;
47 virtual void renderDone() = 0;
48 virtual ~Surface() { }
51 class Backend {
52 public:
53 virtual void init() = 0;
54 virtual int networkInit() = 0;
55 virtual void shutdown() = 0;
57 virtual unsigned int ticks() = 0;
58 virtual bool pollEvent(SomeEvent &e) = 0;
59 virtual void handleEvents() = 0;
60 virtual bool keyDown(int key) = 0;
62 virtual bool selfRender() = 0;
63 virtual void requestRender() = 0;
65 virtual void resize(unsigned int width, unsigned int height) = 0;
67 virtual Surface *getMainSurface() = 0;
68 virtual Surface *newSurface(unsigned int width, unsigned int height) = 0;
69 virtual void freeSurface(Surface *surf) = 0;
71 virtual void setPalette(uint8 *data) = 0;
73 virtual int run(int argc, char **argv);
74 virtual void delay(int msec) = 0;
75 virtual ~Backend() { }
78 #endif