-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIcon.cpp
More file actions
37 lines (31 loc) · 766 Bytes
/
Icon.cpp
File metadata and controls
37 lines (31 loc) · 766 Bytes
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
//
// Created by bpiranda on 13/12/2019.
//
#include "Icon.h"
Icon::Icon(float c_width, float c_height, const string &c_title):width(c_width),height(c_height),title(c_title) {
textureId=0;
}
Icon::~Icon() {
}
void Icon::glDraw() {
if (textureId==0) {
int w,h;
textureId=GlutWindow::loadTGATexture(title,w,h);
}
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,textureId);
glScalef(width,height,1.0f);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(-0.5,-0.5);
glTexCoord2f(1.0f,0);
glVertex2f(0.5,-0.5);
glTexCoord2f(1.0f,1.0f);
glVertex2f(0.5,0.5);
glTexCoord2f(0,1.0f);
glVertex2f(-0.5,0.5);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}