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.
27 class SDLSurface
: public Surface
{
28 friend class SDLBackend
;
31 class SDLBackend
*parent
;
33 unsigned int width
, height
;
34 SDL_Color palette
[256];
36 SDLSurface(SDLBackend
*p
) { parent
= p
; }
39 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);
40 void renderLine(int x1
, int y1
, int x2
, int y2
, unsigned int colour
);
41 void renderText(int x
, int y
, std::string text
, unsigned int colour
, unsigned int bgcolour
);
42 void blitSurface(Surface
*src
, int x
, int y
, int w
, int h
);
43 unsigned int getWidth() const { return width
; }
44 unsigned int getHeight() const { return height
; }
48 class SDLBackend
: public Backend
{
49 friend class SDLSurface
;
54 SDLSurface mainsurface
;
55 TCPsocket listensocket
;
57 struct _TTF_Font
*basicfont
;
59 void handleNetworking();
60 void resizeNotify(int _w
, int _h
);
61 int translateKey(int key
);
63 SDL_Surface
*getMainSDLSurface() { return mainsurface
.surface
; }
65 virtual int idealBpp();
73 void resize(unsigned int w
, unsigned int h
) { resizeNotify(w
, h
); }
75 bool pollEvent(SomeEvent
&e
);
77 unsigned int ticks() { return SDL_GetTicks(); }
81 bool selfRender() { return false; }
82 void requestRender() { }
84 Surface
*getMainSurface() { return &mainsurface
; }
85 Surface
*newSurface(unsigned int width
, unsigned int height
);
86 void freeSurface(Surface
*surf
);
87 unsigned int textWidth(std::string text
);
89 bool keyDown(int key
);
91 void setPalette(uint8
*data
);