add wraparound support to C2 physics
[openc2e.git] / Backend.h
blob69ad8d43fc3081123b5bf4e18ba668bb18cae786
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>
25 #include <string>
27 using boost::shared_ptr;
29 enum eventtype { eventquit, eventkeydown, eventspecialkeyup, eventspecialkeydown, eventmousebuttondown, eventmousebuttonup, eventmousemove, eventresizewindow };
30 enum eventbuttons { buttonleft=0x1, buttonright=0x2, buttonmiddle=0x4, buttonwheeldown=0x8, buttonwheelup=0x10 };
32 struct SomeEvent {
33 eventtype type;
34 int x, y, xrel, yrel;
35 int key;
36 unsigned int button;
39 class creaturesImage;
41 class Surface {
42 public:
43 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;
44 virtual void renderLine(int x1, int y1, int x2, int y2, unsigned int colour) = 0;
45 virtual void renderText(int x, int y, std::string text, unsigned int colour, unsigned int bgcolour) = 0;
46 virtual void blitSurface(Surface *src, int x, int y, int w, int h) = 0;
47 virtual unsigned int getWidth() const = 0;
48 virtual unsigned int getHeight() const = 0;
49 virtual void renderDone() = 0;
50 virtual ~Surface() { }
53 class Backend {
54 public:
55 virtual void init() = 0;
56 virtual int networkInit() = 0;
57 virtual void shutdown() = 0;
59 virtual unsigned int ticks() = 0;
60 virtual bool pollEvent(SomeEvent &e) = 0;
61 virtual void handleEvents() = 0;
62 virtual bool keyDown(int key) = 0;
64 virtual bool selfRender() = 0;
65 virtual void requestRender() = 0;
67 virtual void resize(unsigned int width, unsigned int height) = 0;
69 virtual Surface *getMainSurface() = 0;
70 virtual Surface *newSurface(unsigned int width, unsigned int height) = 0;
71 virtual void freeSurface(Surface *surf) = 0;
73 virtual void setPalette(uint8 *data) = 0;
74 virtual unsigned int textWidth(std::string text) = 0;
76 virtual int run(int argc, char **argv);
77 virtual void delay(int msec) = 0;
78 virtual ~Backend() { }
81 #endif