GL totally abstracted away now from menu drivers

This commit is contained in:
twinaphex 2015-11-02 20:41:42 +01:00
parent ecffd040e2
commit 71ca469cda
9 changed files with 70 additions and 66 deletions

View File

@ -14,8 +14,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_SETTINGS_H__
#define __RARCH_SETTINGS_H__
#ifndef __RARCH_CONFIGURATION_H__
#define __RARCH_CONFIGURATION_H__
#include <stdint.h>
#include <retro_miscellaneous.h>

View File

@ -14,8 +14,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DRIVER__H
#define __DRIVER__H
#ifndef __RARCH_DRIVER__H
#define __RARCH_DRIVER__H
#include <sys/types.h>
#include <boolean.h>

View File

@ -705,7 +705,7 @@ static void glui_frame(void)
if (libretro_running)
{
menu_display_frame_background(menu, settings,
menu_display_frame_background(
width, height,
glui->textures.white, 0.75f, false,
&white_transp_bg[0], &white_bg[0],
@ -727,7 +727,7 @@ static void glui_frame(void)
white_transp_bg[11] = 0.30;
white_transp_bg[15] = 0.30;
menu_display_frame_background(menu, settings,
menu_display_frame_background(
width, height,
glui->textures.bg.id, 0.75f, true,
&white_transp_bg[0], &white_bg[0],
@ -977,19 +977,15 @@ static void glui_layout(menu_handle_t *menu, glui_handle_t *glui)
static void *glui_init(void)
{
glui_handle_t *glui = NULL;
const video_driver_t *video_driver = NULL;
menu_handle_t *menu = NULL;
gl_t *gl = (gl_t*)
video_driver_get_ptr(&video_driver);
if (video_driver != &video_gl || !gl)
goto error;
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
menu_handle_t *menu = (menu_handle_t*)
calloc(1, sizeof(*menu));
if (!menu)
goto error;
if (!menu_display_check_compatibility(menu_ctx_glui.type))
goto error;
menu->userdata = (glui_handle_t*)calloc(1, sizeof(glui_handle_t));
if (!menu->userdata)

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "../menu_driver.h"
#include "../menu_display.h"
#include "../menu.h"
#include "../../general.h"

View File

@ -1570,7 +1570,7 @@ static void xmb_frame(void)
coord_color[3] = coord_color[7] = coord_color[11] = coord_color[15] = (0.75f > xmb->alpha) ? xmb->alpha : 0.75f;
coord_color2[3] = coord_color2[7] = coord_color2[11] = coord_color2[15] = xmb->alpha;
menu_display_frame_background(menu, settings,
menu_display_frame_background(
width, height, xmb->textures.bg.id, xmb->alpha, false, &coord_color[0],
&coord_color2[0], &rmb_vertex[0], &rmb_tex_coord[0], 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
@ -1674,7 +1674,7 @@ static void xmb_frame(void)
if (render_background)
{
menu_display_frame_background(menu, settings,
menu_display_frame_background(
width, height,
xmb->textures.bg.id, xmb->alpha, true,
&coord_color[0], &coord_color2[0],
@ -1821,26 +1821,15 @@ static void xmb_layout(menu_handle_t *menu, xmb_handle_t *xmb)
static void *xmb_init(void)
{
unsigned width, height;
menu_handle_t *menu = NULL;
xmb_handle_t *xmb = NULL;
const video_driver_t *video_driver = NULL;
float scale_factor = 1;
gl_t *gl = (gl_t*)
video_driver_get_ptr(&video_driver);
(void)scale_factor;
if (video_driver != &video_gl || !gl)
{
RARCH_ERR("Cannot initialize XMB menu driver: GL video driver is not active.\n");
return NULL;
}
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
if (!menu)
goto error;
if (!menu_display_check_compatibility(menu_ctx_xmb.type))
goto error;
video_driver_get_size(&width, &height);
menu->userdata = (xmb_handle_t*)calloc(1, sizeof(xmb_handle_t));

View File

@ -1065,7 +1065,7 @@ static void zarch_frame(void)
menu_display_blend_end();
menu_display_frame_background(menu, settings,
menu_display_frame_background(
zui->width, zui->height,
zui->textures.bg.id, 0.75f, false,
&coord_color[0], &coord_color2[0],
@ -1083,29 +1083,15 @@ static void *zarch_init(void)
{
int unused;
zui_t *zui = NULL;
const video_driver_t *video_driver = NULL;
menu_handle_t *menu = NULL;
settings_t *settings = config_get_ptr();
gl_t *gl = (gl_t*)
video_driver_get_ptr(&video_driver);
if (video_driver != &video_gl || !gl)
{
RARCH_ERR("Cannot initialize GLUI menu driver: gl video driver is not active.\n");
return NULL;
}
if (settings->menu.mouse.enable)
{
RARCH_WARN("Forcing menu_mouse_enable=false\n");
settings->menu.mouse.enable = false;
}
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
if (!menu)
goto error;
if (!menu_display_check_compatibility(menu_ctx_zarch.type))
goto error;
menu->userdata = (zui_t*)calloc(1, sizeof(zui_t));
if (!menu->userdata)
@ -1113,6 +1099,12 @@ static void *zarch_init(void)
zui = (zui_t*)menu->userdata;
if (settings->menu.mouse.enable)
{
RARCH_WARN("Forcing menu_mouse_enable=false\n");
settings->menu.mouse.enable = false;
}
unused = 1000;
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, &unused);

View File

@ -584,8 +584,6 @@ void menu_display_draw_frame(
}
void menu_display_frame_background(
menu_handle_t *menu,
settings_t *settings,
unsigned width,
unsigned height,
GLuint texture,
@ -599,8 +597,9 @@ void menu_display_frame_background(
enum menu_display_prim_type prim_type)
{
struct gfx_coords coords;
global_t *global = global_get_ptr();
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
if (!gl)
return;
@ -642,6 +641,33 @@ void menu_display_clear_color(float r, float g, float b, float a)
}
#endif
bool menu_display_check_compatibility(enum menu_display_driver_type type)
{
const video_driver_t *video_driver = NULL;
#ifdef HAVE_OPENGL
gl_t *gl = (gl_t*)video_driver_get_ptr(&video_driver);
#endif
switch (type)
{
case MENU_VIDEO_DRIVER_GENERIC:
return true;
case MENU_VIDEO_DRIVER_OPENGL:
#ifdef HAVE_OPENGL
if (video_driver == &video_gl || gl)
return true;
#endif
break;
case MENU_VIDEO_DRIVER_DIRECT3D:
/* TODO/FIXME */
break;
}
RARCH_ERR("Cannot initialize menu driver: video driver of type %d is not active.\n", type);
return false;
}
const char *menu_video_get_ident(void)
{
#ifdef HAVE_THREADS

View File

@ -26,6 +26,13 @@
extern "C" {
#endif
enum menu_display_driver_type
{
MENU_VIDEO_DRIVER_GENERIC = 0,
MENU_VIDEO_DRIVER_OPENGL,
MENU_VIDEO_DRIVER_DIRECT3D
};
enum menu_display_ctl_state
{
MENU_DISPLAY_CTL_SET_VIEWPORT = 0,
@ -107,8 +114,6 @@ void menu_display_blend_begin(void);
void menu_display_blend_end(void);
void menu_display_frame_background(
menu_handle_t *menu,
settings_t *settings,
unsigned width, unsigned height,
GLuint texture,
float handle_alpha,
@ -130,6 +135,8 @@ void menu_display_clear_color(float r, float g, float b, float a);
void menu_display_matrix_4x4_rotate_z(void *data, float rotation,
float scale_x, float scale_y, float scale_z, bool scale_enable);
bool menu_display_check_compatibility(enum menu_display_driver_type type);
const char *menu_video_get_ident(void);
#ifdef __cplusplus

View File

@ -61,13 +61,6 @@ typedef enum
MENU_HELP_LAST
} menu_help_type_t;
typedef enum
{
MENU_VIDEO_DRIVER_GENERIC = 0,
MENU_VIDEO_DRIVER_OPENGL,
MENU_VIDEO_DRIVER_DIRECT3D
} menu_video_driver_type_t;
typedef struct
{
void *userdata;
@ -140,7 +133,7 @@ typedef struct menu_ctx_driver
uint32_t label_hash, uint32_t menu_label_hash);
bool (*load_image)(void *data, menu_image_type_t type);
const char *ident;
menu_video_driver_type_t type;
unsigned type;
int (*environ_cb)(menu_environ_cb_t type, void *data);
int (*pointer_tap)(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs,