-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSoundButton.cpp
More file actions
50 lines (44 loc) · 1.16 KB
/
SoundButton.cpp
File metadata and controls
50 lines (44 loc) · 1.16 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
#include "SoundButton.h"
#include "TextureManager.h"
#include "resource.h"
extern TextureManager textureManager;
SoundButton::SoundButton(const unsigned int StartX, const unsigned int StartY)
:Field(StartX,StartY), State(STATE::On)
{
}
bool SoundButton::Click(POINT& coordinates)
{
if (coordinates.x >= this->StartX && coordinates.y >= this->StartY && coordinates.x < SoundButtonW + this->StartX && coordinates.y < SoundButtonH + this->StartY)
{
coordinates.x -= this->StartX;
coordinates.y -= this->StartY;
return true;
}
return false;
}
void SoundButton::Draw()
{
GLuint TextureID{};
switch (this->State)
{
case STATE::On:
{
TextureID = textureManager.SoundOnTextureID;
}
break;
case STATE::Off:
{
TextureID = textureManager.SoundOffTextureID;
}
break;
}
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextureID);
glBegin(GL_QUADS);
glTexCoord2d(0, 0); glVertex2f(this->StartX, this->StartY);
glTexCoord2d(1.f, 0); glVertex2f(4.f + this->StartX, this->StartY);
glTexCoord2d(1.f, 1.f); glVertex2f(4.f + this->StartX, 1.f + this->StartY);
glTexCoord2d(0, 1.f); glVertex2f(this->StartX, 1.f + this->StartY);
glEnd();
glDisable(GL_TEXTURE_2D);
}