Codebase list ruby-fxruby / 58e4400
Fix FXGLLine and FXGLPoint and add them to glviewer.rb Lars Kanis 3 years ago
2 changed file(s) with 11 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
482482 sphere = FXGLSphere.new(1.0, 1.0, 0.0, 0.5)
483483 sphere2 = FXGLSphere.new(0.0, 0.0, 0.0, 0.8)
484484 sphere.tipText = "Sphere"
485 gp2.append(FXGLLine.new(-2.0, 0.0, 0.0, -1.0, 1.0, 1.0))
486 gp2.append(FXGLPoint.new(-2.0, 0.0, 0.0))
485487 gp2.append(FXGLCube.new(-1.0, 0.0, 0.0, 1.0, 1.0, 1.0))
486488 gp2.append(FXGLCube.new( 1.0, 0.0, 0.0, 1.0, 1.0, 1.0))
487489 gp2.append(FXGLCube.new( 0.0,-1.0, 0.0, 1.0, 1.0, 1.0))
4747 # Draw this point into _viewer_ (an FXGLViewer instance).
4848 #
4949 def draw(viewer)
50 glColor(0.0, 0.0, 1.0)
50 glColor3d(0.0, 0.0, 1.0)
5151 glPointSize(HANDLE_SIZE)
5252 glBegin(GL_POINTS)
53 glVertex(@pos)
53 glVertex3d(*@pos)
5454 glEnd()
5555 end
5656
5959 #
6060 def hit(viewer)
6161 glBegin(GL_POINTS)
62 glVertex(@pos)
62 glVertex3d(*@pos)
6363 glEnd()
6464 end
6565 end
6868 # OpenGL line object
6969 #
7070 class FXGLLine < FXGLObject
71 include OpenGL
7172
7273 # Starting point for line [FXGLPoint]
7374 attr_accessor :fm
120121 # Draw this line into _viewer_ (an FXGLViewer instance).
121122 #
122123 def draw(viewer)
123 glColor(1.0, 0.0, 0.0)
124 glColor3d(1.0, 0.0, 0.0)
124125 glPointSize(HANDLE_SIZE)
125126 glBegin(GL_LINES)
126 glVertex(@fm.pos)
127 glVertex(@to.pos)
127 glVertex3d(*@fm.pos)
128 glVertex3d(*@to.pos)
128129 glEnd()
129130 end
130131
133134 #
134135 def hit(viewer)
135136 glBegin(GL_LINES)
136 glVertex(@fm.pos)
137 glVertex(@to.pos)
137 glVertex3d(*@fm.pos)
138 glVertex3d(*@to.pos)
138139 glEnd()
139140 end
140141 end