Skip to content

Commit

Permalink
Whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tjbladez committed Mar 23, 2011
1 parent 1309409 commit f25eea9
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 122 deletions.
21 changes: 11 additions & 10 deletions using_nehe_lessons/lesson02.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'rubygems'
require 'gosu'
require 'gl'
require 'glu'
Expand All @@ -9,31 +10,31 @@
class Window < Gosu::Window
def initialize
super(800, 600, false)
self.caption = "Lesson #2"
self.caption = "Lesson #2 - Polygons"
end

def update
end

def draw
gl do
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # see lesson01
glMatrixMode(GL_PROJECTION) # see lesson01
glMatrixMode(GL_PROJECTION) # see lesson01
glLoadIdentity # see lesson01
gluPerspective(45.0, width / height, 0.1, 100.0) # see lesson01
glMatrixMode(GL_MODELVIEW) # see lesson01
glMatrixMode(GL_MODELVIEW) # see lesson01
glLoadIdentity # see lesson01

glTranslatef(-2, 0, -10) # see lesson01

glBegin(GL_TRIANGLES) # see lesson01
glVertex3f( 0, 1, 0) # see lesson01
glVertex3f( 1, -1, 0)
glVertex3f(-1, -1, 0)
glVertex3f( 0, 1, 0) # see lesson01
glVertex3f( 1, -1, 0)
glVertex3f(-1, -1, 0)
glEnd
end
end

def button_down(id)
if id == Gosu::KbEscape
close
Expand Down
26 changes: 13 additions & 13 deletions using_nehe_lessons/lesson03.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ def initialize
super(800, 600, false)
self.caption = "Lesson #3 - Adding colors"
end

def update
end

def draw
gl do
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) #explained in nehe lesson02 [see lesson01]

glMatrixMode(GL_PROJECTION) # see lesson01
glMatrixMode(GL_PROJECTION) # see lesson01
glLoadIdentity # see lesson01

gluPerspective(45.0, width / height, 0.1, 100.0) # see lesson01
glMatrixMode(GL_MODELVIEW) # see lesson01

glMatrixMode(GL_MODELVIEW) # see lesson01
glLoadIdentity # see lesson01

glTranslatef(-2, 0, -10) # see lesson01

glBegin(GL_TRIANGLES) # see lesson01
glColor3f(1, 0, 0) # sets color to be used using RBG
glVertex3f( 0,1, 0)
glColor3f(0, 1, 0)
glVertex3f( 1, -1, 0)
glColor3f(0, 0, 1)
glVertex3f(-1, -1, 0)
glColor3f(1, 0, 0) # sets color to be used using RBG
glVertex3f( 0,1, 0)
glColor3f(0, 1, 0)
glVertex3f( 1, -1, 0)
glColor3f(0, 0, 1)
glVertex3f(-1, -1, 0)
glEnd
end
end

def button_down(id)
if id == Gosu::KbEscape
close
Expand Down
20 changes: 10 additions & 10 deletions using_nehe_lessons/lesson04.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@

class Window < Gosu::Window
attr_accessor :rotation_angle

def initialize
super(800, 600, false)
self.caption = "Lesson #4 - Rotation animation"
@rotation_angle = 0
end

def update
@rotation_angle += 0.2
end

def draw
gl do
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # see lesson01

glMatrixMode(GL_PROJECTION) # see lesson01
glLoadIdentity #
glMatrixMode(GL_PROJECTION) # see lesson01
glLoadIdentity #

gluPerspective(45.0, width / height, 0.1, 100.0) # see lesson01
glMatrixMode(GL_MODELVIEW) # see lesson01

glMatrixMode(GL_MODELVIEW) # see lesson01
glLoadIdentity # see lesson01

glTranslatef(-2, 0, -10) # see lesson01

glRotatef(@rotation_angle, 0, 1, 0) # rotate object around vector set by traveling to x,y,z from current unit, angle is in degrees

glBegin(GL_TRIANGLES) # see lesson01
glColor3f(1, 0, 0) # see nehe03
glVertex3f( 0,1, 0)
Expand All @@ -45,7 +45,7 @@ def draw
glEnd
end
end

def button_down(id)
if id == Gosu::KbEscape
close
Expand Down
76 changes: 38 additions & 38 deletions using_nehe_lessons/lesson05.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,63 @@

class Window < Gosu::Window
attr_accessor :rotation_angle

def initialize
super(800, 600, false)
self.caption = "Lesson #5 - 3D"
self.caption = "Lesson #5 - 3D Shapes"
@rotation_angle = 0
end

def update
@rotation_angle += 0.2
end

def draw
gl do
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # see lesson01

glMatrixMode(GL_PROJECTION) # see lesson01
glMatrixMode(GL_PROJECTION) # see lesson01
glLoadIdentity # see lesson01

gluPerspective(45.0, width / height, 0.1, 100.0) # see lesson01
glMatrixMode(GL_MODELVIEW) # see lesson01

glMatrixMode(GL_MODELVIEW) # see lesson01
glLoadIdentity # see lesson01

