(PS3) Abstracted rotation code to allow for different implementations
This commit is contained in:
parent
1f6efc65ca
commit
6ff8154d19
|
@ -37,7 +37,7 @@
|
||||||
#define video_focus_func() gl_focus(driver.video_data)
|
#define video_focus_func() gl_focus(driver.video_data)
|
||||||
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
||||||
#define video_free_func() gl_free(driver.video_data)
|
#define video_free_func() gl_free(driver.video_data)
|
||||||
#define video_set_rotation_func(orientation) ps3graphics_set_orientation(driver.video_data, orientation)
|
#define video_set_rotation_func(rotation) gl_set_rotation(driver.video_data, rotation)
|
||||||
#define video_set_aspect_ratio_func(aspectratio_idx) ps3graphics_set_aspect_ratio(driver.video_data, aspectratio_idx)
|
#define video_set_aspect_ratio_func(aspectratio_idx) ps3graphics_set_aspect_ratio(driver.video_data, aspectratio_idx)
|
||||||
|
|
||||||
#define input_init_func() ps3_input_initialize()
|
#define input_init_func() ps3_input_initialize()
|
||||||
|
|
|
@ -34,6 +34,32 @@ static struct texture_image menu_texture;
|
||||||
static PSGLdevice* gl_device;
|
static PSGLdevice* gl_device;
|
||||||
static PSGLcontext* gl_context;
|
static PSGLcontext* gl_context;
|
||||||
|
|
||||||
|
// Other vertex orientations
|
||||||
|
static const GLfloat vertexes_90[] = {
|
||||||
|
0, 1,
|
||||||
|
1, 1,
|
||||||
|
1, 0,
|
||||||
|
0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const GLfloat vertexes_180[] = {
|
||||||
|
1, 1,
|
||||||
|
1, 0,
|
||||||
|
0, 0,
|
||||||
|
0, 1
|
||||||
|
};
|
||||||
|
|
||||||
|
static const GLfloat vertexes_270[] = {
|
||||||
|
1, 0,
|
||||||
|
0, 0,
|
||||||
|
0, 1,
|
||||||
|
1, 1
|
||||||
|
};
|
||||||
|
|
||||||
|
//forward decls
|
||||||
|
extern const GLfloat *vertex_ptr;
|
||||||
|
extern const GLfloat *default_vertex_ptr;
|
||||||
|
|
||||||
void gfx_ctx_set_swap_interval(unsigned interval, bool inited)
|
void gfx_ctx_set_swap_interval(unsigned interval, bool inited)
|
||||||
{
|
{
|
||||||
(void)inited;
|
(void)inited;
|
||||||
|
@ -317,3 +343,28 @@ const char * ps3_get_resolution_label(uint32_t resolution)
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gfx_ctx_set_rotation(gl_t *gl, bool allow_rotate)
|
||||||
|
{
|
||||||
|
if(allow_rotate)
|
||||||
|
{
|
||||||
|
switch (gl->rotation)
|
||||||
|
{
|
||||||
|
case 90:
|
||||||
|
vertex_ptr = vertexes_90;
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
vertex_ptr = vertexes_180;
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
vertex_ptr = vertexes_270;
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
vertex_ptr = default_vertex_ptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
|
||||||
|
}
|
||||||
|
|
|
@ -397,3 +397,15 @@ void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)
|
||||||
*input = NULL;
|
*input = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gfx_ctx_set_rotation(gl_t *gl, bool allow_rotate)
|
||||||
|
{
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
if (allow_rotate)
|
||||||
|
glRotatef(gl->rotation, 0, 0, 1);
|
||||||
|
|
||||||
|
glOrtho(0, 1, 0, 1, -1, 1);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
|
|
20
gfx/gl.c
20
gfx/gl.c
|
@ -77,6 +77,9 @@ const GLfloat white_color[] = {
|
||||||
1, 1, 1, 1,
|
1, 1, 1, 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const GLfloat *vertex_ptr = vertexes_flipped;
|
||||||
|
const GLfloat *default_vertex_ptr = vertexes_flipped;
|
||||||
|
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
#define LOAD_SYM(sym) if (!p##sym) { SDL_SYM_WRAP(p##sym, #sym) }
|
#define LOAD_SYM(sym) if (!p##sym) { SDL_SYM_WRAP(p##sym, #sym) }
|
||||||
#endif
|
#endif
|
||||||
|
@ -422,16 +425,7 @@ static void gl_init_fbo(gl_t *gl, unsigned width, unsigned height)
|
||||||
|
|
||||||
void gl_set_projection(gl_t *gl, bool allow_rotate)
|
void gl_set_projection(gl_t *gl, bool allow_rotate)
|
||||||
{
|
{
|
||||||
glMatrixMode(GL_PROJECTION);
|
gfx_ctx_set_rotation(gl, allow_rotate);
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
if (allow_rotate)
|
|
||||||
glRotatef(gl->rotation, 0, 0, 1);
|
|
||||||
|
|
||||||
glOrtho(0, 1, 0, 1, -1, 1);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
gl_shader_set_proj_matrix();
|
gl_shader_set_proj_matrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +473,7 @@ void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full,
|
||||||
|
|
||||||
static void gl_set_rotation(void *data, unsigned rotation)
|
static void gl_set_rotation(void *data, unsigned rotation)
|
||||||
{
|
{
|
||||||
gl_t *gl = (gl_t*)data;
|
gl_t * gl = driver.video_data;
|
||||||
gl->rotation = 90 * rotation;
|
gl->rotation = 90 * rotation;
|
||||||
gl_set_projection(gl, true);
|
gl_set_projection(gl, true);
|
||||||
}
|
}
|
||||||
|
@ -695,7 +689,7 @@ static void gl_frame_fbo(gl_t *gl, const struct gl_tex_info *tex_info)
|
||||||
gl->vp_width, gl->vp_height, gl->frame_count,
|
gl->vp_width, gl->vp_height, gl->frame_count,
|
||||||
tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
|
tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
|
||||||
|
|
||||||
glVertexPointer(2, GL_FLOAT, 0, vertexes_flipped);
|
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
|
||||||
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
|
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
|
||||||
|
@ -1046,7 +1040,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
glVertexPointer(2, GL_FLOAT, 0, vertexes_flipped);
|
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
|
||||||
|
|
||||||
memcpy(gl->tex_coords, tex_coords, sizeof(tex_coords));
|
memcpy(gl->tex_coords, tex_coords, sizeof(tex_coords));
|
||||||
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
|
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
|
||||||
|
|
|
@ -50,30 +50,6 @@ static const GLfloat vertexes_flipped[] = {
|
||||||
1, 0
|
1, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Other vertex orientations
|
|
||||||
static const GLfloat vertexes_90[] = {
|
|
||||||
0, 1,
|
|
||||||
1, 1,
|
|
||||||
1, 0,
|
|
||||||
0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
static const GLfloat vertexes_180[] = {
|
|
||||||
1, 1,
|
|
||||||
1, 0,
|
|
||||||
0, 0,
|
|
||||||
0, 1
|
|
||||||
};
|
|
||||||
|
|
||||||
static const GLfloat vertexes_270[] = {
|
|
||||||
1, 0,
|
|
||||||
0, 0,
|
|
||||||
0, 1,
|
|
||||||
1, 1
|
|
||||||
};
|
|
||||||
|
|
||||||
static const GLfloat *vertex_ptr = vertexes_flipped;
|
|
||||||
|
|
||||||
// Used when rendering to an FBO.
|
// Used when rendering to an FBO.
|
||||||
// Texture coords have to be aligned with vertex coordinates.
|
// Texture coords have to be aligned with vertex coordinates.
|
||||||
static const GLfloat vertexes[] = {
|
static const GLfloat vertexes[] = {
|
||||||
|
@ -97,6 +73,9 @@ static const GLfloat white_color[] = {
|
||||||
1, 1, 1, 1,
|
1, 1, 1, 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const GLfloat *vertex_ptr = vertexes_flipped;
|
||||||
|
const GLfloat *default_vertex_ptr = vertexes_flipped;
|
||||||
|
|
||||||
#ifdef HAVE_FBO
|
#ifdef HAVE_FBO
|
||||||
#if defined(_WIN32) && !defined(RARCH_CONSOLE)
|
#if defined(_WIN32) && !defined(RARCH_CONSOLE)
|
||||||
static PFNGLGENFRAMEBUFFERSPROC pglGenFramebuffers = NULL;
|
static PFNGLGENFRAMEBUFFERSPROC pglGenFramebuffers = NULL;
|
||||||
|
@ -634,26 +613,17 @@ static void check_window(gl_t *gl)
|
||||||
gl->should_resize = true;
|
gl->should_resize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ps3graphics_set_orientation(void * data, uint32_t orientation)
|
void gl_set_projection(gl_t *gl, bool allow_rotate)
|
||||||
{
|
{
|
||||||
(void)data;
|
gfx_ctx_set_rotation(gl, allow_rotate);
|
||||||
switch (orientation)
|
gl_shader_set_proj_matrix();
|
||||||
{
|
}
|
||||||
case ORIENTATION_NORMAL:
|
|
||||||
vertex_ptr = vertexes_flipped;
|
|
||||||
break;
|
|
||||||
case ORIENTATION_VERTICAL:
|
|
||||||
vertex_ptr = vertexes_90;
|
|
||||||
break;
|
|
||||||
case ORIENTATION_FLIPPED:
|
|
||||||
vertex_ptr = vertexes_180;
|
|
||||||
break;
|
|
||||||
case ORIENTATION_FLIPPED_ROTATED:
|
|
||||||
vertex_ptr = vertexes_270;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
|
static void gl_set_rotation(void *data, unsigned rotation)
|
||||||
|
{
|
||||||
|
gl_t * gl = driver.video_data;
|
||||||
|
gl->rotation = 90 * rotation;
|
||||||
|
gl_set_projection(gl, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __CELLOS_LV2__
|
#ifdef __CELLOS_LV2__
|
||||||
|
@ -1212,7 +1182,7 @@ const video_driver_t video_gl =
|
||||||
.focus = gl_focus,
|
.focus = gl_focus,
|
||||||
.free = gl_free,
|
.free = gl_free,
|
||||||
.ident = "gl",
|
.ident = "gl",
|
||||||
.set_rotation = ps3graphics_set_orientation,
|
.set_rotation = gl_set_rotation,
|
||||||
.set_aspect_ratio = ps3graphics_set_aspect_ratio,
|
.set_aspect_ratio = ps3graphics_set_aspect_ratio,
|
||||||
#ifdef RARCH_CONSOLE
|
#ifdef RARCH_CONSOLE
|
||||||
.start = gl_start,
|
.start = gl_start,
|
||||||
|
|
Loading…
Reference in New Issue