-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbins.cpp
More file actions
41 lines (36 loc) · 1.01 KB
/
bins.cpp
File metadata and controls
41 lines (36 loc) · 1.01 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
#include "bins.h"
bin::bin(double xx, double yy)
{
filled = false;
x = xx;
y = yy;
c = randomColor();
}
void bin::draw()
{
GLUquadric *myQuad;
myQuad=gluNewQuadric();
glPushMatrix();
glTranslated(x*20,0,y*20);
glRotated(-90,1,0,0);
glScaled(0.25,0.25,0.25);
glTranslated(0,1,0);
glDisable(GL_COLOR_MATERIAL); //Required for the glMaterial calls to work
if(!filled)
{
GLfloat materialColor[] = {c.r, c.g, c.b, c.a};
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColor);
}
else
{
GLfloat materialColor[] = {0, 0, 0, 1};
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColor);
}
GLfloat materialSpecular[] = {0.8f, 0.8f, 0.8f, 1.0f};
GLfloat materialEmission[] = {0, 0, 0, 1.0f};
glMaterialfv(GL_FRONT, GL_SPECULAR, materialSpecular);
glMaterialfv(GL_FRONT, GL_EMISSION, materialEmission);
glMaterialf(GL_FRONT, GL_SHININESS, 15.0f);
gluCylinder( myQuad, 2.0, 2.0, 3.0, 20, 2 );
glPopMatrix();
}