| 28 #include "ascension/scene.h" |
28 #include "ascension/scene.h" |
| 29 |
29 |
| 30 #include "ascension/context.h" |
30 #include "ascension/context.h" |
| 31 #include "ascension/utils.h" |
31 #include "ascension/utils.h" |
| 32 |
32 |
| |
33 #include "ascension/2d.h" |
| |
34 |
| 33 #include <cx/linked_list.h> |
35 #include <cx/linked_list.h> |
| 34 #include <cx/array_list.h> |
36 #include <cx/array_list.h> |
| 35 #include <cx/tree.h> |
37 #include <cx/tree.h> |
| 36 #include <cx/utils.h> |
38 #include <cx/utils.h> |
| 37 |
39 |
| 38 #include "ascension/shader.h" |
|
| 39 #include <GL/glew.h> |
40 #include <GL/glew.h> |
| 40 |
41 |
| 41 #include <assert.h> |
42 #include <assert.h> |
| 42 |
43 |
| 43 static CxTreeIterator asc_scene_node_iterator( |
44 static CxTreeIterator asc_scene_node_iterator( |
| 54 static CxTreeVisitor asc_scene_node_visitor(AscSceneNode *node) { |
55 static CxTreeVisitor asc_scene_node_visitor(AscSceneNode *node) { |
| 55 return cx_tree_visitor(node, |
56 return cx_tree_visitor(node, |
| 56 offsetof(AscSceneNode, children), |
57 offsetof(AscSceneNode, children), |
| 57 offsetof(AscSceneNode, next) |
58 offsetof(AscSceneNode, next) |
| 58 ); |
59 ); |
| 59 } |
|
| 60 |
|
| 61 static void asc_sprite_draw(AscSprite const *node) { |
|
| 62 // Obtain shader |
|
| 63 AscShaderSprite *shader = ASC_SHADER_SPRITE; |
|
| 64 |
|
| 65 // Upload model matrix |
|
| 66 glUniformMatrix4fv(shader->program.model, 1, |
|
| 67 GL_FALSE, node->data.world_transform); |
|
| 68 |
|
| 69 // Bind texture |
|
| 70 asc_texture_bind(&node->tex, shader->tex, 0); |
|
| 71 |
|
| 72 // Apply depth |
|
| 73 glUniform1f(shader->depth, (float)(node->data.depth)); |
|
| 74 |
|
| 75 // Draw mesh |
|
| 76 asc_primitives_draw_plane(); |
|
| 77 } |
60 } |
| 78 |
61 |
| 79 void asc_scene_draw(AscSceneNode *root, asc_recti viewport, AscCamera *camera) { |
62 void asc_scene_draw(AscSceneNode *root, asc_recti viewport, AscCamera *camera) { |
| 80 // create render groups |
63 // create render groups |
| 81 CxList *render_group[ASC_RENDER_GROUP_COUNT]; |
64 CxList *render_group[ASC_RENDER_GROUP_COUNT]; |