jashkenas / ruby-processing

Code as Art, Art as Code. Processing and Ruby are meant for each other.
http://github.com/jashkenas/ruby-processing/wikis
Other
1.28k stars 94 forks source link

`rp5 watch` does not work #58

Closed nocksock closed 11 years ago

nocksock commented 11 years ago

Running rp5 watch 3dtest.rb starts the sketch but when reloading it does not start again and I get warnings for constants.

I'm just starting out with processing-ruby, so might've done something wrong.

$ rp5 watch 3dtest.rb 
reloading sketch...
./3dtest.rb:1 warning: already initialized constant X_COUNT
./3dtest.rb:2 warning: already initialized constant Y_COUNT

The sketch is fairly simple:

X_COUNT = 50
Y_COUNT = 50

class WaveTest < Processing::App
  load_library :opengl
  include_package "processing.opengl"

  def setup
    size 1280, 768, OPENGL
    color_mode HSB, 360, 100, 100, 100
    no_stroke
    @frame = 0
  end

  def draw
    lights

    rotate_y radians(10)
    rotate_z radians(50)

    @frame+=0.1
    background 255
    scale 10

    (0..Y_COUNT).each do |y|
      begin_shape TRIANGLE_STRIP

      (0...X_COUNT).each do |x|
        z = sin(x-@frame)
        vertex x, y, z
        vertex x, y+1, z
      end

      fill 198, 100, 50, 50
      stroke 198, 0, 0, 10
      end_shape
    end
  end
end
monkstone commented 11 years ago

Try putting your constants inside your class, better still change the code to be a "bare" sketch (delete line ~four and the last end) 'cos that's what I'm making default for next release (Jruby-1.7.2, processing-2.0). Actually I just tried such a modified sketch with the development version, and may'be including constants is not such a good idea. However I get a new issue segfault stroke path too long, some triangles wont get drawn (processing-2.0 beta version) so perhaps your sketch is a bit ambitious for the watch mode. I've only really used "watch" mode for very simple sketches, so I expect there are some limitations....

nocksock commented 11 years ago

Ambitious? :) It was meant to be simple - a simple test to use opengl in ruby-processing. Also I noticed that it wont start if I use the app that's generated by rp5 app 3dtest.rb.

monkstone commented 11 years ago

Whats wrong with run?

nocksock commented 11 years ago

run takes a few more seconds to start - I was hoping that I could fasten my workflow using rp5 watch not having to switch the console and type !!.

monkstone commented 11 years ago

Yeah it would be nice, but in practice I don't think ruby-processing is up to it (apart from simple sketches). Interestingly fjennet is working on a live coding for regular processing. Regarding exported app not working I think that might have been reported before could be a path thing, I'm a 100% linux user, and working with the development version so it is not easy for me to check. If you just want to experiment by changing variable values you should try the control panel (it is very easy to setup).