81 } |
81 } |
82 |
82 |
83 void asc_sprite_draw(const AscCamera *camera, const AscSceneNode *node) { |
83 void asc_sprite_draw(const AscCamera *camera, const AscSceneNode *node) { |
84 asc_cptr_cast(AscSprite, sprite, node); |
84 asc_cptr_cast(AscSprite, sprite, node); |
85 |
85 |
|
86 const int flags = asc_texture_is_uv_normalized(sprite->texture) ? 0 : 1; |
|
87 |
86 // Activate shader |
88 // Activate shader |
87 // TODO: scene should know which shader we are going to activate s.t. it can pre-sort nodes |
89 // TODO: scene should know which shader we are going to activate s.t. it can pre-sort nodes |
88 const AscShaderProgram *shader = |
90 const AscShaderProgram *shader = asc_shader_lookup_or_create( |
89 asc_texture_is_uv_normalized(sprite->texture) |
91 ASC_SHADER_SPRITE(flags), |
90 ? asc_shader_lookup_or_create(ASC_SHADER_SPRITE_UV, asc_sprite_shader_create, 0) |
92 asc_sprite_shader_create, flags |
91 : asc_shader_lookup_or_create(ASC_SHADER_SPRITE_RECT, asc_sprite_shader_create, 1); |
93 ); |
92 if (asc_shader_use(shader, camera)) return; |
94 if (asc_shader_use(shader, camera)) return; |
93 asc_cptr_cast(AscSpriteShader, sprite_shader, shader); |
95 asc_cptr_cast(AscSpriteShader, sprite_shader, shader); |
94 |
96 |
95 // Upload model matrix |
97 // Upload model matrix |
96 asc_shader_upload_model_matrix(shader, node); |
98 asc_shader_upload_model_matrix(shader, node); |