obj2d: use "immutable"; generate logo width/height
This commit is contained in:
parent
37ecb3a30b
commit
8dc61686a9
9
obj2d.rb
9
obj2d.rb
@ -11,20 +11,20 @@ struct char_desc_t
|
|||||||
float c_y;
|
float c_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
float[<%= vertices.size * 2 %>] vertices = [
|
immutable float[<%= vertices.size * 2 %>] vertices = [
|
||||||
<% vertices.flatten.each do |coord| -%>
|
<% vertices.flatten.each do |coord| -%>
|
||||||
<%= coord %>,
|
<%= coord %>,
|
||||||
<% end -%>
|
<% end -%>
|
||||||
];
|
];
|
||||||
|
|
||||||
ushort[<%= indices.size %>] indices = [
|
immutable ushort[<%= indices.size %>] indices = [
|
||||||
<% indices.each do |index| -%>
|
<% indices.each do |index| -%>
|
||||||
<%= index %>,
|
<%= index %>,
|
||||||
<% end -%>
|
<% end -%>
|
||||||
];
|
];
|
||||||
|
|
||||||
<% object_ranges.each_pair do |obj_name, obj_ranges| -%>
|
<% object_ranges.each_pair do |obj_name, obj_ranges| -%>
|
||||||
char_desc_t[] <%= obj_name %> = [
|
immutable char_desc_t[] <%= obj_name %> = [
|
||||||
<% obj_ranges.each do |obj_range| -%>
|
<% obj_ranges.each do |obj_range| -%>
|
||||||
<% obj_verts = indices[*obj_range].map {|i| vertices[i]} -%>
|
<% obj_verts = indices[*obj_range].map {|i| vertices[i]} -%>
|
||||||
<% c_x = (obj_verts.map {|v| v[0]}.min + obj_verts.map {|v| v[0]}.max) / 2.0 -%>
|
<% c_x = (obj_verts.map {|v| v[0]}.min + obj_verts.map {|v| v[0]}.max) / 2.0 -%>
|
||||||
@ -33,6 +33,9 @@ char_desc_t[] <%= obj_name %> = [
|
|||||||
<% end -%>
|
<% end -%>
|
||||||
];
|
];
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
immutable float width = <%= vertices.map {|v| v[0]}.max - vertices.map {|v| v[0]}.min %>;
|
||||||
|
immutable float height = <%= vertices.map {|v| v[1]}.max - vertices.map {|v| v[1]}.min %>;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
def main(obj_fname, d_fname)
|
def main(obj_fname, d_fname)
|
||||||
|
@ -12,14 +12,17 @@ immutable enum int WIRE = 1;
|
|||||||
immutable enum int GENTEX = 0;
|
immutable enum int GENTEX = 0;
|
||||||
immutable enum int CORPORATION = 1;
|
immutable enum int CORPORATION = 1;
|
||||||
|
|
||||||
logoobj.char_desc_t [][2][2] characters;
|
immutable float WIDTH = logoobj.width;
|
||||||
|
immutable float HEIGHT = logoobj.height;
|
||||||
|
|
||||||
|
immutable logoobj.char_desc_t [][2][2] characters = [[logoobj.fg, logoobj.fc],
|
||||||
|
[logoobj.lg, logoobj.lc]];
|
||||||
|
|
||||||
/* Indexed by: face/wire, word, character */
|
/* Indexed by: face/wire, word, character */
|
||||||
VAO[][2][2] object_vaos;
|
VAO[][2][2] object_vaos;
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
characters = [[logoobj.fg, logoobj.fc],
|
|
||||||
[logoobj.lg, logoobj.lc]];
|
|
||||||
Buffer vertices_buffer = new Buffer(logoobj.vertices);
|
Buffer vertices_buffer = new Buffer(logoobj.vertices);
|
||||||
for (int draw_type = FACE; draw_type <= WIRE; draw_type++)
|
for (int draw_type = FACE; draw_type <= WIRE; draw_type++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user