From a8232f1b46d207af6b12a5ce0634d39e18e816bd Mon Sep 17 00:00:00 2001 From: xhp-creations Date: Fri, 20 Jan 2017 10:29:53 -0500 Subject: [PATCH] (WIIU) add rotation support (WIIU) add rotation support --- gfx/drivers/wiiu_gfx.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index 53c91e564f..0d800a7f07 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -138,16 +138,16 @@ static wiiu_set_position(position_t* position, GX2ColorBuffer* draw_buffer, floa GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, position, 4 * sizeof(*position)); } -static void wiiu_set_tex_coords(tex_coord_t* tex_coord, GX2Texture* texture, float u0, float v0, float u1, float v1) +static void wiiu_set_tex_coords(tex_coord_t* tex_coord, GX2Texture* texture, float u0, float v0, float u1, float v1, unsigned rotation) { - tex_coord[0].u = u0 / texture->surface.width; - tex_coord[0].v = (v1 / texture->surface.height); - tex_coord[1].u = u1 / texture->surface.width; - tex_coord[1].v = (v1 / texture->surface.height); - tex_coord[2].u = u1 / texture->surface.width; - tex_coord[2].v = (v0 / texture->surface.height); - tex_coord[3].u = u0 / texture->surface.width; - tex_coord[3].v = (v0 / texture->surface.height); + tex_coord[((0 + rotation) % 4)].u = u0 / texture->surface.width; + tex_coord[((0 + rotation) % 4)].v = (v1 / texture->surface.height); + tex_coord[((1 + rotation) % 4)].u = u1 / texture->surface.width; + tex_coord[((1 + rotation) % 4)].v = (v1 / texture->surface.height); + tex_coord[((2 + rotation) % 4)].u = u1 / texture->surface.width; + tex_coord[((2 + rotation) % 4)].v = (v0 / texture->surface.height); + tex_coord[((3 + rotation) % 4)].u = u0 / texture->surface.width; + tex_coord[((3 + rotation) % 4)].v = (v0 / texture->surface.height); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, tex_coord, 4 * sizeof(*tex_coord)); } @@ -407,7 +407,7 @@ static void* wiiu_gfx_init(const video_info_t* video, wiiu->tex_coord = MEM2_alloc(4 * sizeof(*wiiu->tex_coord), GX2_VERTEX_BUFFER_ALIGNMENT); wiiu_set_tex_coords(wiiu->tex_coord, &wiiu->texture, 0, 0, - wiiu->texture.surface.width, wiiu->texture.surface.height); + wiiu->texture.surface.width, wiiu->texture.surface.height, wiiu->rotation); GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->position), sizeof(*wiiu->position), wiiu->position); GX2SetAttribBuffer(1, 4 * sizeof(*wiiu->tex_coord), sizeof(*wiiu->tex_coord), wiiu->tex_coord); @@ -418,7 +418,7 @@ static void* wiiu_gfx_init(const video_info_t* video, wiiu->menu.tex_coord = MEM2_alloc(4 * sizeof(*wiiu->menu.tex_coord), GX2_VERTEX_BUFFER_ALIGNMENT); wiiu_set_tex_coords(wiiu->menu.tex_coord, &wiiu->menu.texture, 0, 0, - wiiu->menu.texture.surface.width, wiiu->menu.texture.surface.height); + wiiu->menu.texture.surface.width, wiiu->menu.texture.surface.height, wiiu->rotation); /* init frame texture */ memset(&wiiu->texture, 0, sizeof(GX2Texture)); @@ -667,7 +667,7 @@ static bool wiiu_gfx_frame(void* data, const void* frame, GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->texture.surface.image, wiiu->texture.surface.imageSize); - wiiu_set_tex_coords(wiiu->tex_coord, &wiiu->texture, 0, 0, width, height); + wiiu_set_tex_coords(wiiu->tex_coord, &wiiu->texture, 0, 0, width, height, wiiu->rotation); } GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->position), sizeof(*wiiu->position), wiiu->position); @@ -836,8 +836,8 @@ static void wiiu_gfx_set_texture_frame(void* data, const void* frame, bool rgb32 GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->menu.texture.surface.image, wiiu->menu.texture.surface.imageSize); - wiiu_set_tex_coords(wiiu->menu.tex_coord, &wiiu->menu.texture, 0, 0, width, height); -// wiiu_set_tex_coords(wiiu->menu.tex_coord, &wiiu->menu.texture, 0, 0, wiiu->menu.texture.surface.width, wiiu->menu.texture.surface.height); + wiiu_set_tex_coords(wiiu->menu.tex_coord, &wiiu->menu.texture, 0, 0, width, height, wiiu->rotation); +// wiiu_set_tex_coords(wiiu->menu.tex_coord, &wiiu->menu.texture, 0, 0, wiiu->menu.texture.surface.width, wiiu->menu.texture.surface.height, wiiu->rotation); } static void wiiu_gfx_set_texture_enable(void* data, bool state, bool full_screen)