Fix FXGLLine and FXGLPoint and add them to glviewer.rb
Lars Kanis
3 years ago
482 | 482 |
sphere = FXGLSphere.new(1.0, 1.0, 0.0, 0.5)
|
483 | 483 |
sphere2 = FXGLSphere.new(0.0, 0.0, 0.0, 0.8)
|
484 | 484 |
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))
|
485 | 487 |
gp2.append(FXGLCube.new(-1.0, 0.0, 0.0, 1.0, 1.0, 1.0))
|
486 | 488 |
gp2.append(FXGLCube.new( 1.0, 0.0, 0.0, 1.0, 1.0, 1.0))
|
487 | 489 |
gp2.append(FXGLCube.new( 0.0,-1.0, 0.0, 1.0, 1.0, 1.0))
|
47 | 47 |
# Draw this point into _viewer_ (an FXGLViewer instance).
|
48 | 48 |
#
|
49 | 49 |
def draw(viewer)
|
50 | |
glColor(0.0, 0.0, 1.0)
|
|
50 |
glColor3d(0.0, 0.0, 1.0)
|
51 | 51 |
glPointSize(HANDLE_SIZE)
|
52 | 52 |
glBegin(GL_POINTS)
|
53 | |
glVertex(@pos)
|
|
53 |
glVertex3d(*@pos)
|
54 | 54 |
glEnd()
|
55 | 55 |
end
|
56 | 56 |
|
|
59 | 59 |
#
|
60 | 60 |
def hit(viewer)
|
61 | 61 |
glBegin(GL_POINTS)
|
62 | |
glVertex(@pos)
|
|
62 |
glVertex3d(*@pos)
|
63 | 63 |
glEnd()
|
64 | 64 |
end
|
65 | 65 |
end
|
|
68 | 68 |
# OpenGL line object
|
69 | 69 |
#
|
70 | 70 |
class FXGLLine < FXGLObject
|
|
71 |
include OpenGL
|
71 | 72 |
|
72 | 73 |
# Starting point for line [FXGLPoint]
|
73 | 74 |
attr_accessor :fm
|
|
120 | 121 |
# Draw this line into _viewer_ (an FXGLViewer instance).
|
121 | 122 |
#
|
122 | 123 |
def draw(viewer)
|
123 | |
glColor(1.0, 0.0, 0.0)
|
|
124 |
glColor3d(1.0, 0.0, 0.0)
|
124 | 125 |
glPointSize(HANDLE_SIZE)
|
125 | 126 |
glBegin(GL_LINES)
|
126 | |
glVertex(@fm.pos)
|
127 | |
glVertex(@to.pos)
|
|
127 |
glVertex3d(*@fm.pos)
|
|
128 |
glVertex3d(*@to.pos)
|
128 | 129 |
glEnd()
|
129 | 130 |
end
|
130 | 131 |
|
|
133 | 134 |
#
|
134 | 135 |
def hit(viewer)
|
135 | 136 |
glBegin(GL_LINES)
|
136 | |
glVertex(@fm.pos)
|
137 | |
glVertex(@to.pos)
|
|
137 |
glVertex3d(*@fm.pos)
|
|
138 |
glVertex3d(*@to.pos)
|
138 | 139 |
glEnd()
|
139 | 140 |
end
|
140 | 141 |
end
|