line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenGL::Earth::Scene; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1442
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
456
|
use OpenGL q(:all); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use OpenGL::Earth::NetworkHits; |
7
|
|
|
|
|
|
|
use OpenGL::Earth::Physics; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @LIGHT_AMBIENT = ( 0.0, 0.0, 0.1, 0.2 ); |
10
|
|
|
|
|
|
|
our @LIGHT_DIFFUSE = ( 1.2, 1.2, 1.2, 1.0 ); |
11
|
|
|
|
|
|
|
our @LIGHT_POSITION = ( 4.0, 4.0, 2.0, 3.0); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub render { |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Enables, disables or otherwise adjusts as |
16
|
|
|
|
|
|
|
# appropriate for our current settings. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
if ($OpenGL::Earth::TEXTURE_ON) { |
19
|
|
|
|
|
|
|
glEnable(GL_TEXTURE_2D); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
|
|
|
|
|
|
glDisable(GL_TEXTURE_2D); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
if ($OpenGL::Earth::LIGHT_ON) { |
25
|
|
|
|
|
|
|
glEnable(GL_LIGHTING); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
|
|
|
|
|
|
glDisable(GL_LIGHTING); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#if ($OpenGL::Earth::ALPHA_ADD) { |
32
|
|
|
|
|
|
|
# glBlendFunc(GL_SRC_ALPHA,GL_ONE); |
33
|
|
|
|
|
|
|
#} |
34
|
|
|
|
|
|
|
#else { |
35
|
|
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); |
36
|
|
|
|
|
|
|
#} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# If we're blending, we don'$t want z-buffering. |
39
|
|
|
|
|
|
|
if ($OpenGL::Earth::BLEND_ON) { |
40
|
|
|
|
|
|
|
glDisable(GL_DEPTH_TEST); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
if ($OpenGL::Earth::FILTERING_ON) { |
46
|
|
|
|
|
|
|
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); |
47
|
|
|
|
|
|
|
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
|
|
|
|
|
|
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); |
51
|
|
|
|
|
|
|
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Need to manipulate the ModelView matrix to move our model around. |
55
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Reset to 0,0,0; no rotation, no scaling. |
58
|
|
|
|
|
|
|
glLoadIdentity(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
OpenGL::Earth::Physics::move(); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Clear the color and depth buffers. |
63
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $quad = gluNewQuadric(); |
66
|
|
|
|
|
|
|
if ($quad != 0) |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
gluQuadricNormals($quad, GLU_SMOOTH); |
69
|
|
|
|
|
|
|
gluQuadricTexture($quad, GL_TRUE); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#my @Earth_emission = (0.0, 0.0, 0.0, 1.0); |
72
|
|
|
|
|
|
|
#my @Earth_specular = (0.3, 0.3, 0.3, 1.0); |
73
|
|
|
|
|
|
|
#glMaterialf(GL_FRONT, GL_EMISSION, 0.0); #@Earth_emission); |
74
|
|
|
|
|
|
|
#glMaterialf(GL_FRONT, GL_SPECULAR, 50.0); #@Earth_specular); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Render Earth sphere |
77
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, $OpenGL::Earth::TEXTURES[0]); |
78
|
|
|
|
|
|
|
glColor3f(0.6, 0.6, 0.6); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
gluSphere($quad, 1.5, 64, 64); |
81
|
|
|
|
|
|
|
gluDeleteQuadric($quad); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
glDisable(GL_LIGHTING); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
OpenGL::Earth::NetworkHits::display(); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Sense the wii motion |
89
|
|
|
|
|
|
|
my $motion = OpenGL::Earth::Wiimote::get_motion(); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Move back to the origin (for the text, below). |
92
|
|
|
|
|
|
|
glLoadIdentity(); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
OpenGL::Earth::Render::text_stats($motion); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# All done drawing. Let's show it. |
97
|
|
|
|
|
|
|
glutSwapBuffers(); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#static_motion_calc($motion); |
100
|
|
|
|
|
|
|
OpenGL::Earth::Physics::calculate_falloff_motion($motion); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# And collect our statistics. |
103
|
|
|
|
|
|
|
#ourDoFPS(); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub resize { |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my ($width, $height) = @_; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# Let's not core dump, no matter what. |
113
|
|
|
|
|
|
|
$height = 1 if ($height == 0); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
glViewport(0, 0, $width, $height); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION); |
118
|
|
|
|
|
|
|
glLoadIdentity(); |
119
|
|
|
|
|
|
|
gluPerspective(45.0,$width/$height,0.1,100.0); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$OpenGL::Earth::WINDOW_WIDTH = $width; |
124
|
|
|
|
|
|
|
$OpenGL::Earth::WINDOW_HEIGHT = $height; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
return; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub setup_lighting { |
130
|
|
|
|
|
|
|
glLightfv_p(GL_LIGHT1, GL_POSITION, @LIGHT_POSITION); |
131
|
|
|
|
|
|
|
glLightfv_p(GL_LIGHT1, GL_AMBIENT, @LIGHT_AMBIENT); |
132
|
|
|
|
|
|
|
glLightfv_p(GL_LIGHT1, GL_DIFFUSE, @LIGHT_DIFFUSE); |
133
|
|
|
|
|
|
|
glEnable (GL_LIGHT1); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
137
|
|
|
|
|
|
|
|