Add scene scaling
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DUSK_DISPLAY_SCALE
|
||||
#define DUSK_DISPLAY_SCALE 1
|
||||
#endif
|
||||
|
||||
// Main Display Struct, platform-speicifc
|
||||
typedef displayplatform_t display_t;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ const screencropaspectinfo_t SCREEN_CROP_ASPECTS[SCREEN_CROP_ASPECT_COUNT] = {
|
||||
errorret_t screenInit() {
|
||||
memoryZero(&SCREEN, sizeof(screen_t));
|
||||
|
||||
SCREEN.scale = DUSK_DISPLAY_SCALE;
|
||||
SCREEN.background = COLOR_CORNFLOWER_BLUE;
|
||||
|
||||
#ifdef DUSK_DISPLAY_SIZE_DYNAMIC
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
#include "display/display.h"
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/mesh/quad.h"
|
||||
#include "display/color.h"
|
||||
@@ -58,6 +59,7 @@ typedef enum {
|
||||
// } screenscalemode_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t scale;
|
||||
screenmode_t mode;
|
||||
// screenscalemode_t scaleMode;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
|
||||
|
||||
// Camera Eye
|
||||
float_t pixelsPerUnit = TILE_SIZE_PIXELS;
|
||||
float_t worldH = (float_t)SCREEN.height / pixelsPerUnit;
|
||||
float_t worldH = (float_t)(SCREEN.height / SCREEN.scale) / pixelsPerUnit;
|
||||
float_t z = (worldH * 0.5f) / tanf(fov * 0.5f);
|
||||
vec3 worldPosVec;
|
||||
rpgCameraGetPosition(worldPosVec);
|
||||
|
||||
@@ -73,8 +73,8 @@ errorret_t sceneRender(void) {
|
||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, ident));
|
||||
|
||||
glm_ortho(
|
||||
0.0f, SCREEN.width,
|
||||
SCREEN.height, 0.0f,
|
||||
0.0f, (float_t)(SCREEN.width / SCREEN.scale),
|
||||
(float_t)(SCREEN.height / SCREEN.scale), 0.0f,
|
||||
0.1f, 100.0f,
|
||||
proj
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define DUSK_DISPLAY_SCALE 2
|
||||
#include "displaydolphin.h"
|
||||
|
||||
#define displayPlatformInit displayInitDolphin
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#define DUSK_DISPLAY_SCALE 2
|
||||
#include "display/displaysdl2.h"
|
||||
|
||||
typedef displaysdl2_t displayplatform_t;
|
||||
|
||||
Reference in New Issue
Block a user