Class: SGL::Application

Inherits:
Object
  • Object
show all
Includes:
FrameTranslator
Defined in:
lib/sgl/cocoa-app.rb,
lib/sgl/sgl-sound.rb,
lib/sgl/cocoa-draw.rb,
lib/sgl/opengl-app.rb,
lib/sgl/cocoa-color.rb,
lib/sgl/cocoa-event.rb,
lib/sgl/cocoa-media.rb,
lib/sgl/opengl-draw.rb,
lib/sgl/cocoa-window.rb,
lib/sgl/opengl-color.rb,
lib/sgl/opengl-event.rb,
lib/sgl/opengl-window.rb,
lib/sgl/opengl-modules.rb

Constant Summary collapse

LINES =
GL::LINES
POINTS =
GL::POINTS
LINE_STRIP =
GL::LINE_STRIP
LINE_LOOP =
GL::LINE_LOOP
TRIANGLES =
GL::TRIANGLES
TRIANGLE_STRIP =
GL::TRIANGLE_STRIP
TRIANGLE_FAN =
GL::TRIANGLE_FAN
QUADS =
GL::QUADS
QUAD_STRIP =
GL::QUAD_STRIP
POLYGON =
GL::POLYGON
DEFAULT_WINDOW_WIDTH =
100
DEFAULT_WINDOW_HEIGHT =
100
DEFAULT_FULLSCREEN_WIDTH =
1024
DEFAULT_FULLSCREEN_HEIGHT =
768

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



14
15
16
17
18
19
# File 'lib/sgl/cocoa-app.rb', line 14

def initialize
  initialize_cocoa
  initialize_window
  initialize_color
  initialize_event
end

Instance Attribute Details

#cur_colorObject (readonly)

for test



18
19
20
# File 'lib/sgl/opengl-color.rb', line 18

def cur_color
  @cur_color
end

#heightObject (readonly)

get window size



123
124
125
# File 'lib/sgl/opengl-window.rb', line 123

def height
  @height
end

#keynumObject (readonly)

Returns the value of attribute keynum.



50
51
52
# File 'lib/sgl/cocoa-event.rb', line 50

def keynum
  @keynum
end

#mouseDownObject (readonly)

Returns the value of attribute mouseDown.



49
50
51
# File 'lib/sgl/cocoa-event.rb', line 49

def mouseDown
  @mouseDown
end

#mouseXObject (readonly)

get status



48
49
50
# File 'lib/sgl/cocoa-event.rb', line 48

def mouseX
  @mouseX
end

#mouseX0Object (readonly)

Returns the value of attribute mouseX0.



81
82
83
# File 'lib/sgl/opengl-event.rb', line 81

def mouseX0
  @mouseX0
end

#mouseYObject (readonly)

get status



48
49
50
# File 'lib/sgl/cocoa-event.rb', line 48

def mouseY
  @mouseY
end

#mouseY0Object (readonly)

Returns the value of attribute mouseY0.



81
82
83
# File 'lib/sgl/opengl-event.rb', line 81

def mouseY0
  @mouseY0
end

#runtimeObject

for test



45
46
47
# File 'lib/sgl/cocoa-event.rb', line 45

def runtime
  @runtime
end

#widthObject (readonly)

get window size



123
124
125
# File 'lib/sgl/opengl-window.rb', line 123

def width
  @width
end

Instance Method Details

#background(x, y = nil, z = nil, a = nil) ⇒ Object



19
20
21
# File 'lib/sgl/cocoa-color.rb', line 19

def background(x, y=nil, z=nil, a=nil)
  @bg_color = @rgb.norm(x,y,z,a)
end

#backgroundHSV(x, y = nil, z = nil, a = nil) ⇒ Object



23
24
25
# File 'lib/sgl/cocoa-color.rb', line 23

def backgroundHSV(x, y=nil, z=nil, a=nil)
  @bg_color = @hsv.norm(x,y,z,a)
end

#beginObj(mode = POLYGON) ⇒ Object

draw primitive



50
51
52
# File 'lib/sgl/opengl-draw.rb', line 50

def beginObj(mode = POLYGON)
  GL.Begin(mode)
end

#box(x1, y1, z1, x2, y2, z2) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/sgl/opengl-draw.rb', line 158

