Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / recording within a recording
- - By Traddles Date 2012-11-26 06:16
Just spent a while debugging something before I was finally able to figure out the issue.

Apparently the image that is generated by Window#record is not a "true" gosu image?

e.g.
img1 = Gosu::Image.new("some_file.gif")
img2 = window.record(100, 100) { img1.draw(0, 0, 0) }
window.record(100, 100) do
  img1.draw(0,0,0)  #=> is fine and works like a charm
  img2.draw(0,0,0)  #=> generates an exception: "Custom code cannot be recorded into a macro (RuntimeError)"
end

Is there a reason for this or is this a bug?
Parent - By jlnr (dev) Date 2012-11-26 08:38
The result of record() is not a "true" Gosu::Image in that it is not rendering to a texture; it is recording the contents of a block to a vertex array.

What you are seeing is not a bug, it is a missing feature. Internally, the Image returned by record uses a custom OpenGL block to render itself, which is what the error message is trying to say. Since Gosu cannot know what a custom GL block is doing, it cannot capture the output into a vertex array (though it could capture it to a texture - if that is what record were doing :) ).

I have two To-Do items that would help you, one is to implement render-to-texture. The other is to simply expand the inner vertex array into the outer array for the special case where a vertex array is drawn inside a record block.

They're super-low-priority compared to everything else now, but I enjoy hacking on the record code a lot, so maybe I can sneak it into a break some time.
Up Topic Gosu / Gosu Exchange / recording within a recording

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill