ECS rendering
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "camera.h"
|
||||
#include "display/display.h"
|
||||
#include "assert/assert.h"
|
||||
#include "scene/node.h"
|
||||
|
||||
camera_t CAMERA_DATA[ECS_ENTITY_COUNT_MAX] = { 0 };
|
||||
ecscomponent_t CAMERA_COMPONENT = ecsComponentInit(
|
||||
@@ -24,8 +25,8 @@ void cameraEntityAdded(const ecsid_t id) {
|
||||
if(CAMERA_MAIN == -1) CAMERA_MAIN = id;
|
||||
|
||||
camera_t *cam = cameraGet(id);
|
||||
cam->type = CAMERA_TYPE_ORTHOGRAPHIC;
|
||||
cam->perspective.fov = glm_rad(75.0f);
|
||||
cam->type = CAMERA_TYPE_PERSPECTIVE;
|
||||
cam->perspective.fov = glm_rad(90.0f);
|
||||
cam->nearClip = 0.1f;
|
||||
cam->farClip = 1000.0f;
|
||||
cam->clearColor = COLOR_CORNFLOWER_BLUE;
|
||||
@@ -36,7 +37,9 @@ void cameraPush(const ecsid_t id) {
|
||||
|
||||
camera_t *cam = cameraGet(id);
|
||||
|
||||
mat4 projection;
|
||||
mat4 projection, view;
|
||||
nodeMatrixGet(id, view);
|
||||
|
||||
switch(cam->type) {
|
||||
case CAMERA_TYPE_ORTHOGRAPHIC:
|
||||
glm_ortho(
|
||||
@@ -61,10 +64,13 @@ void cameraPush(const ecsid_t id) {
|
||||
}
|
||||
|
||||
#if DUSK_DISPLAY_SDL2
|
||||
mat4 pv;
|
||||
glm_mat4_mul(projection, view, pv);
|
||||
|
||||
glPushMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glLoadMatrixf((const GLfloat*)projection);
|
||||
glLoadMatrixf((const GLfloat*)pv);
|
||||
|
||||
glClearColor(
|
||||
cam->clearColor.r / 255.0f,
|
||||
@@ -73,6 +79,9 @@ void cameraPush(const ecsid_t id) {
|
||||
cam->clearColor.a / 255.0f
|
||||
);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user