def box(x1, y1, z1, x2, y2, z2)
  box = [
	[x1, y1, z1], # 0 back left bottom
	[x2, y1, z1], # 1 back right bottom
	[x2, y2, z1], # 2 back right top
	[x1, y2, z1], # 3 back left top
	[x1, y1, z2], # 4 front left bottom
	[x2, y1, z2], # 5 front right bottom
	[x2, y2, z2], # 6 front right top
	[x1, y2, z2]  # 7 front left top
  ]
  GL.Begin(GL::QUADS)
  GL.Vertex(box[1]) # back
  GL.Vertex(box[0])
  GL.Vertex(box[3])
  GL.Vertex(box[2])
  GL.Vertex(box[0]) # left
  GL.Vertex(box[4])
  GL.Vertex(box[7])
  GL.Vertex(box[3])
  GL.Vertex(box[4]) # front
  GL.Vertex(box[5])
  GL.Vertex(box[6])
  GL.Vertex(box[7])
  GL.Vertex(box[5]) # right
  GL.Vertex(box[1])
  GL.Vertex(box[2])
  GL.Vertex(box[6])
  GL.Vertex(box[7]) # top
  GL.Vertex(box[6])
  GL.Vertex(box[2])
  GL.Vertex(box[3])
  GL.Vertex(box[0]) # bottom
  GL.Vertex(box[1])
  GL.Vertex(box[5])
  GL.Vertex(box[4])
  GL.End
end

#check_display0Object



117
118
119
# File 'lib/sgl/opengl-event.rb', line 117

def check_display0
  return ! @block[:display0].nil?
end

#check_mousedown0Object



175
176
177
# File 'lib/sgl/opengl-event.rb', line 175

def check_mousedown0
  return ! @block[:mousedown0].nil?
end

#circle(x, y, r, style = LINE_LOOP, div = nil) ⇒ Object



45
46
47
48
# File 'lib/sgl/cocoa-draw.rb', line 45

def circle(x, y, r)
  rect = OSX::NSRect.new(x - r, y - r, 2*r, 2*r)
  OSX::NSBezierPath.bezierPathWithOvalInRect(rect).fill
end

#close_windowObject



63
64
65
66
# File 'lib/sgl/cocoa-window.rb', line 63

def close_window
  @win.close if @win
  @win = @bgview = nil
end

#cocoa_create_window(w, h) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/sgl/cocoa-window.rb', line 70

def cocoa_create_window(w, h)
  @receiver = CocoaReceiver.alloc.init
  @receiver.setApp(self)

  # create a window
  s = OSX::NSScreen.mainScreen.frame.size
  x = (s.width  - w) / 2.0
  y = (s.height - h) / 2.0
  win_frame = [x.to_f, y.to_f, w.to_f, h.to_f]
  style = OSX::NSClosableWindowMask
  style |= @options[:border] ? OSX::NSTitledWindowMask :
	OSX::NSBorderlessWindowMask
  win = NSWindow.alloc.
	initWithContentRect(win_frame,
   :styleMask, style,
   :backing, OSX::NSBackingStoreBuffered,
   :defer, true)
  win.setTitle("sgl")

  # create a view
  view = SglNSView.alloc.init
  view.setApp(self)
  win.setContentView(view)
  background(100)	# white
  color(0)		# black

  # for handling windowShouldClose
  win.setDelegate(@receiver)
  win.setOpaque(false)	# can be transparent
  win.setHasShadow(@options[:shadow])
  win.setReleasedWhenClosed(false)
  win.makeKeyAndOrderFront(@receiver)
  win.orderFrontRegardless	# show the window now
  @win = win
  @bgview = view
  window_movie(@options) if @options[:movie]
 #window_overlay(@options) if defined?(displayOverlay)
  window_overlay(@options) if @options[:overlay]
  @win
end

#color(x, y = nil, z = nil, a = nil) ⇒ Object



27
28
29
30
# File 'lib/sgl/cocoa-color.rb', line 27

def color(x, y=nil, z=nil, a=nil)
  @cur_color = @rgb.norm(x,y,z,a)
  set_cur_color
end

#colorHSV(x, y = nil, z = nil, a = nil) ⇒ Object



32
33
34
35
# File 'lib/sgl/cocoa-color.rb', line 32

