diff options
author | pixel <pixel> | 2003-03-28 13:36:38 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-03-28 13:36:38 +0000 |
commit | 3e2e4fe9e05d73ba1c1b5de93160bb1cdb7cb56e (patch) | |
tree | 49b310acf67fb2dbad7a7f39841d67e01ea2c007 /lib/sprite.cc | |
parent | 541c00c93fcd98f766cce661aa83ef4ffe713e57 (diff) |
SDL backend mostly finished
Diffstat (limited to 'lib/sprite.cc')
-rw-r--r-- | lib/sprite.cc | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/sprite.cc b/lib/sprite.cc index 60f944c..74ea522 100644 --- a/lib/sprite.cc +++ b/lib/sprite.cc @@ -1,5 +1,6 @@ #include <SDL.h> -#include "glbase.h" +#include "engine.h" +#include "base.h" #include "sprite.h" #define TEXSIZE 256 @@ -107,6 +108,11 @@ void mogltk::Sprite::TexList::Bind() const { tex->Bind(); } +SDL_Surface * mogltk::Sprite::TexList::GetSurface() { + return tex->GetSurface(); +} + + bool mogltk::Sprite::intersect(int x1, int y1, int x2, int y2) const { int sx1 = posx, sy1 = posy, sx2 = posx + sx, sy2 = posy + sy; @@ -124,27 +130,24 @@ bool mogltk::Sprite::canfit(int x1, int y1, int x2, int y2) const { } void mogltk::Sprite::draw(int dx, int dy, ColorP c) { -#if 0 - bool was2D; + bool locked = false; + + if (SDL_MUSTLOCK(mogltk::engine::base_o->getsurface())) { + locked = true; + SDL_LockSurface(mogltk::engine::base_o->getsurface()); + } - was2D = mogltk::glbase::is2D(); + SDL_Rect src, dst; - if (!was2D) - mogltk::glbase::Enter2DMode(); - - c.Bind(); + src.x = posx; src.y = posy; src.w = sx; src.h = sy; + dst.x = dx; dst.y = dy; dst.w = sx; dst.h = sy; - tlist->Bind(); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2i(posx , posy ); glVertex2i(dx , dy ); - glTexCoord2i(posx + sx - 1, posy ); glVertex2i(dx + sx - 1, dy ); - glTexCoord2i(posx , posy + sy - 1); glVertex2i(dx , dy + sy - 1); - glTexCoord2i(posx + sx - 1, posy + sy - 1); glVertex2i(dx + sx - 1, dy + sy - 1); - glEnd(); - - if (!was2D) - mogltk::glbase::Leave2DMode(); -#endif + printm(M_INFO, "Drawing sprite at %i %i\n", dx, dy); + + SDL_BlitSurface(tlist->GetSurface(), &src, mogltk::engine::base_o->getsurface(), &dst); + + if (locked) + SDL_UnlockSurface(mogltk::engine::base_o->getsurface()); } void mogltk::Sprite::Bind() { |