Style nit party.

This commit is contained in:
Themaister 2012-05-27 23:14:46 +02:00
parent 1d05161723
commit 72310b6661
6 changed files with 94 additions and 88 deletions

View File

@ -256,57 +256,59 @@ void gfx_ctx_set_fbo(bool enable)
void gfx_ctx_get_available_resolutions (void) void gfx_ctx_get_available_resolutions (void)
{ {
bool defaultresolution; bool defaultresolution;
uint32_t i, resolution_count; uint32_t resolution_count;
uint16_t num_videomodes; uint16_t num_videomodes;
if(g_console.check_available_resolutions) if (g_console.check_available_resolutions)
return; return;
defaultresolution = true; defaultresolution = true;
uint32_t videomode[] = { uint32_t videomode[] = {
CELL_VIDEO_OUT_RESOLUTION_480, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_RESOLUTION_480, CELL_VIDEO_OUT_RESOLUTION_576,
CELL_VIDEO_OUT_RESOLUTION_960x1080, CELL_VIDEO_OUT_RESOLUTION_720, CELL_VIDEO_OUT_RESOLUTION_960x1080, CELL_VIDEO_OUT_RESOLUTION_720,
CELL_VIDEO_OUT_RESOLUTION_1280x1080, CELL_VIDEO_OUT_RESOLUTION_1440x1080, CELL_VIDEO_OUT_RESOLUTION_1280x1080, CELL_VIDEO_OUT_RESOLUTION_1440x1080,
CELL_VIDEO_OUT_RESOLUTION_1600x1080, CELL_VIDEO_OUT_RESOLUTION_1080}; CELL_VIDEO_OUT_RESOLUTION_1600x1080, CELL_VIDEO_OUT_RESOLUTION_1080
};
num_videomodes = sizeof(videomode)/sizeof(uint32_t); num_videomodes = sizeof(videomode) / sizeof(uint32_t);
resolution_count = 0; resolution_count = 0;
for (i = 0; i < num_videomodes; i++) for (unsigned i = 0; i < num_videomodes; i++)
if (cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, videomode[i], CELL_VIDEO_OUT_ASPECT_AUTO,0)) {
if (cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, videomode[i], CELL_VIDEO_OUT_ASPECT_AUTO, 0))
resolution_count++; resolution_count++;
}
g_console.supported_resolutions = (uint32_t*)malloc(resolution_count * sizeof(uint32_t)); g_console.supported_resolutions = malloc(resolution_count * sizeof(uint32_t));
g_console.supported_resolutions_count = 0; g_console.supported_resolutions_count = 0;
for (i = 0; i < num_videomodes; i++) for (unsigned i = 0; i < num_videomodes; i++)
{ {
if (cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, videomode[i], CELL_VIDEO_OUT_ASPECT_AUTO,0)) if (cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, videomode[i], CELL_VIDEO_OUT_ASPECT_AUTO, 0))
{ {
g_console.supported_resolutions[g_console.supported_resolutions_count++] = videomode[i]; g_console.supported_resolutions[g_console.supported_resolutions_count++] = videomode[i];
g_console.initial_resolution_id = videomode[i]; g_console.initial_resolution_id = videomode[i];
if (g_console.current_resolution_id == videomode[i]) if (g_console.current_resolution_id == videomode[i])
{ {
defaultresolution = false; defaultresolution = false;
g_console.current_resolution_index = g_console.supported_resolutions_count-1; g_console.current_resolution_index = g_console.supported_resolutions_count-1;
} }
} }
} }
/* In case we didn't specify a resolution - make the last resolution /* In case we didn't specify a resolution - make the last resolution
that was added to the list (the highest resolution) the default resolution*/ that was added to the list (the highest resolution) the default resolution */
if (g_console.current_resolution_id > num_videomodes || defaultresolution) if (g_console.current_resolution_id > num_videomodes || defaultresolution)
g_console.current_resolution_index = g_console.supported_resolutions_count-1; g_console.current_resolution_index = g_console.supported_resolutions_count - 1;
g_console.check_available_resolutions = true; g_console.check_available_resolutions = true;
} }
void ps3_next_resolution (void) void ps3_next_resolution (void)
{ {
if(g_console.current_resolution_index+1 < g_console.supported_resolutions_count) if (g_console.current_resolution_index + 1 < g_console.supported_resolutions_count)
{ {
g_console.current_resolution_index++; g_console.current_resolution_index++;
g_console.current_resolution_id = g_console.supported_resolutions[g_console.current_resolution_index]; g_console.current_resolution_id = g_console.supported_resolutions[g_console.current_resolution_index];
@ -315,7 +317,7 @@ void ps3_next_resolution (void)
void ps3_previous_resolution (void) void ps3_previous_resolution (void)
{ {
if(g_console.current_resolution_index) if (g_console.current_resolution_index)
{ {
g_console.current_resolution_index--; g_console.current_resolution_index--;
g_console.current_resolution_id = g_console.supported_resolutions[g_console.current_resolution_index]; g_console.current_resolution_id = g_console.supported_resolutions[g_console.current_resolution_index];
@ -324,12 +326,12 @@ void ps3_previous_resolution (void)
int ps3_check_resolution(uint32_t resolution_id) int ps3_check_resolution(uint32_t resolution_id)
{ {
return cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, resolution_id, CELL_VIDEO_OUT_ASPECT_AUTO,0); return cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, resolution_id, CELL_VIDEO_OUT_ASPECT_AUTO, 0);
} }
const char * ps3_get_resolution_label(uint32_t resolution) const char *ps3_get_resolution_label(uint32_t resolution)
{ {
switch(resolution) switch (resolution)
{ {
case CELL_VIDEO_OUT_RESOLUTION_480: case CELL_VIDEO_OUT_RESOLUTION_480:
return "720x480 (480p)"; return "720x480 (480p)";
@ -352,30 +354,30 @@ const char * ps3_get_resolution_label(uint32_t resolution)
} }
} }
void gfx_ctx_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate) void gfx_ctx_set_projection(gl_t *gl, const struct gl_ortho *ortho, bool allow_rotate)
{ {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
if(allow_rotate) if (allow_rotate)
{ {
switch (gl->rotation) switch (gl->rotation)
{ {
case 90: case 90:
vertex_ptr = vertexes_90; vertex_ptr = vertexes_90;
break; break;
case 180: case 180:
vertex_ptr = vertexes_180; vertex_ptr = vertexes_180;
break; break;
case 270: case 270:
vertex_ptr = vertexes_270; vertex_ptr = vertexes_270;
break; break;
case 0: case 0:
default: default:
vertex_ptr = default_vertex_ptr; vertex_ptr = default_vertex_ptr;
break; break;
} }
} }
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr); glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
@ -384,12 +386,12 @@ void gfx_ctx_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate)
glLoadIdentity(); glLoadIdentity();
} }
void gfx_ctx_set_aspect_ratio(void * data, unsigned aspectratio_index) void gfx_ctx_set_aspect_ratio(void *data, unsigned aspectratio_index)
{ {
(void)data; (void)data;
gl_t * gl = driver.video_data; gl_t *gl = driver.video_data;
if(g_console.aspect_ratio_index == ASPECT_RATIO_AUTO) if (g_console.aspect_ratio_index == ASPECT_RATIO_AUTO)
rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
g_settings.video.aspect_ratio = aspectratio_lut[g_console.aspect_ratio_index].value; g_settings.video.aspect_ratio = aspectratio_lut[g_console.aspect_ratio_index].value;
@ -400,9 +402,10 @@ void gfx_ctx_set_aspect_ratio(void * data, unsigned aspectratio_index)
void gfx_ctx_set_overscan(void) void gfx_ctx_set_overscan(void)
{ {
gl_t * gl = driver.video_data; gl_t *gl = driver.video_data;
if(!gl) if (!gl)
return; return;
gl->should_resize = true; gl->should_resize = true;
} }

View File

@ -398,7 +398,7 @@ void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)
} }
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
void gfx_ctx_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate) void gfx_ctx_set_projection(gl_t *gl, const struct gl_ortho *ortho, bool allow_rotate)
{ {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
@ -406,7 +406,7 @@ void gfx_ctx_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate)
if (allow_rotate) if (allow_rotate)
glRotatef(gl->rotation, 0, 0, 1); glRotatef(gl->rotation, 0, 0, 1);
glOrtho(0, 1, 0, 1, -1, 1); glOrtho(ortho->left, ortho->right, ortho->bottom, ortho->top, ortho->near, ortho->far);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
} }