def colorHSV(x, y=nil, z=nil, a=nil)
  @cur_color = @hsv.norm(x,y,z,a)
  set_cur_color
end

#cube(x, y, z, s) ⇒ Object



197
198
199
200
# File 'lib/sgl/opengl-draw.rb', line 197

def cube(x, y, z, s)
  s = s / 2
  box(x - s, y - s, z - s, x + s, y + s, z + s)
end

#display_all(rect) ⇒ Object

display



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/sgl/cocoa-event.rb', line 74

def display_all(rect) # callback
  return if @win.nil?
  return if @setup_done.nil?
  return if @display_drawing
  @display_drawing = true
  display_bg(rect)
  display_pre
  do_display
  display_post
  @display_drawing = nil
end

#display_mov(rect) ⇒ Object

sub view



126
127
128
129
# File 'lib/sgl/cocoa-event.rb', line 126

def display_mov(rect)
  display_clear_bg(rect)
  set_cur_color	# set back current color
end

#display_overlay_all(rect) ⇒ Object



131
132
133
134
135
136
137
138
139
140
# File 'lib/sgl/cocoa-event.rb', line 131

def display_overlay_all(rect)
  return if @win.nil?
  return if @setup_done.nil?
  return if @display_overlay_drawing
  @display_overlay_drawing = true
  display_clear_bg(rect)
  set_cur_color	# set back current color
  @block[:display_overlay].call if @block[:display_overlay]
  @display_overlay_drawing = nil
end

#do_displayObject

callback



127
128
129
130
131
132
# File 'lib/sgl/opengl-event.rb', line 127

def do_display
  return if @win.nil?
  display_pre
  @block[:display].call if @block[:display]
  display_post
end

#do_keydown(key) ⇒ Object



206
207
208
209
# File 'lib/sgl/cocoa-event.rb', line 206

def do_keydown(e)
  calc_keynum(e)
  @block[:keydown].call(@keynum) if @block[:keydown]
end

#do_keyup(key) ⇒ Object



216
217
218
219
220
# File 'lib/sgl/cocoa-event.rb', line 216

def do_keyup(e)
  calc_keynum(e)
  @keynum = 0
  @block[:keyup].call(@keynum) if @block[:keyup]
end

#do_mousedownObject



185
186
187
188
# File 'lib/sgl/cocoa-event.rb', line 185

def do_mousedown
  @mouseDown = 1
  @block[:mousedown].call(@mouseX, @mouseY) if @block[:mousedown]
end

#do_mouseupObject



195
196
197
198
# File 'lib/sgl/cocoa-event.rb', line 195

def do_mouseup
  @mouseDown = 0
  @block[:mouseup].call(@mouseX, @mouseY) if @block[:mouseup]
end

#do_setupObject



58
59
60
61
62
# File 'lib/sgl/cocoa-event.rb', line 58

def do_setup
  setup_pre
  @block[:setup].call if @block[:setup]
  setup_post
end

#endObjObject



54
55
56
# File 'lib/sgl/opengl-draw.rb', line 54

def endObj
  GL.End
end

#flipObject

novice mode



246
247
248
249
250
251
252
# File 'lib/sgl/opengl-event.rb', line 246

def flip
  @starttime = Time.now if @starttime.nil?
  display_post
  delay
  display_pre
 #exit if check_runtime_finished(@starttime)
end

#font(*a) ⇒ Object



40
41
42
# File 'lib/sgl/cocoa-media.rb', line 40

def font(*a)
  NSFont.new(self, *a)
end

#get_cur_color_alphaObject



43
44
45
# File 'lib/sgl/cocoa-color.rb', line 43

def get_cur_color_alpha
  @cur_color[3]
end

#image(file) ⇒ Object



34
35
36
37
38
# File 'lib/sgl/cocoa-media.rb', line 34

def image(file)
  img = NSImage.alloc.initWithContentsOfFile(file)
  img.setApp(self)
  img
end

#line(a, b, c, d, e = nil, f = nil) ⇒ Object



33
34
35
36
37
38
# File 'lib/sgl/cocoa-draw.rb', line 33

def line(a,b,c,d)
  #OSX::NSBezierPath.strokeLine({:fromPoint=>OSX::NSPoint.new(a, b),
  #				     :toPoint=>OSX::NSPoint.new(c, d)})
  OSX::NSBezierPath.strokeLineFromPoint(OSX::NSPoint.new(a, b),
	    :toPoint, OSX::NSPoint.new(c, d))
