I’m trying to put together a quick test of buffered animation with
WxRuby, but I’m encountering a fair amount of trouble… I’m drawing
to a Wx::Bitmap first, then using Wx::DC#draw_bitmap to copy it to a
Wx::Window. But I get the following error:
draw': uninitialized constant Wxruby2::Bitmap::MemoryDC (NameError) from dc_draw_line.rb:30:inon_init’
Is MemoryDC not implemented yet in WxRuby 1.9.1? It’s in the
documentation, but I know large chunks of that are auto-generated, so
I don’t totally trust it. Maybe I’m doing something wrong, though?
My code is below. Any advice would be most appreciated!
gems_loaded = false
if gems_loaded == false
gems_loaded = true
class MyApp < Wx::App
#Create the top window.
frame = Wx::Frame.new(nil, :size => [300, 300])
#Create a panel within it.
view = Wx::Window.new(frame)
buffer = Wx::Bitmap.new(300, 300) @x = 0 #Set up a handler for paint events. view.evt_paint do |event| #Wx::Window#paint takes a block. #This will later be called with a device context to paint on. view.paint do |dc| buffer.draw do |buffer_dc| buffer_dc.clear buffer_dc.pen = Wx::Pen.new(Wx::Colour.new(128, 128, 128), 5) buffer_dc.draw_line(@x, 0, @x + 100, 100) end dc.draw_bitmap(buffer, 0, 0, false) end @x += 1 end #Show the window. frame.show return true
app = MyApp.new