src/mesh.c

changeset 175
e5544920377e
parent 145
a3231310d66d
equal deleted inserted replaced
174:0009b982bc7d 175:e5544920377e
107 args.size.y = ASC_NONZERO_OR(1.f, args.size.y); 107 args.size.y = ASC_NONZERO_OR(1.f, args.size.y);
108 args.uv_scale.x = ASC_NONZERO_OR(1.f, args.uv_scale.x); 108 args.uv_scale.x = ASC_NONZERO_OR(1.f, args.uv_scale.x);
109 args.uv_scale.y = ASC_NONZERO_OR(1.f, args.uv_scale.y); 109 args.uv_scale.y = ASC_NONZERO_OR(1.f, args.uv_scale.y);
110 110
111 // bottom left 111 // bottom left
112 data[0].pos = asc_vec2f_new(0.0f, 0.0f); 112 data[0].pos = ASC_VEC2F(0.0f, 0.0f);
113 data[0].uv = asc_vec2f_new(args.uv_offset.x, args.uv_offset.y); 113 data[0].uv = ASC_VEC2F(args.uv_offset.x, args.uv_offset.y);
114 // top left 114 // top left
115 data[1].pos = asc_vec2f_new(0.0f, args.size.y); 115 data[1].pos = ASC_VEC2F(0.0f, args.size.y);
116 data[1].uv = asc_vec2f_new(args.uv_offset.x, args.uv_offset.y + args.uv_scale.y); 116 data[1].uv = ASC_VEC2F(args.uv_offset.x, args.uv_offset.y + args.uv_scale.y);
117 // bottom right 117 // bottom right
118 data[2].pos = asc_vec2f_new(args.size.x, 0.0f); 118 data[2].pos = ASC_VEC2F(args.size.x, 0.0f);
119 data[2].uv = asc_vec2f_new(args.uv_offset.x + args.uv_scale.x, args.uv_offset.y); 119 data[2].uv = ASC_VEC2F(args.uv_offset.x + args.uv_scale.x, args.uv_offset.y);
120 // top right 120 // top right
121 data[3].pos = asc_vec2f_new(args.size.x, args.size.y); 121 data[3].pos = ASC_VEC2F(args.size.x, args.size.y);
122 data[3].uv = asc_vec2f_new(args.uv_offset.x + args.uv_scale.x, args.uv_offset.y + args.uv_scale.y); 122 data[3].uv = ASC_VEC2F(args.uv_offset.x + args.uv_scale.x, args.uv_offset.y + args.uv_scale.y);
123 glBindBuffer(GL_ARRAY_BUFFER, mesh->vbo); 123 glBindBuffer(GL_ARRAY_BUFFER, mesh->vbo);
124 glBufferData(GL_ARRAY_BUFFER, mesh->vtx_data_size, mesh->vtx_data, GL_STATIC_DRAW); 124 glBufferData(GL_ARRAY_BUFFER, mesh->vtx_data_size, mesh->vtx_data, GL_STATIC_DRAW);
125 // TODO: this should not be repeated for every adjustment - but it will be moved to the batch renderer anyway 125 // TODO: this should not be repeated for every adjustment - but it will be moved to the batch renderer anyway
126 glBindVertexArray(mesh->vao); 126 glBindVertexArray(mesh->vao);
127 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(asc_vertex2d), (void*)offsetof(asc_vertex2d, pos)); 127 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(asc_vertex2d), (void*)offsetof(asc_vertex2d, pos));

mercurial