end

#lineWidth(w) ⇒ Object



29
30
31
# File 'lib/sgl/cocoa-draw.rb', line 29

def lineWidth(w)
  OSX::NSBezierPath.setDefaultLineWidth(w)
end

#loadSound(file) ⇒ Object



16
17
18
# File 'lib/sgl/sgl-sound.rb', line 16

def loadSound(file)
  return Bass::Sample.new(file)
end

#mainloopObject

mainloop



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/sgl/cocoa-event.rb', line 143

def mainloop
  starttime = Time.now

  do_setup

  @thread = Thread.start {
	loop {
	  need_display
	  delay

	  if check_runtime_finished(starttime)
 stop
 break
	  end
	}
  }

  run
end

#mainloop_setupObject



210
211
212
# File 'lib/sgl/opengl-event.rb', line 210

def mainloop_setup
  do_setup
end

#make_cur_colorObject

called from cocoa-media Since thie method called from NSFont, this should be public.



39
40
41
# File 'lib/sgl/cocoa-color.rb', line 39

def make_cur_color
  make_color(*@cur_color)
end

#movie(u) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sgl/cocoa-media.rb', line 13

def movie(u)
  if /\Ahttp:\/\// =~ u || /\Artsp:\/\// =~ u
	url = OSX::NSURL.URLWithString_(u)
  else
	url = OSX::NSURL.fileURLWithPath_(u)
  end
  mov = OSX::NSMovie.alloc.initWithURL(url, :byReference, true)
  # Place the movie on the out of screen.
  obj = NSMovieView.alloc.initWithFrame([-100.0, -100.0, 10.0, 10.0])
  obj.setApp(self)
  obj.setMovie(mov)
  obj.showController(false, :adjustingSize, false)
  view = @options[:movie] ? @movview : @bgview
  # This "p" is necessary to show the movie.  I don't know why.
  p [@options[:movie], view]
  # p view			# This does not work.
  # dummy = view.inspect	# This does not work also.
  view.addSubview(obj)
  obj
end

#normal(a, b = nil, c = nil) ⇒ Object



72
73
74
# File 'lib/sgl/opengl-draw.rb', line 72

def normal(a, b = nil, c = nil)
  GL.Normal(a, b, c)
end

#point(a, b, c = nil) ⇒ Object

simple draw



98
99
100
# File 'lib/sgl/opengl-draw.rb', line 98

def point(a,b)
  line(a,b,a,b)
end

#popObject



62
63
64
# File 'lib/sgl/opengl-draw.rb', line 62

def pop
  GL.PopMatrix
end

#process(&b) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
# File 'lib/sgl/opengl-event.rb', line 263

def process(&b)
  block = Proc.new
  @starttime = Time.now
  loop {
	check_event
	block.call
	#yield
	delay
	return if check_runtime_finished(@starttime)
  }
end

#pushObject



58
59
60
# File 'lib/sgl/opengl-draw.rb', line 58

def push
  GL.PushMatrix
end

#rect(a, b, c, d) ⇒ Object



40
41
42
43
# File 'lib/sgl/cocoa-draw.rb', line 40

def rect(a,b,c,d)
  rect = OSX::NSRect.new(*to_xywh(a, b, c, d))
  OSX::NSBezierPath.bezierPathWithRect(rect).fill
end

#resetObject



68
69
70
# File 'lib/sgl/cocoa-draw.rb', line 68

def reset
  OSX::NSAffineTransform.transform.set
end

#rotateX(a) ⇒ Object



81
82
83
# File 'lib/sgl/opengl-draw.rb', line 81

def rotateX(a)
  GL.Rotate(a, 1, 0, 0)
end

#rotateY(a) ⇒ Object



85
86
87
# File 'lib/sgl/opengl-draw.rb', line 85

def rotateY(a)
  GL.Rotate(a, 0, 1, 0)
end

#rotateZ(a) ⇒ Object



50
51
52
53
54
# File 'lib/sgl/cocoa-draw.rb', line 50

def rotateZ(deg)
  af = OSX::NSAffineTransform.transform
  af.rotateByDegrees(deg)
  af.concat
