diff options
Diffstat (limited to 'lib/glsprite.cc')
-rw-r--r-- | lib/glsprite.cc | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/lib/glsprite.cc b/lib/glsprite.cc index 0a98149..7091ca3 100644 --- a/lib/glsprite.cc +++ b/lib/glsprite.cc @@ -1,105 +1,105 @@ -/* - * mogltk - * Copyright (C) 1999-2004 Nicolas "Pixel" Noble - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* $Id: glsprite.cc,v 1.9 2004-07-15 14:21:31 pixel Exp $ */ - -#include <SDL.h> -#include "glbase.h" -#include "glsprite.h" -#include "engine.h" - -#define TEXSIZE 256 - -mogltk::glSprite::glSprite(Handle * h, int asx, int asy) : Sprite(h, asx, asy) { -} - -mogltk::glSprite::glSprite(Uint8 * p, int asx, int asy) : Sprite(p, asx, asy) { -} - -mogltk::glSprite::~glSprite() { -} - -void mogltk::glSprite::draw(int dx, int dy, ColorP c, float sx, float sy) { - bool was2D; - - if (!(was2D = mogltk::engine::glbase_o->is2D())) - mogltk::engine::glbase_o->Enter2DMode(); - - c.Bind(); - - Bind(); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2i(GetPX() , GetPY() ); glVertex2i(dx , dy ); - glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(dx + GetSX() * sx, dy ); - glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i(dx , dy + GetSY() * sy); - glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(dx + GetSX() * sx, dy + GetSY() * sy); - glEnd(); - - if (!was2D) - mogltk::engine::glbase_o->Leave2DMode(); -} - -void mogltk::glSprite::bindcorner(float fx, float fy) { - if (fx > 1) - fx = 1; - if (fy > 1) - fy = 1; - if (fx < 0) - fx = 0; - if (fy < 0) - fy = 0; - glTexCoord2i(GetPX() + fx * GetSX(), GetPY() + fy * GetSY()); -} - -void mogltk::glSprite::drawrotate(int cx, int cy, double a, ColorP c) { - bool was2D; - - int sx, sy; - - sx = GetSX() / 2; - sy = GetSY() / 2; - - was2D = mogltk::engine::glbase_o->is2D(); - - if (!was2D) - mogltk::engine::glbase_o->Enter2DMode(); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslated(cx, cy, 0); - glRotated(a, 0, 0, 1); - -// glMatrixMode(GL_TEXTURE); -// glRotated(a, 0, 0, 1); - - c.Bind(); - - Bind(); - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2i(GetPX() , GetPY() ); glVertex2i( - sx, - sy); - glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(GetSX() - sx, - sy); - glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i( - sx, GetSY() - sy); - glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(GetSX() - sx, GetSY() - sy); - glEnd(); - - glPopMatrix(); - - if (!was2D) - mogltk::engine::glbase_o->Leave2DMode(); -} +/*
+ * mogltk
+ * Copyright (C) 1999-2004 Nicolas "Pixel" Noble
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* $Id: glsprite.cc,v 1.10 2004-11-27 21:44:53 pixel Exp $ */
+
+#include <SDL.h>
+#include "glbase.h"
+#include "glsprite.h"
+#include "engine.h"
+
+#define TEXSIZE 256
+
+mogltk::glSprite::glSprite(Handle * h, int asx, int asy) : Sprite(h, asx, asy) {
+}
+
+mogltk::glSprite::glSprite(Uint8 * p, int asx, int asy) : Sprite(p, asx, asy) {
+}
+
+mogltk::glSprite::~glSprite() {
+}
+
+void mogltk::glSprite::draw(int dx, int dy, ColorP c, float sx, float sy) {
+ bool was2D;
+
+ if (!(was2D = mogltk::engine::glbase_o->is2D()))
+ mogltk::engine::glbase_o->Enter2DMode();
+
+ c.Bind();
+
+ Bind();
+ glBegin(GL_TRIANGLE_STRIP);
+ glTexCoord2i(GetPX() , GetPY() ); glVertex2i(dx , dy );
+ glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(dx + GetSX() * sx, dy );
+ glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i(dx , dy + GetSY() * sy);
+ glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(dx + GetSX() * sx, dy + GetSY() * sy);
+ glEnd();
+
+ if (!was2D)
+ mogltk::engine::glbase_o->Leave2DMode();
+}
+
+void mogltk::glSprite::bindcorner(float fx, float fy) {
+ if (fx > 1)
+ fx = 1;
+ if (fy > 1)
+ fy = 1;
+ if (fx < 0)
+ fx = 0;
+ if (fy < 0)
+ fy = 0;
+ glTexCoord2i(GetPX() + fx * GetSX(), GetPY() + fy * GetSY());
+}
+
+void mogltk::glSprite::drawrotate(int cx, int cy, double a, ColorP c) {
+ bool was2D;
+
+ int sx, sy;
+
+ sx = GetSX() / 2;
+ sy = GetSY() / 2;
+
+ was2D = mogltk::engine::glbase_o->is2D();
+
+ if (!was2D)
+ mogltk::engine::glbase_o->Enter2DMode();
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslated(cx, cy, 0);
+ glRotated(a, 0, 0, 1);
+
+// glMatrixMode(GL_TEXTURE);
+// glRotated(a, 0, 0, 1);
+
+ c.Bind();
+
+ Bind();
+ glBegin(GL_TRIANGLE_STRIP);
+ glTexCoord2i(GetPX() , GetPY() ); glVertex2i( - sx, - sy);
+ glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(GetSX() - sx, - sy);
+ glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i( - sx, GetSY() - sy);
+ glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(GetSX() - sx, GetSY() - sy);
+ glEnd();
+
+ glPopMatrix();
+
+ if (!was2D)
+ mogltk::engine::glbase_o->Leave2DMode();
+}
|