Cleanup and extra error-handling
This commit is contained in:
parent
ee1d777ebb
commit
1f9247e587
1 changed files with 111 additions and 104 deletions
|
@ -94,8 +94,8 @@ RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_w
|
|||
(void)window_title;
|
||||
(void)fullscreen;
|
||||
|
||||
WHBGfxInit();
|
||||
|
||||
if (WHBGfxInit())
|
||||
{
|
||||
// Initialise the shaders
|
||||
|
||||
// Texture shader
|
||||
|
@ -132,8 +132,9 @@ RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_w
|
|||
GX2R_RESOURCE_USAGE_GPU_READ);
|
||||
vertex_position_buffer.elemSize = 2 * sizeof(float);
|
||||
vertex_position_buffer.elemCount = 4;
|
||||
GX2RCreateBuffer(&vertex_position_buffer);
|
||||
|
||||
if (GX2RCreateBuffer(&vertex_position_buffer))
|
||||
{
|
||||
// Initialise texture coordinate buffer
|
||||
texture_coordinate_buffer.flags = (GX2RResourceFlags)(GX2R_RESOURCE_BIND_VERTEX_BUFFER |
|
||||
GX2R_RESOURCE_USAGE_CPU_READ |
|
||||
|
@ -141,8 +142,9 @@ RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_w
|
|||
GX2R_RESOURCE_USAGE_GPU_READ);
|
||||
texture_coordinate_buffer.elemSize = 2 * sizeof(float);
|
||||
texture_coordinate_buffer.elemCount = 4;
|
||||
GX2RCreateBuffer(&texture_coordinate_buffer);
|
||||
|
||||
if (GX2RCreateBuffer(&texture_coordinate_buffer))
|
||||
{
|
||||
// Initialise sampler
|
||||
GX2InitSampler(&sampler, GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR);
|
||||
|
||||
|
@ -152,7 +154,7 @@ RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_w
|
|||
if (framebuffer_surface != NULL)
|
||||
{
|
||||
// Create a 'context' (this voodoo magic can be used to undo `GX2SetColorBuffer`,
|
||||
// allowing us to draw to the screen once again).
|
||||
// allowing us to draw to the screen once again)
|
||||
gx2_context = (GX2ContextState*)aligned_alloc(GX2_CONTEXT_STATE_ALIGNMENT, sizeof(GX2ContextState));
|
||||
memset(gx2_context, 0, sizeof(GX2ContextState));
|
||||
GX2SetupContextStateEx(gx2_context, TRUE);
|
||||
|
@ -161,17 +163,6 @@ RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_w
|
|||
// Disable depth-test (enabled by default for some reason)
|
||||
GX2SetDepthOnlyControl(FALSE, FALSE, GX2_COMPARE_FUNC_ALWAYS);
|
||||
|
||||
// Set custom blending mode for pre-multiplied alpha
|
||||
/* GX2SetBlendControl(GX2_RENDER_TARGET_0,
|
||||
GX2_BLEND_MODE_ZERO,
|
||||
GX2_BLEND_MODE_ONE,
|
||||
GX2_BLEND_COMBINE_MODE_ADD,
|
||||
TRUE,
|
||||
GX2_BLEND_MODE_ZERO,
|
||||
GX2_BLEND_MODE_ONE,
|
||||
GX2_BLEND_COMBINE_MODE_ADD);
|
||||
*/
|
||||
|
||||
// Calculate centred viewports
|
||||
switch (GX2GetSystemTVScanMode())
|
||||
{
|
||||
|
@ -204,7 +195,18 @@ RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_w
|
|||
}
|
||||
|
||||
GX2RDestroyBufferEx(&texture_coordinate_buffer, (GX2RResourceFlags)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Couldn't create the texture coordinate buffer");
|
||||
}
|
||||
|
||||
GX2RDestroyBufferEx(&vertex_position_buffer, (GX2RResourceFlags)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("Couldn't create the vertex position buffer");
|
||||
}
|
||||
|
||||
WHBGfxFreeShaderGroup(&glyph_shader);
|
||||
}
|
||||
|
@ -235,6 +237,11 @@ RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_w
|
|||
}
|
||||
|
||||
WHBGfxShutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
Backend_PrintError("WHBGfxInit failed");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -771,7 +778,7 @@ void RenderBackend_FlushGlyphs(void)
|
|||
|
||||
void RenderBackend_HandleRenderTargetLoss(void)
|
||||
{
|
||||
// No problem for us
|
||||
// Doesn't happen on the Wii U
|
||||
}
|
||||
|
||||
void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height)
|
||||
|
@ -779,5 +786,5 @@ void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height)
|
|||
(void)width;
|
||||
(void)height;
|
||||
|
||||
// No problem for us
|
||||
// Doesn't happen on the Wii U
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue