/****************************************************************************** * vertex transform */ static void tnl_vertex_transform (void) { const GLfloat *mvp = get_mvp(); /* clip coords: the data pointer _CAN_ be indexed! */ if (tnl_extra_flags & TNL_VERTEXW_BIT) { matrix_mul_vec4_batch(tnl_vb.clip, mvp, (const GLfloat4 *)tnl_vb.attr[TNL_VERTEX].data, tnl_vb.len); } else { matrix_mul_vec3_batch(tnl_vb.clip, mvp, (const GLfloat4 *)tnl_vb.attr[TNL_VERTEX].data, tnl_vb.len); } if (tnl_render_state & D_NEED_VEYE) { const GLfloat *mv = ctx_mx_modelview_top->mat; if (tnl_render_state & D_NEED_VEYN) { tnl_veyn_func[(tnl_extra_flags & TNL_VERTEXW_BIT) ? 1 : 0](mv); } else { if (tnl_extra_flags & TNL_VERTEXW_BIT) { matrix_mul_vec4_batch(tnl_vb.veye, mv, (const GLfloat4 *)tnl_vb.attr[TNL_VERTEX].data, tnl_vb.len); } else { matrix_mul_vec3_batch(tnl_vb.veye, mv, (const GLfloat4 *)tnl_vb.attr[TNL_VERTEX].data, tnl_vb.len); } } } if (tnl_render_state & D_NEED_NEYE) { tnl_calc_neye_tab[ctx_normalize](); } if (ctx_hint_clip_volume == GL_FASTEST) { tnl_clipmask_tab[V_NOCLIP](); } else if (ctx_userclip) { tnl_clipmask_tab[V_USERCLIP](); } else { tnl_clipmask_tab[0](); } }
void SpriteRender::render_rectangle(fmat4* transform, float width, float height, fvec3 texture_corners[4]) { fmat4 view; get_mvp(&view); view = *transform * view; // add to the transformation matrix a scaling factor for the radius view = glm::scale(view, fvec3(0, height, width)); OGLAttr::current_shader->set_transform_matrix(&view); int num_triangles = 6; GLfloat rectangle_vertex_data[6][3] = { {0, -1, -1}, {0, -1, 1}, {0, 1, -1}, {0, 1, -1}, {0, -1, 1}, {0, 1, 1}, }; fvec3 texture_binds[6]; texture_binds[0] = texture_corners[0]; texture_binds[1] = texture_corners[1]; texture_binds[2] = texture_corners[2]; texture_binds[3] = texture_corners[2]; texture_binds[4] = texture_corners[1]; texture_binds[5] = texture_corners[3]; glBindBuffer(GL_ARRAY_BUFFER, OGLAttr::common_vertex_vbo); glBufferData(GL_ARRAY_BUFFER, sizeof rectangle_vertex_data, rectangle_vertex_data, GL_DYNAMIC_DRAW); OGLAttr::current_shader->set_coord_attribute(GL_FLOAT); glBindBuffer(GL_ARRAY_BUFFER, OGLAttr::common_texture_vbo); glBufferData(GL_ARRAY_BUFFER, sizeof texture_binds, &(texture_binds[0]), GL_DYNAMIC_DRAW); OGLAttr::current_shader->set_texture_coord_attribute(GL_FLOAT); glDrawArrays(GL_TRIANGLES, 0, num_triangles); }