pre-cache shader matrices
This commit is contained in:
+26
-19
@@ -58,6 +58,23 @@ errorret_t sceneUpdate(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
errorret_t sceneRender(void) {
|
errorret_t sceneRender(void) {
|
||||||
|
// Setup screen matrices for 3D rendering.
|
||||||
|
glm_mat4_identity(SCENE.screenIdentity);
|
||||||
|
|
||||||
|
glm_ortho(
|
||||||
|
0.0f, (float_t)(SCREEN.width / SCREEN.scaleUi),
|
||||||
|
(float_t)(SCREEN.height / SCREEN.scaleUi), 0.0f,
|
||||||
|
0.1f, 100.0f,
|
||||||
|
SCENE.screenProj
|
||||||
|
);
|
||||||
|
|
||||||
|
glm_lookat(
|
||||||
|
(vec3){ 0.0f, 0.0f, 1.0f },
|
||||||
|
(vec3){ 0.0f, 0.0f, 0.0f },
|
||||||
|
(vec3){ 0.0f, 1.0f, 0.0f },
|
||||||
|
SCENE.screenView
|
||||||
|
);
|
||||||
|
|
||||||
// Scene rendering
|
// Scene rendering
|
||||||
if(
|
if(
|
||||||
SCENE.current != SCENE_TYPE_NULL &&
|
SCENE.current != SCENE_TYPE_NULL &&
|
||||||
@@ -67,26 +84,16 @@ errorret_t sceneRender(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UI Rendering
|
// UI Rendering
|
||||||
mat4 proj, view, ident;
|
|
||||||
glm_mat4_identity(ident);
|
|
||||||
errorChain(shaderBind(&SHADER_UNLIT));
|
errorChain(shaderBind(&SHADER_UNLIT));
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, ident));
|
errorChain(shaderSetMatrix(
|
||||||
|
&SHADER_UNLIT, SHADER_UNLIT_MODEL, SCENE.screenIdentity
|
||||||
glm_ortho(
|
));
|
||||||
0.0f, (float_t)(SCREEN.width / SCREEN.scaleUi),
|
errorChain(shaderSetMatrix(
|
||||||
(float_t)(SCREEN.height / SCREEN.scaleUi), 0.0f,
|
&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, SCENE.screenProj
|
||||||
0.1f, 100.0f,
|
));
|
||||||
proj
|
errorChain(shaderSetMatrix(
|
||||||
);
|
&SHADER_UNLIT, SHADER_UNLIT_VIEW, SCENE.screenView
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj));
|
));
|
||||||
|
|
||||||
glm_lookat(
|
|
||||||
(vec3){ 0.0f, 0.0f, 1.0f },
|
|
||||||
(vec3){ 0.0f, 0.0f, 0.0f },
|
|
||||||
(vec3){ 0.0f, 1.0f, 0.0f },
|
|
||||||
view
|
|
||||||
);
|
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, view));
|
|
||||||
|
|
||||||
errorChain(displaySetState((displaystate_t){
|
errorChain(displaySetState((displaystate_t){
|
||||||
.flags = DISPLAY_STATE_FLAG_BLEND
|
.flags = DISPLAY_STATE_FLAG_BLEND
|
||||||
|
|||||||
@@ -6,12 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "dusk.h"
|
||||||
#include "scenetype.h"
|
#include "scenetype.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
scenetype_t current;
|
scenetype_t current;
|
||||||
scenetype_t next;
|
scenetype_t next;
|
||||||
scenedata_t data;
|
scenedata_t data;
|
||||||
|
mat4 screenProj;
|
||||||
|
mat4 screenView;
|
||||||
|
mat4 screenIdentity;
|
||||||
} scene_t;
|
} scene_t;
|
||||||
|
|
||||||
extern scene_t SCENE;
|
extern scene_t SCENE;
|
||||||
|
|||||||
Reference in New Issue
Block a user