1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#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();
glRotated(a, 0, 0, 1);
glTranslated(cx, cy, 0);
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();
}
|