glTranslatef(0, 0, -7) # see lesson01

glRotatef(@rotation_angle, 0.0, 1.0, 0.0) # see nehe04

glBegin(GL_TRIANGLES) # see lesson01
glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 1, 0)
glVertex3f(-1, -1, 1)
glColor3f(0, 0, 1)
glVertex3f(1, -1, 1)
glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 1, 0)
glVertex3f( 1, -1, 1)
glColor3f(0, 0, 1)
glVertex3f(1, -1, -1)
glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 0, 1)
glVertex3f(-1, -1, 1)
glColor3f(0, 0, 1)
glVertex3f(-1, -1, -1)
glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 1, 0)
glVertex3f(-1, -1, -1)
glColor3f(0, 0, 1)
glVertex3f(1, -1, -1)
glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 1, 0)
glVertex3f(-1, -1, 1)
glColor3f(0, 0, 1)
glVertex3f(1, -1, 1)

glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 1, 0)
glVertex3f( 1, -1, 1)
glColor3f(0, 0, 1)
glVertex3f(1, -1, -1)

glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 0, 1)
glVertex3f(-1, -1, 1)
glColor3f(0, 0, 1)
glVertex3f(-1, -1, -1)

glColor3f(1, 0, 0)
glVertex3f( 0, 1, 0)
glColor3f(0, 1, 0)
glVertex3f(-1, -1, -1)
glColor3f(0, 0, 1)
glVertex3f(1, -1, -1)
glEnd

glColor3f(1, 0, 0)
glBegin(GL_QUADS)
glVertex3f(1, -1, 1)
Expand All @@ -74,7 +74,7 @@ def draw
glEnd
end
end

def button_down(id)
if id == Gosu::KbEscape
close
Expand Down
36 changes: 18 additions & 18 deletions using_nehe_lessons/lesson07.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ def initialize_light
def initialize_textures
gl do
nearest = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, nearest.info.tex_name); # see lesson 1
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) # Nearest filter is the worst on quality
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST) # but fastest and lowest need for processing power

linear = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, linear.info.tex_name);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) # Linear filter, good quality - high demands see nehe06
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)

minimap = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, minimap.info.tex_name);
texture = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT) #use texture data to get data for buildimg a mipmap
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
# Mipmapping. OpenGL tried to build different sized high quality texture. When you draw it OpenGL will select the best
# looking texture from ones it built and draw that instead of resizing the original image which can cause detail loss
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST)
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB, GL_FLOAT, texture) # building mipmaps
@filters = [nearest.info.tex_name, linear.info.tex_name, minimap.info.tex_name]
glBindTexture(GL_TEXTURE_2D, nearest.info.tex_name); # see lesson 1
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) # Nearest filter is the worst on quality
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST) # but fastest and lowest need for processing power

linear = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, linear.info.tex_name);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) # Linear filter, good quality - high demands see nehe06
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)

minimap = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, minimap.info.tex_name);
texture = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT) #use texture data to get data for buildimg a mipmap
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
# Mipmapping. OpenGL tried to build different sized high quality texture. When you draw it OpenGL will select the best
# looking texture from ones it built and draw that instead of resizing the original image which can cause detail loss
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST)
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB, GL_FLOAT, texture) # building mipmaps
@filters = [nearest.info.tex_name, linear.info.tex_name, minimap.info.tex_name]
end
end

Expand Down
38 changes: 19 additions & 19 deletions using_nehe_lessons/lesson08.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ def initialize_light
def initialize_textures
gl do
nearest = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, nearest.info.tex_name) # see lesson 1
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) # see nehe07
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST) # see nehe07

linear = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, linear.info.tex_name)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) # see nehe06
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)

minimap = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, minimap.info.tex_name)
texture = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT) # see nehe07
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST) # see nehe07
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB, GL_FLOAT, texture) # see nehe07
@filters = [nearest.info.tex_name, linear.info.tex_name, minimap.info.tex_name]
glBindTexture(GL_TEXTURE_2D, nearest.info.tex_name) # see lesson 1
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) # see nehe07
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST) # see nehe07

linear = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, linear.info.tex_name)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) # see nehe06
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)

minimap = Texture.new(self)
glBindTexture(GL_TEXTURE_2D, minimap.info.tex_name)
texture = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT) # see nehe07
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST) # see nehe07
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB, GL_FLOAT, texture) # see nehe07
@filters = [nearest.info.tex_name, linear.info.tex_name, minimap.info.tex_name]
end
end

Expand Down Expand Up @@ -109,8 +109,8 @@ def draw
glDisable(GL_DEPTH_TEST) # disable depth
else
glDisable(GL_BLEND)
glEnable(GL_DEPTH_TEST)
end
glEnable(GL_DEPTH_TEST)
end
glTranslate(0, 0, @z_depth) #see lesson 01

glBindTexture(GL_TEXTURE_2D, current_filter) #see lesson 01
Expand Down
Loading

0 comments on commit f25eea9

Please sign in to comment.