Skip to content
Browse files

Adds stars

  • Loading branch information...
1 parent 5fce11b commit 770ca4a98ee28819b6735c1f23f5f11c20b60c4e @dorsath dorsath committed Feb 11, 2012
Showing with 28 additions and 1 deletion.
  1. +5 −0 lib/models/sky.rb
  2. +19 −0 lib/views/sky_view.rb
  3. +1 −1 lib/views/window.rb
  4. +3 −0 playground
  5. BIN textures/starmap.bmp
View
5 lib/models/sky.rb
@@ -0,0 +1,5 @@
+class Sky
+ include Rotation
+
+
+end
View
19 lib/views/sky_view.rb
@@ -0,0 +1,19 @@
+class SkyView < View
+ def draw
+ glMultMatrix(@model.matrix)
+
+ texture = $window.textures.find(:starmap)
+
+ quadro = gluNewQuadric();
+ gluQuadricNormals(quadro, GLU_SMOOTH);
+ gluQuadricTexture(quadro, GL_TRUE);
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ gluSphere(quadro, 1000, 72, 72);
+ glDisable(GL_TEXTURE_2D);
+ gluDeleteQuadric(quadro);
+
+ end
+end
View
2 lib/views/window.rb
@@ -57,7 +57,7 @@ def reshape(width, height)
glViewport 0, 0, width, height
glMatrixMode(GL_PROJECTION)
glLoadIdentity
- gluPerspective(45, width / height, 0.1, 1000)
+ gluPerspective(45, width / height, 0.1, 10000)
glMatrixMode(GL_MODELVIEW)
end
View
3 playground
@@ -3,7 +3,9 @@
require 'environment'
require 'models/spaceship'
+require 'models/sky'
require 'views/fuselage'
+require 'views/sky_view'
class SpaceWars < Controller
@@ -98,6 +100,7 @@ $camera.pitch(Math::PI/2)
window.views << CameraView.new($camera)
window.views << Fuselage.new(space_wars.spaceship)
+window.views << SkyView.new(Sky.new)
# window.views << SunView.new(Sun.new)
$window = window
View
BIN textures/starmap.bmp
Binary file not shown.

0 comments on commit 770ca4a

Please sign in to comment.
Something went wrong with that request. Please try again.