28 lines
1.1 KiB
C++
28 lines
1.1 KiB
C++
#include <deerith/world.h>
|
|
#include <deerith/world/entity.h>
|
|
|
|
#include <deerith/graphics/primitive.h>
|
|
|
|
void deerith::render_world()
|
|
{
|
|
define_primitive_viewspace(glm::vec2(-10, -10), glm::vec2(10, 10));
|
|
|
|
auto entities_view = get_entity_registry().view<entity_sync_coordinates_t>(entt::exclude<entity_sync_client_position_t>);
|
|
for (auto [entity, sync_coords] : entities_view.each())
|
|
{
|
|
glm::vec2 chords;
|
|
if (sync_coords.position.read_synced(chords))
|
|
{
|
|
define_primitive_color(glm::vec4(1, 1, 1, 1));
|
|
draw_primitive_rectangle(chords - glm::vec2(0.5f, 0.5f), chords + glm::vec2(0.5f, 0.5f));
|
|
}
|
|
}
|
|
|
|
// we should expect only one registry
|
|
auto self_view = get_entity_registry().view<entity_sync_coordinates_t, entity_sync_client_position_t>();
|
|
for (auto [entity, sync_coords, client_sync_coords] : self_view.each())
|
|
{
|
|
define_primitive_color(glm::vec4(1, 0.5f, 0.6f, 1));
|
|
draw_primitive_rectangle(client_sync_coords.position.read_value() - glm::vec2(0.5f, 0.5f), client_sync_coords.position.read_value() + glm::vec2(0.5f, 0.5f));
|
|
}
|
|
} |