1 | //-------------------------------------------------------------------------------------------------
|
2 | void Visuals::DrawSpriteOntoScreenBuffer(Uint16 index)
|
3 | {
|
4 | glPushMatrix();
|
5 |
|
6 | glBindTexture(GL_TEXTURE_2D, Sprites[index].OGL_Texture);
|
7 | glEnable(GL_TEXTURE_2D);
|
8 |
|
9 | glTranslatef(Sprites[index].ScreenX, Sprites[index].ScreenY, 1.0f);
|
10 | glScalef(Sprites[index].ScaleX, Sprites[index].ScaleY, 1.0f);
|
11 | glRotatef(Sprites[index].RotationDegree, 0.0f, 0.0f, 1.0f);
|
12 |
|
13 | glColor4f(Sprites[index].redHue, Sprites[index].greenHue, Sprites[index].blueHue
|
14 | , Sprites[index].Transparency);
|
15 |
|
16 | if (Sprites[index].AnimationTimerOne > -1) Sprites[index].AnimationTimerOne--;
|
17 |
|
18 | if (Sprites[index].Smooth == false)
|
19 | {
|
20 |
|
21 | }
|
22 | else
|
23 | {
|
24 | glEnable(GL_BLEND);
|
25 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
26 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
27 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
28 | }
|
29 |
|
30 | GLfloat xMin = 0.0f; GLfloat xMax = 0.0f;
|
31 | GLfloat yMin = 0.0f; GLfloat yMax = 0.0f;
|
32 | if (Sprites[index].FlipX == false && Sprites[index].FlipY == false)
|
33 | {
|
34 | xMin = 0-(Sprites[index].Width/2); xMax = 0+(Sprites[index].Width/2);
|
35 | yMin = 0-(Sprites[index].Height/2); yMax = 0+(Sprites[index].Height/2);
|
36 | }
|
37 | else if (Sprites[index].FlipX == true && Sprites[index].FlipY == false)
|
38 | {
|
39 | xMin = 0+(Sprites[index].Width/2); xMax = 0-(Sprites[index].Width/2);
|
40 | yMin = 0-(Sprites[index].Height/2); yMax = 0+(Sprites[index].Height/2);
|
41 | }
|
42 | else if (Sprites[index].FlipX == false && Sprites[index].FlipY == true)
|
43 | {
|
44 | xMin = 0-(Sprites[index].Width/2); xMax = 0+(Sprites[index].Width/2);
|
45 | yMin = 0+(Sprites[index].Height/2); yMax = 0-(Sprites[index].Height/2);
|
46 | }
|
47 | else if (Sprites[index].FlipX == true && Sprites[index].FlipY == true)
|
48 | {
|
49 | xMin = 0+(Sprites[index].Width/2); xMax = 0-(Sprites[index].Width/2);
|
50 | yMin = 0+(Sprites[index].Height/2); yMax = 0-(Sprites[index].Height/2);
|
51 | }
|
52 |
|
53 | glBegin( GL_QUADS );
|
54 | glTexCoord3f(0.0f, 0.0f, 1.0f);
|
55 | glVertex3f(xMin, yMin, 0.0f );
|
56 |
|
57 | glTexCoord3f(1.0f, 0.0f, 1.0f);
|
58 | glVertex3f(xMax, yMin, 0.0f );
|
59 |
|
60 | glTexCoord3f(1.0f, 1.0f, 1.0f);
|
61 | glVertex3f(xMax, yMax, 0.0f );
|
62 |
|
63 | glTexCoord3f(0.0f, 1.0f, 1.0f);
|
64 | glVertex3f(xMin, yMax, 0.0f );
|
65 | glEnd();
|
66 |
|
67 | glPopMatrix();
|
68 | }
|
69 | //-------------------------------------------------------------------------------------------------
|