obj2d: output vertices and objects

This commit is contained in:
Josh Holtrop 2013-11-17 15:42:39 -05:00
parent 364702d70c
commit 38aeeba973

View File

@ -3,10 +3,15 @@
require "erb" require "erb"
TEMPLATE = <<EOF TEMPLATE = <<EOF
int foo() float[2][] vertices = [
{ <%= vertices.map {|v| v[0, 2].inspect}.join(",\n ") %>
return 42; ];
} <% objects.each_pair do |obj_name, obj_array| %>
int[][][] <%= obj_name %> = [
<%= obj_array.map {|oa| "[" + oa.map {|o| o.inspect}.join(",\n ") + "]"}.join(",\n ") %>
];
<% end %>
EOF EOF
def main(obj_fname, d_fname) def main(obj_fname, d_fname)
@ -30,7 +35,7 @@ def main(obj_fname, d_fname)
end end
end end
File.open(d_fname, "w") do |fh| File.open(d_fname, "w") do |fh|
fh.puts ERB.new(TEMPLATE, nil, "<>").result fh.puts ERB.new(TEMPLATE, nil, "<>").result(binding)
end end
end end