View File

@ -227,7 +227,6 @@ extern const GLfloat white_color[];
void gl_render_msg_post(gl_t *gl) void gl_render_msg_post(gl_t *gl)
{ {
ortho_t ortho = {0}; //dummy - no overscan on PC
#ifdef HAVE_FREETYPE #ifdef HAVE_FREETYPE
// Go back to old rendering path. // Go back to old rendering path.
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords); glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
@ -236,6 +235,8 @@ void gl_render_msg_post(gl_t *gl)
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
glDisable(GL_BLEND); glDisable(GL_BLEND);
struct gl_ortho ortho = {0, 1, 0, 1, -1, 1};
gl_set_projection(gl, &ortho, true); gl_set_projection(gl, &ortho, true);
#else #else
(void)gl; (void)gl;

View File

@ -73,7 +73,7 @@ void gfx_ctx_get_available_resolutions(void);
#endif #endif
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
void gfx_ctx_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate); void gfx_ctx_set_projection(gl_t *gl, const struct gl_ortho *ortho, bool allow_rotate);
#endif #endif
#endif #endif

View File

@ -423,14 +423,14 @@ static void gl_init_fbo(gl_t *gl, unsigned width, unsigned height)
//////////// ////////////
void gl_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate) void gl_set_projection(gl_t *gl, struct gl_ortho *ortho, bool allow_rotate)
{ {
#ifdef RARCH_CONSOLE #ifdef RARCH_CONSOLE
if(g_console.overscan_enable) if (g_console.overscan_enable)
{ {
ortho->left = -g_console.overscan_amount/2; ortho->left = -g_console.overscan_amount / 2;
ortho->right = 1 + g_console.overscan_amount/2; ortho->right = 1 + g_console.overscan_amount / 2;
ortho->bottom = -g_console.overscan_amount/2; ortho->bottom = -g_console.overscan_amount / 2;
} }
#endif #endif
@ -441,7 +441,7 @@ void gl_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate)
void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate) void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate)
{ {
unsigned vp_x_temp, vp_y_temp, vp_width_temp, vp_height_temp; unsigned vp_x_temp, vp_y_temp, vp_width_temp, vp_height_temp;
ortho_t ortho; struct gl_ortho ortho = {0};
vp_x_temp = 0; vp_x_temp = 0;
vp_y_temp = 0; vp_y_temp = 0;
@ -462,34 +462,36 @@ void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full,
float delta; float delta;
#ifdef RARCH_CONSOLE #ifdef RARCH_CONSOLE
if(g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM) if (g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM)
{ {
delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5; delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5;
vp_x_temp = g_console.viewports.custom_vp.x; vp_x_temp = g_console.viewports.custom_vp.x;
vp_y_temp = g_console.viewports.custom_vp.y; vp_y_temp = g_console.viewports.custom_vp.y;
vp_width_temp = g_console.viewports.custom_vp.width; vp_width_temp = g_console.viewports.custom_vp.width;
vp_height_temp = g_console.viewports.custom_vp.height; vp_height_temp = g_console.viewports.custom_vp.height;
} }
else else
#endif #endif
if (fabs(device_aspect - desired_aspect) < 0.0001)
{ {
// If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff), if (fabs(device_aspect - desired_aspect) < 0.0001)
// assume they are actually equal. {
} // If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff),
else if (device_aspect > desired_aspect) // assume they are actually equal.
{ }
delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5; else if (device_aspect > desired_aspect)
vp_x_temp = (GLint)(width * (0.5 - delta)); {
vp_width_temp = (GLint)(2.0 * width * delta); delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5;
width = (unsigned)(2.0 * width * delta); vp_x_temp = (GLint)(width * (0.5 - delta));
} vp_width_temp = (GLint)(2.0 * width * delta);
else width = (unsigned)(2.0 * width * delta);
{ }
delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5; else
vp_y_temp = (GLint)(height * (0.5 - delta)); {
vp_height_temp = (GLint)(2.0 * height * delta); delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5;
height = (unsigned)(2.0 * height * delta); vp_y_temp = (GLint)(height * (0.5 - delta));
vp_height_temp = (GLint)(2.0 * height * delta);
height = (unsigned)(2.0 * height * delta);
}
} }
} }
@ -512,7 +514,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)
{ {
ortho_t ortho; struct gl_ortho ortho = {0};
ortho.left = 0; ortho.left = 0;
ortho.right = 1; ortho.right = 1;
@ -521,7 +523,7 @@ static void gl_set_rotation(void *data, unsigned rotation)
ortho.near = -1; ortho.near = -1;
ortho.far = 1; ortho.far = 1;
gl_t * gl = driver.video_data; gl_t *gl = (gl_t*)driver.video_data;
gl->rotation = 90 * rotation; gl->rotation = 90 * rotation;
gl_set_projection(gl, &ortho, true); gl_set_projection(gl, &ortho, true);
} }
@ -943,7 +945,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
gfx_ctx_update_window_title(false); gfx_ctx_update_window_title(false);
#ifdef RARCH_CONSOLE #ifdef RARCH_CONSOLE
if(!gl->block_swap) if (!gl->block_swap)
#endif #endif
gfx_ctx_swap_buffers(); gfx_ctx_swap_buffers();
@ -1237,7 +1239,7 @@ static void gl_start(void)
video_info.smooth = g_settings.video.smooth; video_info.smooth = g_settings.video.smooth;
video_info.input_scale = 2; video_info.input_scale = 2;
video_info.fullscreen = true; video_info.fullscreen = true;
if(g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM) if (g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM)
{ {
video_info.width = g_console.viewports.custom_vp.width; video_info.width = g_console.viewports.custom_vp.width;
video_info.height = g_console.viewports.custom_vp.height; video_info.height = g_console.viewports.custom_vp.height;
@ -1264,9 +1266,9 @@ static void gl_stop(void)
static void gl_restart(void) static void gl_restart(void)
{ {
gl_t * gl = driver.video_data; gl_t *gl = driver.video_data;
if(!gl) if (!gl)
return; return;
gl_stop(); gl_stop();

View File

@ -107,15 +107,15 @@ struct gl_fbo_scale
bool valid; bool valid;
}; };
typedef struct struct gl_ortho
{ {
float left; GLfloat left;
float right; GLfloat right;
float bottom; GLfloat bottom;
float top; GLfloat top;
float near; GLfloat near;
float far; GLfloat far;
} ortho_t; };
struct gl_tex_info struct gl_tex_info
{ {
@ -222,7 +222,7 @@ extern PFNGLACTIVETEXTUREPROC pglActiveTexture;
#endif #endif
void gl_shader_use(unsigned index); void gl_shader_use(unsigned index);
void gl_set_projection(gl_t *gl, ortho_t *ortho, bool allow_rotate); void gl_set_projection(gl_t *gl, struct gl_ortho *ortho, bool allow_rotate);
void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate); void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate);
#endif #endif