Improved Wii aspect ratio significantly
This commit is contained in:
@@ -64,7 +64,7 @@ errorret_t displayInit(void) {
|
|||||||
|
|
||||||
glm_perspective(
|
glm_perspective(
|
||||||
glm_rad(45.0f),
|
glm_rad(45.0f),
|
||||||
(float_t)SCREEN.width / (float_t)SCREEN.height,
|
SCREEN.aspect,
|
||||||
0.1f,
|
0.1f,
|
||||||
100.0f,
|
100.0f,
|
||||||
proj
|
proj
|
||||||
|
|||||||
@@ -40,6 +40,17 @@ uint32_t frameBufferGetHeight(const framebuffer_t *framebuffer) {
|
|||||||
return frameBufferPlatformGetHeight(framebuffer);
|
return frameBufferPlatformGetHeight(framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float_t frameBufferGetAspect(const framebuffer_t *framebuffer) {
|
||||||
|
#ifdef frameBufferPlatformGetAspect
|
||||||
|
return frameBufferPlatformGetAspect(framebuffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t width = frameBufferGetWidth(framebuffer);
|
||||||
|
uint32_t height = frameBufferGetHeight(framebuffer);
|
||||||
|
if(height == 0) return 1.0f; // Avoid divide by zero, just return 1:1 aspect.
|
||||||
|
return (float_t)width / (float_t)height;
|
||||||
|
}
|
||||||
|
|
||||||
void frameBufferClear(const uint8_t flags, const color_t color) {
|
void frameBufferClear(const uint8_t flags, const color_t color) {
|
||||||
frameBufferPlatformClear(flags, color);
|
frameBufferPlatformClear(flags, color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,16 @@ uint32_t frameBufferGetWidth(const framebuffer_t *framebuffer);
|
|||||||
*/
|
*/
|
||||||
uint32_t frameBufferGetHeight(const framebuffer_t *framebuffer);
|
uint32_t frameBufferGetHeight(const framebuffer_t *framebuffer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the aspect ratio of the framebuffer. This is ALMOST always just
|
||||||
|
* the width / height, however some platforms may choose to override this if
|
||||||
|
* they have stretched styled back buffers, e.g. 640x480 stretched.
|
||||||
|
*
|
||||||
|
* @param framebuffer The framebuffer to get the aspect ratio of.
|
||||||
|
* @return The aspect ratio of the framebuffer.
|
||||||
|
*/
|
||||||
|
float_t frameBufferGetAspect(const framebuffer_t *framebuffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the framebuffer for rendering, or the backbuffer if the framebuffer
|
* Binds the framebuffer for rendering, or the backbuffer if the framebuffer
|
||||||
* provided is NULL.
|
* provided is NULL.
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ errorret_t screenBind() {
|
|||||||
// Screen mode backbuffer uses the full display size
|
// Screen mode backbuffer uses the full display size
|
||||||
SCREEN.width = frameBufferGetWidth(FRAMEBUFFER_BOUND);
|
SCREEN.width = frameBufferGetWidth(FRAMEBUFFER_BOUND);
|
||||||
SCREEN.height = frameBufferGetHeight(FRAMEBUFFER_BOUND);
|
SCREEN.height = frameBufferGetHeight(FRAMEBUFFER_BOUND);
|
||||||
SCREEN.aspect = (float_t)SCREEN.width / (float_t)SCREEN.height;
|
SCREEN.aspect = frameBufferGetAspect(FRAMEBUFFER_BOUND);
|
||||||
|
|
||||||
// No needd for a framebuffer.
|
// No needd for a framebuffer.
|
||||||
#ifdef DUSK_DISPLAY_SIZE_DYNAMIC
|
#ifdef DUSK_DISPLAY_SIZE_DYNAMIC
|
||||||
@@ -100,8 +100,7 @@ errorret_t screenBind() {
|
|||||||
int32_t fbWidth, fbHeight;
|
int32_t fbWidth, fbHeight;
|
||||||
fbWidth = frameBufferGetWidth(FRAMEBUFFER_BOUND);
|
fbWidth = frameBufferGetWidth(FRAMEBUFFER_BOUND);
|
||||||
fbHeight = frameBufferGetHeight(FRAMEBUFFER_BOUND);
|
fbHeight = frameBufferGetHeight(FRAMEBUFFER_BOUND);
|
||||||
|
float_t currentAspect = frameBufferGetAspect(FRAMEBUFFER_BOUND);
|
||||||
float_t currentAspect = (float_t)fbWidth / (float_t)fbHeight;
|
|
||||||
if(currentAspect == SCREEN.aspectRatio.ratio) {
|
if(currentAspect == SCREEN.aspectRatio.ratio) {
|
||||||
// No need to use framebuffer.
|
// No need to use framebuffer.
|
||||||
SCREEN.width = fbWidth;
|
SCREEN.width = fbWidth;
|
||||||
@@ -129,13 +128,14 @@ errorret_t screenBind() {
|
|||||||
if(SCREEN.framebufferReady) {
|
if(SCREEN.framebufferReady) {
|
||||||
// Is current framebuffer the correct size?
|
// Is current framebuffer the correct size?
|
||||||
int32_t curFbWidth, curFbHeight;
|
int32_t curFbWidth, curFbHeight;
|
||||||
|
float_t curFbAspect = frameBufferGetAspect(&SCREEN.framebuffer);
|
||||||
curFbWidth = frameBufferGetWidth(&SCREEN.framebuffer);
|
curFbWidth = frameBufferGetWidth(&SCREEN.framebuffer);
|
||||||
curFbHeight = frameBufferGetHeight(&SCREEN.framebuffer);
|
curFbHeight = frameBufferGetHeight(&SCREEN.framebuffer);
|
||||||
if(curFbWidth == newFbWidth && curFbHeight == newFbHeight) {
|
if(curFbWidth == newFbWidth && curFbHeight == newFbHeight) {
|
||||||
// Correct size, nothing to do.
|
// Correct size, nothing to do.
|
||||||
SCREEN.width = newFbWidth;
|
SCREEN.width = newFbWidth;
|
||||||
SCREEN.height = newFbHeight;
|
SCREEN.height = newFbHeight;
|
||||||
SCREEN.aspect = (float_t)SCREEN.width / (float_t)SCREEN.height;
|
SCREEN.aspect = curFbAspect;
|
||||||
errorChain(frameBufferBind(&SCREEN.framebuffer));
|
errorChain(frameBufferBind(&SCREEN.framebuffer));
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-27
@@ -113,8 +113,8 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
|||||||
errorChain(networkInit());
|
errorChain(networkInit());
|
||||||
errorChain(gameInit());
|
errorChain(gameInit());
|
||||||
|
|
||||||
printf("Init done, going to queue online in 3 seconds...\n");
|
// printf("Init done, going to queue online in 3 seconds...\n");
|
||||||
onlineSwapTime = TIME.time + 3.0f;
|
// onlineSwapTime = TIME.time + 3.0f;
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
entityid_t cam = entityManagerAdd();
|
entityid_t cam = entityManagerAdd();
|
||||||
@@ -130,35 +130,35 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
|||||||
entityCameraSetZFar(cam, camCam, 100.0f);
|
entityCameraSetZFar(cam, camCam, 100.0f);
|
||||||
|
|
||||||
// Floor
|
// Floor
|
||||||
entityid_t floorEnt = entityManagerAdd();
|
// entityid_t floorEnt = entityManagerAdd();
|
||||||
componentid_t floorPos = entityAddComponent(floorEnt, COMPONENT_TYPE_POSITION);
|
// componentid_t floorPos = entityAddComponent(floorEnt, COMPONENT_TYPE_POSITION);
|
||||||
componentid_t floorMesh = entityAddComponent(floorEnt, COMPONENT_TYPE_MESH);
|
// componentid_t floorMesh = entityAddComponent(floorEnt, COMPONENT_TYPE_MESH);
|
||||||
componentid_t floorMat = entityAddComponent(floorEnt, COMPONENT_TYPE_MATERIAL);
|
// componentid_t floorMat = entityAddComponent(floorEnt, COMPONENT_TYPE_MATERIAL);
|
||||||
componentid_t floorPhys = entityAddComponent(floorEnt, COMPONENT_TYPE_PHYSICS);
|
// componentid_t floorPhys = entityAddComponent(floorEnt, COMPONENT_TYPE_PHYSICS);
|
||||||
|
|
||||||
entityPositionSetPosition(floorEnt, floorPos, (vec3){ -5.0f, 0.0f, -5.0f });
|
// entityPositionSetPosition(floorEnt, floorPos, (vec3){ -5.0f, 0.0f, -5.0f });
|
||||||
entityPositionSetScale(floorEnt, floorPos, (vec3){ 10.0f, 1.0f, 10.0f });
|
// entityPositionSetScale(floorEnt, floorPos, (vec3){ 10.0f, 1.0f, 10.0f });
|
||||||
entityMeshSetMesh(floorEnt, floorMesh, &PLANE_MESH_SIMPLE);
|
// entityMeshSetMesh(floorEnt, floorMesh, &PLANE_MESH_SIMPLE);
|
||||||
entityMaterialGetShaderMaterial(floorEnt, floorMat)->unlit.color = COLOR_GREEN;
|
// entityMaterialGetShaderMaterial(floorEnt, floorMat)->unlit.color = COLOR_GREEN;
|
||||||
|
|
||||||
entityphysics_t *floorPhysData = entityPhysicsGet(floorEnt, floorPhys);
|
// entityphysics_t *floorPhysData = entityPhysicsGet(floorEnt, floorPhys);
|
||||||
floorPhysData->type = PHYSICS_BODY_STATIC;
|
// floorPhysData->type = PHYSICS_BODY_STATIC;
|
||||||
floorPhysData->shape.type = PHYSICS_SHAPE_PLANE;
|
// floorPhysData->shape.type = PHYSICS_SHAPE_PLANE;
|
||||||
floorPhysData->shape.data.plane.normal[0] = 0.0f;
|
// floorPhysData->shape.data.plane.normal[0] = 0.0f;
|
||||||
floorPhysData->shape.data.plane.normal[1] = 1.0f;
|
// floorPhysData->shape.data.plane.normal[1] = 1.0f;
|
||||||
floorPhysData->shape.data.plane.normal[2] = 0.0f;
|
// floorPhysData->shape.data.plane.normal[2] = 0.0f;
|
||||||
floorPhysData->shape.data.plane.distance = 0.0f;
|
// floorPhysData->shape.data.plane.distance = 0.0f;
|
||||||
|
|
||||||
/* ---- Dynamic box ---- */
|
// Box
|
||||||
phBoxEnt = entityManagerAdd();
|
phBoxEnt = entityManagerAdd();
|
||||||
componentid_t boxPos = entityAddComponent(phBoxEnt, COMPONENT_TYPE_POSITION);
|
componentid_t boxPos = entityAddComponent(phBoxEnt, COMPONENT_TYPE_POSITION);
|
||||||
componentid_t boxMesh = entityAddComponent(phBoxEnt, COMPONENT_TYPE_MESH);
|
componentid_t boxMesh = entityAddComponent(phBoxEnt, COMPONENT_TYPE_MESH);
|
||||||
componentid_t boxMat = entityAddComponent(phBoxEnt, COMPONENT_TYPE_MATERIAL);
|
componentid_t boxMat = entityAddComponent(phBoxEnt, COMPONENT_TYPE_MATERIAL);
|
||||||
phBoxPhys = entityAddComponent(phBoxEnt, COMPONENT_TYPE_PHYSICS);
|
// phBoxPhys = entityAddComponent(phBoxEnt, COMPONENT_TYPE_PHYSICS);
|
||||||
|
|
||||||
entityMeshSetMesh(phBoxEnt, boxMesh, &CUBE_MESH_SIMPLE);
|
entityMeshSetMesh(phBoxEnt, boxMesh, &CUBE_MESH_SIMPLE);
|
||||||
entityMaterialGetShaderMaterial(phBoxEnt, boxMat)->unlit.color = COLOR_RED;
|
entityMaterialGetShaderMaterial(phBoxEnt, boxMat)->unlit.color = COLOR_RED;
|
||||||
entityPositionSetPosition(phBoxEnt, boxPos, (vec3){ 0.0f, 4.0f, 0.0f });
|
entityPositionSetPosition(phBoxEnt, boxPos, (vec3){ 0.0f, 0.0f, 0.0f });
|
||||||
|
|
||||||
/* Run the init script. */
|
/* Run the init script. */
|
||||||
scriptcontext_t ctx;
|
scriptcontext_t ctx;
|
||||||
@@ -178,12 +178,12 @@ errorret_t engineUpdate(void) {
|
|||||||
uiUpdate();
|
uiUpdate();
|
||||||
errorChain(sceneUpdate());
|
errorChain(sceneUpdate());
|
||||||
|
|
||||||
/* Reset the box to its start position on demand. */
|
// /* Reset the box to its start position on demand. */
|
||||||
if(inputIsDown(INPUT_ACTION_ACCEPT)) {
|
// if(inputIsDown(INPUT_ACTION_ACCEPT)) {
|
||||||
componentid_t posComp = entityGetComponent(phBoxEnt, COMPONENT_TYPE_POSITION);
|
// componentid_t posComp = entityGetComponent(phBoxEnt, COMPONENT_TYPE_POSITION);
|
||||||
entityPositionSetPosition(phBoxEnt, posComp, (vec3){ 0.0f, 4.0f, 0.0f });
|
// entityPositionSetPosition(phBoxEnt, posComp, (vec3){ 0.0f, 4.0f, 0.0f });
|
||||||
entityPhysicsSetVelocity(phBoxEnt, phBoxPhys, (vec3){ 0.0f, 0.0f, 0.0f });
|
// entityPhysicsSetVelocity(phBoxEnt, phBoxPhys, (vec3){ 0.0f, 0.0f, 0.0f });
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Step physics: positions are updated directly on POSITION components. */
|
/* Step physics: positions are updated directly on POSITION components. */
|
||||||
physicsManagerUpdate();
|
physicsManagerUpdate();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "display/framebuffer/framebuffer.h"
|
#include "display/framebuffer/framebuffer.h"
|
||||||
#include "display/display.h"
|
#include "display/display.h"
|
||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
|
#include "system/systemdolphin.h"
|
||||||
|
|
||||||
errorret_t frameBufferInitBackBufferDolphin(void) {
|
errorret_t frameBufferInitBackBufferDolphin(void) {
|
||||||
errorOk();
|
errorOk();
|
||||||
@@ -15,16 +16,29 @@ errorret_t frameBufferInitBackBufferDolphin(void) {
|
|||||||
|
|
||||||
uint32_t frameBufferGetWidthDolphin(const framebufferdolphin_t *framebuffer) {
|
uint32_t frameBufferGetWidthDolphin(const framebufferdolphin_t *framebuffer) {
|
||||||
assertNotNull(framebuffer, "Cannot get width of NULL framebuffer.");
|
assertNotNull(framebuffer, "Cannot get width of NULL framebuffer.");
|
||||||
|
|
||||||
return DISPLAY.screenMode->fbWidth;
|
return DISPLAY.screenMode->fbWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t frameBufferGetHeightDolphin(const framebufferdolphin_t *framebuffer) {
|
uint32_t frameBufferGetHeightDolphin(const framebufferdolphin_t *framebuffer) {
|
||||||
assertNotNull(framebuffer, "Cannot get height of NULL framebuffer.");
|
assertNotNull(framebuffer, "Cannot get height of NULL framebuffer.");
|
||||||
|
|
||||||
return DISPLAY.screenMode->efbHeight;
|
return DISPLAY.screenMode->efbHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float_t frameBufferGetAspectDolphin(const framebufferdolphin_t *framebuffer) {
|
||||||
|
assertNotNull(framebuffer, "Cannot get aspect of NULL framebuffer.");
|
||||||
|
switch(systemGetAspectRatioDolphin()) {
|
||||||
|
case CONF_ASPECT_16_9:
|
||||||
|
return 16.0f / 9.0f;
|
||||||
|
case CONF_ASPECT_4_3:
|
||||||
|
return 4.0f / 3.0f;
|
||||||
|
default:
|
||||||
|
return (
|
||||||
|
(float_t)DISPLAY.screenMode->fbWidth /
|
||||||
|
(float_t)DISPLAY.screenMode->efbHeight
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
errorret_t frameBufferBindDolphin(framebufferdolphin_t *framebuffer) {
|
errorret_t frameBufferBindDolphin(framebufferdolphin_t *framebuffer) {
|
||||||
assertNotNull(framebuffer, "Cannot bind NULL framebuffer.");
|
assertNotNull(framebuffer, "Cannot bind NULL framebuffer.");
|
||||||
assertTrue(
|
assertTrue(
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ uint32_t frameBufferGetWidthDolphin(const framebufferdolphin_t *framebuffer);
|
|||||||
*/
|
*/
|
||||||
uint32_t frameBufferGetHeightDolphin(const framebufferdolphin_t *framebuffer);
|
uint32_t frameBufferGetHeightDolphin(const framebufferdolphin_t *framebuffer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the aspect ratio of the framebuffer. (Dolphin implementation). Taking
|
||||||
|
* the Wii aspect setting into consideration.
|
||||||
|
*
|
||||||
|
* @param framebuffer The framebuffer to get the aspect ratio of.
|
||||||
|
* @return The aspect ratio of the framebuffer.
|
||||||
|
*/
|
||||||
|
float_t frameBufferGetAspectDolphin(const framebufferdolphin_t *framebuffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the framebuffer for rendering. (Dolphin implementation).
|
* Binds the framebuffer for rendering. (Dolphin implementation).
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ typedef framebufferdolphin_t framebufferplatform_t;
|
|||||||
#define frameBufferPlatformInitBackBuffer frameBufferInitBackBufferDolphin
|
#define frameBufferPlatformInitBackBuffer frameBufferInitBackBufferDolphin
|
||||||
#define frameBufferPlatformGetWidth frameBufferGetWidthDolphin
|
#define frameBufferPlatformGetWidth frameBufferGetWidthDolphin
|
||||||
#define frameBufferPlatformGetHeight frameBufferGetHeightDolphin
|
#define frameBufferPlatformGetHeight frameBufferGetHeightDolphin
|
||||||
|
#define frameBufferPlatformGetAspect frameBufferGetAspectDolphin
|
||||||
#define frameBufferPlatformBind frameBufferBindDolphin
|
#define frameBufferPlatformBind frameBufferBindDolphin
|
||||||
#define frameBufferPlatformClear frameBufferClearDolphin
|
#define frameBufferPlatformClear frameBufferClearDolphin
|
||||||
|
|||||||
@@ -228,12 +228,13 @@ errorret_t shaderUpdateMVPDolphin() {
|
|||||||
|
|
||||||
// Set Model/View Matrix
|
// Set Model/View Matrix
|
||||||
if(mvDirt) {
|
if(mvDirt) {
|
||||||
guMtxConcat(
|
// guMtxConcat(
|
||||||
SHADER_BOUND->matrixView,
|
// SHADER_BOUND->matrixView,
|
||||||
SHADER_BOUND->matrixModel,
|
// SHADER_BOUND->matrixModel,
|
||||||
SHADER_BOUND->matrixModelView
|
// SHADER_BOUND->matrixModelView
|
||||||
);
|
// );
|
||||||
GX_LoadPosMtxImm(SHADER_BOUND->matrixModelView, GX_PNMTX0);
|
// GX_LoadPosMtxImm(SHADER_BOUND->matrixModelView, GX_PNMTX0);
|
||||||
|
GX_LoadPosMtxImm(SHADER_BOUND->matrixView, GX_PNMTX0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHADER_BOUND->dirtyMatrix = 0;
|
SHADER_BOUND->dirtyMatrix = 0;
|
||||||
@@ -255,7 +256,7 @@ void shaderMat4ToMtx(const mat4 inGlmMatrix, Mtx outGXMatrix) {
|
|||||||
assertNotNull(inGlmMatrix, "Input matrix cannot be null");
|
assertNotNull(inGlmMatrix, "Input matrix cannot be null");
|
||||||
assertNotNull(outGXMatrix, "Output matrix cannot be null");
|
assertNotNull(outGXMatrix, "Output matrix cannot be null");
|
||||||
|
|
||||||
for(int row = 0; row < 3; ++row) {
|
for(int row = 0; row < 4; ++row) {// Can perhaps be 3.
|
||||||
for(int col = 0; col < 4; ++col) {
|
for(int col = 0; col < 4; ++col) {
|
||||||
outGXMatrix[row][col] = inGlmMatrix[col][row];
|
outGXMatrix[row][col] = inGlmMatrix[col][row];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,12 @@ errorret_t systemInitDolphin(void) {
|
|||||||
|
|
||||||
systemdialogtype_t systemGetActiveDialogTypeDolphin(void) {
|
systemdialogtype_t systemGetActiveDialogTypeDolphin(void) {
|
||||||
return SYSTEM_DIALOG_TYPE_NONE;
|
return SYSTEM_DIALOG_TYPE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t systemGetAspectRatioDolphin(void) {
|
||||||
|
return CONF_GetAspectRatio();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t systemGetLanguageDolphin(void) {
|
||||||
|
return CONF_GetLanguage();
|
||||||
}
|
}
|
||||||
@@ -20,4 +20,29 @@ errorret_t systemInitDolphin(void);
|
|||||||
*
|
*
|
||||||
* @return Currently open system dialog type.
|
* @return Currently open system dialog type.
|
||||||
*/
|
*/
|
||||||
systemdialogtype_t systemGetActiveDialogTypeDolphin(void);
|
systemdialogtype_t systemGetActiveDialogTypeDolphin(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns either CONF_ASPECT_4_3 or CONF_ASPECT_16_9 depending on the aspect
|
||||||
|
* ratio of the system. I do believe that Gamecube will only ever return 4:3.
|
||||||
|
*
|
||||||
|
* Refer to;
|
||||||
|
* https://github.com/devkitPro/libogc/blob/20d90e944b83c8991538e88b00b1e5f309428e85/gc/ogc/conf.h#L190
|
||||||
|
*
|
||||||
|
* @return Aspect ratio of the system.
|
||||||
|
*/
|
||||||
|
int32_t systemGetAspectRatioDolphin(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the language the system is set to. This is used for things like
|
||||||
|
* locale management, to try to match the system language if possible.
|
||||||
|
*
|
||||||
|
* Refer to;
|
||||||
|
* https://github.com/devkitPro/libogc/blob/20d90e944b83c8991538e88b00b1e5f309428e85/gc/ogc/conf.h#L190
|
||||||
|
*
|
||||||
|
* @return System language.
|
||||||
|
*/
|
||||||
|
int32_t systemGetLanguageDolphin(void);
|
||||||
|
|
||||||
|
// There's actually a tonne more things Wii can return, this is it for now
|
||||||
|
// though.
|
||||||
Reference in New Issue
Block a user