-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimation.cpp
More file actions
73 lines (46 loc) · 1.63 KB
/
Copy pathAnimation.cpp
File metadata and controls
73 lines (46 loc) · 1.63 KB
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
#include "Animation.h"
#include <iostream>
using namespace std;
Animation::Animation()
{
imgPtr = new vector<GLuint *>();
it = 0;
}
void Animation::windowToScene(float &x, float &y)
{
x = (2.0f*(x/float(newW)) - 1.0f);
y = 1.0f - (2.0f*(y/float(newH)));
}
int Animation::animate(float x, float y, float w, float h)
{
it = ((it) % imgPtr->size());
Animation::windowToScene(x,y);
//cout << "NewW: " << newW << " NewH: " << newH << endl;
w = 2.0f*((w/float(newW)));
h = 2.0f*((h/float(newH)));
//cout << "animate is called" << endl;
//cout << "Drawing on coordinates (x,y,w,h): " << x << ", " << y << ", " << w << ", " << h << endl;
// Binding Texture
//glShadeModel(GL_SMOOTH);
glBindTexture(GL_TEXTURE_2D, *(imgPtr->at((it))));
glEnable(GL_TEXTURE_2D);
// Drawing the Texture
glBegin(GL_POLYGON); // texCoord for tex, vertex for where to map
glTexCoord2f(0.0f, 1.0f); glVertex2d(x, y);
glTexCoord2f(1.0f, 1.0f); glVertex2d(x+w, y);
glTexCoord2f(1.0f, 0.0f); glVertex2d(x+w, y-h);
glTexCoord2f(0.0f, 0.0f); glVertex2d(x, y-h);
glEnd();
// Fixing this code so there's no possibility of overflow
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glDisable(GL_TEXTURE_2D);
// Current Isssue: Which element of the vector to render?
// Technical Deliberation: Parameters such as lightning and background.
return it;
}