On Wed, 2008-09-24 at 21:52 +1000, Steve Smith wrote:
> Hmm, it looks like there's something else at work here.  I've tried a
> threaded version and I'm still seeing the jumping; if I comment out
> the thread-start it's fine.  Code below; can anyone see what I'm doing
> wrong here?

Perhaps you could try splitting the texture up into multiple smaller
textures and move them all across the screen. Then you could delete the
small textures as they drop off the screen and add new ones as gaps
appear.

Drawing to the large texture in small chunks will probably just make it
slower because after you destroy the cairo context for every chunk
clutter will upload the whole texture data to GL. This is unfortunatly
quite an ineffecient process because Clutter has to un-premultiply and
reorder the data.

I don't know enough Python to make an example for that, but here is a
Ruby version I mocked up on the train this morning:

require 'clutter'
require 'clutter_cairo'

PART_WIDTH = 128

def make_part(last_pos)
  stage_height = Clutter::Stage.get_default.height

  tex = Clutter::Cairo.new(PART_WIDTH, stage_height)
  
  tex.create do |cr|
    cr.set_source_rgb(0, 1, 0)

    cr.move_to(0, last_pos)

    10.times do |i|
      last_pos += rand(100) - 50
      if last_pos < 0
        last_pos = 0
      elsif last_pos >= stage_height
        last_pos = stage_height - 1
      end

      cr.line_to((i + 1) * PART_WIDTH / 10, last_pos)
    end

    cr.stroke
  end

  [ last_pos, tex ]
end

Clutter::init

stage = Clutter::Stage.get_default
stage.color = Clutter::Color.new(0, 0, 0, 255)

stage.show

(last_pos, part) = make_part(stage.height / 2)
part.x = stage.width
parts = [ part ]
stage << part

tl = Clutter::Timeline.new(1000)
tl.loop = true
tl.start

tl.signal_connect('new-frame') do |tl, frame_num|
  # Move all of the actors to the left by the timeline delta
  parts.each { |part| part.x -= tl.delta }
  
  # Add new actors until the screen is covered
  while parts[-1].x + PART_WIDTH < stage.width
    (last_pos, part) = make_part(last_pos)
    part.x = parts[-1].x + PART_WIDTH
    parts << part
    stage << part
  end

  # Delete any actors that are off the left edge of the screen
  to_go_end = 0
  while to_go_end < parts.size && parts[to_go_end].x <= -PART_WIDTH
    to_go_end += 1
  end

  parts[0...to_go_end].each { |x| x.destroy }
  parts.slice!(0...to_go_end)
end

Clutter::main


-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to