(WIIU) add rotation support

(WIIU) add rotation support
This commit is contained in:
xhp-creations 2017-01-20 10:29:53 -05:00 committed by GitHub
parent 927e4b6be0
commit a8232f1b46

View File

@ -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)