/
display.c
57 lines (51 loc) · 988 Bytes
/
display.c
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
#include "screencasts.h"
/*
* displayReshape()
* ------
* GLUT calls this routine when the window is resized
*/
void displayReshape(int width,int height)
{
asp = (height>0) ? (double)width/height : 1;
glViewport(0,0, width,height);
displayProject(fov,asp,dim);
}
/*
* displayProject()
* ------
* Sets the projection
*/
void displayProject(double fov, double asp, double dim)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// 2D only for this example
gluOrtho2D(-asp,+asp,-1,+1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
/*
* display()
* ------
* Display the scene
*/
void display(void)
{
/* setup functions */
glClear(GL_COLOR_BUFFER_BIT);
/* Draw Scene */
drawScene();
/* Flush and sanity check */
glFlush();
errCheck("display sanity check");
}
/*
* redisplayAll()
* ------
* This is called whenever we need to draw the display
*/
void redisplayAll(void)
{
displayProject(fov,asp,dim);
glutPostRedisplay();
}