end

#runObject



31
32
33
34
# File 'lib/sgl/cocoa-app.rb', line 31

def run
  OSX.NSApp.run
  OSX::NSEvent.stopPeriodicEvents
end

#scale(a) ⇒ Object



62
63
64
65
66
# File 'lib/sgl/cocoa-draw.rb', line 62

def scale(x, y=nil)
  af = OSX::NSAffineTransform.transform
  y ? af.scaleXBy(x, :yBy, y) : af.scaleBy(x)
  af.concat
end

#set_display(&b) ⇒ Object

display



107
108
109
110
# File 'lib/sgl/opengl-event.rb', line 107

def set_display(&b)
  return unless block_given?
  @block[:display] = Proc.new
end

#set_display0(&b) ⇒ Object



112
113
114
115
# File 'lib/sgl/opengl-event.rb', line 112

def set_display0(&b)
  return unless block_given?
  @block[:display0] = Proc.new
end

#set_display_overlay(&b) ⇒ Object



91
92
93
94
# File 'lib/sgl/cocoa-event.rb', line 91

def set_display_overlay(&b)
  return unless block_given?
  @block[:display_overlay] = Proc.new
end

#set_keydown(&b) ⇒ Object

key events



201
202
203
204
# File 'lib/sgl/cocoa-event.rb', line 201

def set_keydown(&b)
  return unless block_given?
  @block[:keydown] = Proc.new
end

#set_keyup(&b) ⇒ Object



211
212
213
214
# File 'lib/sgl/cocoa-event.rb', line 211

def set_keyup(&b)
  return unless block_given?
  @block[:keyup] = Proc.new
end

#set_mousedown(&b) ⇒ Object

mouse events



180
181
182
183
# File 'lib/sgl/cocoa-event.rb', line 180

def set_mousedown(&b)
  return unless block_given?
  @block[:mousedown] = Proc.new
end

#set_mousedown0(&b) ⇒ Object

mouse events for fullscreen



170
171
172
173
# File 'lib/sgl/opengl-event.rb', line 170

def set_mousedown0(&b)
  return unless block_given?
  @block[:mousedown0] = Proc.new
end

#set_mouseup(&b) ⇒ Object



190
191
192
193
# File 'lib/sgl/cocoa-event.rb', line 190

def set_mouseup(&b)
  return unless block_given?
  @block[:mouseup] = Proc.new
end

#set_setup(&b) ⇒ Object

setup



53
54
55
56
# File 'lib/sgl/cocoa-event.rb', line 53

def set_setup(&b)
  return unless block_given?
  @block[:setup] = Proc.new
end

#sound(file) ⇒ Object



44
45
46
47
48
# File 'lib/sgl/cocoa-media.rb', line 44

def sound(file)
  url = OSX::NSURL.fileURLWithPath_(file)
  snd = NSSound.alloc.initWithContentsOfURL(url, :byReference, true)
  snd
end

#stopObject



36
37
38
39
40
# File 'lib/sgl/cocoa-app.rb', line 36

def stop
  close_window
  OSX.NSApp.stop(nil)
  OSX::NSEvent.startPeriodicEventsAfterDelay(0.01, :withPeriod, 0.01)
end

#stopSoundObject



20
21
22
# File 'lib/sgl/sgl-sound.rb', line 20

def stopSound
  Bass::BassLib.instance.stop_all
end

#translate(a, b, c = 0) ⇒ Object

matrix manipulation



77
78
79
80
81
# File 'lib/sgl/opengl-draw.rb', line 77

def translate(x, y)
  af = OSX::NSAffineTransform.transform
  af.translateXBy(x, :yBy, y)
  af.concat
end

#triangle(a, b, c, d, e, f) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/sgl/opengl-draw.rb', line 128

def triangle(a, b, c, d, e, f)
  GL.Begin(GL::TRIANGLES)
  GL.Vertex(a, b)
  GL.Vertex(c, d)
  GL.Vertex(e, f)
  GL.End
end

#useCulling(a = true) ⇒ Object



141
142
143
144
# File 'lib/sgl/opengl-window.rb', line 141

def useCulling(a = true)
  @options[:culling] = a
  @options[:culling] ? GL.Enable(GL::CULL_FACE) : GL.Disable(GL::CULL_FACE)
end

