class Fox::FXGLGroup

A group of OpenGL objects

Constants

FLT_MAX
FLT_MIN

Public Class Methods

new() click to toggle source

Returns an initialized FXGLGroup instance

Calls superclass method Fox::FXGLObject::new
# File lib/fox16/glgroup.rb, line 21
def initialize
  super
  @list = []
end

Public Instance Methods

<<(obj)
Alias for: append
[](pos) click to toggle source

Return child at position pos.

# File lib/fox16/glgroup.rb, line 36
def [](pos)
  @list[pos]
end
[]=(pos, obj) click to toggle source

Set child at position pos to obj.

# File lib/fox16/glgroup.rb, line 43
def []=(pos, obj)
  @list[pos] = obj
end
append(obj) click to toggle source

Append child object

# File lib/fox16/glgroup.rb, line 131
def append(obj)
  @list << obj
end
Also aliased as: <<
bounds() click to toggle source

Return bounding box for this group (an FXRangef instance)

# File lib/fox16/glgroup.rb, line 60
def bounds
  box = nil
  if @list.empty?
    box = FXRangef.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
  else
    box = FXRangef.new(FLT_MAX, -FLT_MAX, FLT_MAX, -FLT_MAX, FLT_MAX, -FLT_MAX)
    @list.each { |obj| box.include!(obj.bounds) }
  end
  box
end
canDrag() click to toggle source

Return true if group can be dragged.

# File lib/fox16/glgroup.rb, line 102
def canDrag
  true
end
clear() click to toggle source

Remove all children from this group.

# File lib/fox16/glgroup.rb, line 162
def clear
  @list.clear
end
drag(viewer, fx, fy, tx, ty) click to toggle source

Drag group object around in viewer (an FXGLViewer instance), from (fx, fy) to (tx, ty).

# File lib/fox16/glgroup.rb, line 110
def drag(viewer, fx, fy, tx, ty)
  @list.each { |obj| obj.drag(viewer, fx, fy, tx, ty) }
end
draw(viewer) click to toggle source

Draw this group into viewer (an FXGLViewer instance).

# File lib/fox16/glgroup.rb, line 74
def draw(viewer)
  @list.each { |obj| obj.draw(viewer) }
end
each()
Alias for: each_child
each_child() { |childObject| ... } click to toggle source

Iterate over child objects

# File lib/fox16/glgroup.rb, line 50
def each_child # :yields: childObject
  @list.each { |child| yield child }
  self
end
Also aliased as: each
erase(obj)
Alias for: remove
hit(viewer) click to toggle source

Perform hit test in viewer (an FXGLViewer instance).

# File lib/fox16/glgroup.rb, line 81
    def hit(viewer)
#     GL.PushName(0xffffffff)
      GL.PushName(1000000)
      @list.each_with_index do |obj, i|
        GL.LoadName(i)
        obj.hit(viewer)
      end
      GL.PopName
    end
identify(path) click to toggle source

Identify object by means of path.

# File lib/fox16/glgroup.rb, line 94
def identify(path)
  objIndex = path.shift
  @list[objIndex].identify(path)
end
insert(pos, obj) click to toggle source

Insert child object (obj) at position pos.

# File lib/fox16/glgroup.rb, line 117
def insert(pos, obj)
  raise NotImplementedError
end
prepend(obj) click to toggle source

Prepend child object (obj).

# File lib/fox16/glgroup.rb, line 124
def prepend(obj)
  @list.unshift(obj)
end
remove(obj) click to toggle source

If obj is a reference to an FXGLObject in this group, remove the child object from the list. If obj is an integer, remove the child object at that position from the list.

# File lib/fox16/glgroup.rb, line 149
def remove(obj)
  if obj.is_a? FXGLObject
    @list.delete(obj)
  else
    @list.delete_at(obj)
  end
end
Also aliased as: erase
replace(pos, obj) click to toggle source

Replace child object at position pos with obj.

# File lib/fox16/glgroup.rb, line 140
def replace(pos, obj)
  @list[pos] = obj
end
size() click to toggle source

Return number of objects in this group.

# File lib/fox16/glgroup.rb, line 29
def size
  @list.size
end