HOG2
MNPuzzle.cpp
Go to the documentation of this file.
1 /*
2  * MNPuzzle.cpp
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 5/9/07.
6  * Copyright 2007 Nathan Sturtevant, University of Alberta. All rights reserved.
7  *
8  */
9 
10 
11 #include "MNPuzzle.h"
12 
13 void DrawTile(float x, float y, char c1, char c2, int w, int h)
14 {
15  //glLineWidth(10.0);
16  int textWidth = 0;
17  //if (c1 != 0)
18  // textWidth += glutStrokeWidth(GLUT_STROKE_ROMAN, c1);
19  // if (c2 != 0)
20  // textWidth += glutStrokeWidth(GLUT_STROKE_ROMAN, c2);
21  if (textWidth == 0)
22  return;
23  //printf("%d\n", textWidth);
24  glPushMatrix();
25  glColor3f(0.0, 0.0, 1.0);
26  glTranslatef(x*2.0/w-1.0, (1+y)*2.0/h-1.0-0.15, -0.001);
27  glScalef(1.0/(w*120.0), 1.0/(h*120.0), 1);
28  glRotatef(180, 0.0, 0.0, 1.0);
29  glRotatef(180, 0.0, 1.0, 0.0);
30  glTranslatef(120-textWidth/2, 0, 0);
31  //if (c1 != 0)
32  // glutStrokeCharacter(GLUT_STROKE_ROMAN, c1);
33  //if (c2 != 0)
34  // glutStrokeCharacter(GLUT_STROKE_ROMAN, c2);
35  //glTranslatef(-x/width+0.5, -y/height+0.5, 0);
36  glPopMatrix();
37 
38  glLineWidth(1.0);
39  glColor3f(1, 1, 1);
40  glBegin(GL_QUADS);
41  glVertex3f(x*2.0/w-1+.05/w, (y)*2.0/h-1+.05/h, 0.002);
42  glVertex3f((x+1)*2.0/w-1-.05/w, (y)*2.0/h-1+.05/h, 0.002);
43  glVertex3f((x+1)*2.0/w-1-.05/w, (y+1)*2.0/h-1-.05/h, 0.002);
44  glVertex3f(x*2.0/w-1+.05/w, (y+1)*2.0/h-1-.05/h, 0.002);
45  glEnd();
46 }
47 
48 void DrawFrame(int w, int h)
49 {
50  // frame
51  glLineWidth(3.0);
52  glColor3f(1.0, 1.0, 1.0);
53  glBegin(GL_LINE_LOOP);
54  glVertex3f(-1-.05/w, -1-.05/h, 0.002);
55  glVertex3f(1+.05/w, -1-.05/h, 0.002);
56  glVertex3f(1+.05/w, 1+.05/h, 0.002);
57  glVertex3f(-1-.05/w, 1+.05/h, 0.002);
58  glEnd();
59 
60  glColor3f(0.25, 0.25, 0.25);
61  glBegin(GL_QUADS);
62  glVertex3f(-1-.05/w, -1-.05/h, 0.003);
63  glVertex3f(1+.05/w, -1-.05/h, 0.003);
64  glVertex3f(1+.05/w, 1+.05/h, 0.003);
65  glVertex3f(-1-.05/w, 1+.05/h, 0.003);
66  glEnd();
67  glLineWidth(1.0);
68 }
DrawFrame
void DrawFrame(int w, int h)
Definition: MNPuzzle.cpp:48
DrawTile
void DrawTile(float x, float y, char c1, char c2, int w, int h)
Definition: MNPuzzle.cpp:13
MNPuzzle.h