#useCursor(bmpfile) ⇒ Object



152
153
154
# File 'lib/sgl/opengl-window.rb', line 152

def useCursor(bmpfile)
  @options[:cursor] = bmpfile
end

#useDelay(sec) ⇒ Object



156
157
158
# File 'lib/sgl/opengl-window.rb', line 156

def useDelay(sec)
  @options[:delaytime] = sec
end

#useDepth(a = true) ⇒ Object



130
131
132
133
# File 'lib/sgl/opengl-window.rb', line 130

def useDepth(a = true)
  @options[:depth] = a
  @options[:depth] ? GL.Enable(GL::DEPTH_TEST) : GL.Disable(GL::DEPTH_TEST)
end

#useFov(f = 45) ⇒ Object

world control methods



126
127
128
# File 'lib/sgl/opengl-window.rb', line 126

def useFov(f = 45)
  @options[:fov] = f
end

#useFramerate(f) ⇒ Object



160
161
162
# File 'lib/sgl/opengl-window.rb', line 160

def useFramerate(f)
  @options[:framerate] = f
end

#useFullscreen(w = DEFAULT_FULLSCREEN_WIDTH, h = DEFAULT_FULLSCREEN_HEIGHT) ⇒ Object



146
147
148
149
150
# File 'lib/sgl/opengl-window.rb', line 146

def useFullscreen(w=DEFAULT_FULLSCREEN_WIDTH, h=DEFAULT_FULLSCREEN_HEIGHT)
  if @options[:fullscreen].nil?
    @options[:fullscreen] = (w.nil? || h.nil?) ? nil : [w, h]
  end
end

#useMidiObject



10
11
12
13
# File 'lib/sgl/opengl-modules.rb', line 10

def useMidi
  require "sgl/sgl-midi"
  $__midi__ = SGLMidi.new
end

#useMidiIn(num = -1)) ⇒ Object



15
16
17
18
19
20
# File 'lib/sgl/opengl-modules.rb', line 15

def useMidiIn(num = -1)
  require "sgl/sgl-midiin"
  printMidiDeviceNames
  openMidiIn(num)
  startMidiInThread
end

#useRuntime(r) ⇒ Object



164
165
166
# File 'lib/sgl/opengl-window.rb', line 164

def useRuntime(r)
  @options[:runtime] = r
end

#useSmooth(a = true) ⇒ Object



135
136
137
138
139
# File 'lib/sgl/opengl-window.rb', line 135

def useSmooth(a = true)
  @options[:smooth] = a
  @options[:smooth] ?
  GL.Enable(GL::LINE_SMOOTH) : GL.Disable(GL::LINE_SMOOTH)
end

#useSoundObject



12
13
14
# File 'lib/sgl/sgl-sound.rb', line 12

def useSound
  bass = Bass::BassLib.instance
end

#vertex(a, b = nil, c = nil, d = nil) ⇒ Object



66
67
68
69
70
# File 'lib/sgl/opengl-draw.rb', line 66

def vertex(a, b = nil, c = nil, d = nil)
  GL.Vertex(a, b, c, d) if d
  GL.Vertex(a, b, c) if c
  GL.Vertex(a, b)
end

#waitObject



254
255
256
257
258
259
260
261
# File 'lib/sgl/opengl-event.rb', line 254

def wait
  #SGL.flip if !$__v__.flipped
  loop {
	check_event
	delay
	return if check_runtime_finished(@starttime)
  }
end

#window(*a) ⇒ Object

create window



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/sgl/cocoa-window.rb', line 32

def window(*a)
  return if @win

  @options.update(a.pop) if a.last.is_a? Hash

  if defined?($windowShadow)
	@options[:shadow] = $windowShadow == 1
  end

  if defined?($windowBorder)
	@options[:border] = $windowBorder == 1
  end

  if @block[:display_overlay]
	@options[:overlay] = true
  end

  # get window size
  case a.length
  when 2
	w, h = a
  when 4
	raise "not implemented" # x1, y1, x2, y3 = a
  else
	raise "please specify width and height"
  end
  @width, @height = w, h

  cocoa_create_window(w, h)
end

#window_should_closeObject

Cocoa callback methods



153
154
155
# File 'lib/sgl/cocoa-window.rb', line 153

def window_should_close
  stop
end