本文整理汇总了C++中RARCH_LOG函数的典型用法代码示例。如果您正苦于以下问题:C++ RARCH_LOG函数的具体用法?C++ RARCH_LOG怎么用?C++ RARCH_LOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RARCH_LOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gfx_ctx_init
static bool gfx_ctx_init(void)
{
struct android_app *android_app = (struct android_app*)g_android;
const EGLint attribs[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_NONE
};
EGLint num_config;
EGLint egl_version_major, egl_version_minor;
EGLint format;
EGLint context_attributes[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
RARCH_LOG("Initializing context\n");
if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
{
RARCH_ERR("eglGetDisplay failed.\n");
goto error;
}
if (!eglInitialize(g_egl_dpy, &egl_version_major, &egl_version_minor))
{
RARCH_ERR("eglInitialize failed.\n");
goto error;
}
RARCH_LOG("[ANDROID/EGL]: EGL version: %d.%d\n", egl_version_major, egl_version_minor);
if (!eglChooseConfig(g_egl_dpy, attribs, &g_config, 1, &num_config))
{
RARCH_ERR("eglChooseConfig failed.\n");
goto error;
}
int var = eglGetConfigAttrib(g_egl_dpy, g_config, EGL_NATIVE_VISUAL_ID, &format);
if (!var)
{
RARCH_ERR("eglGetConfigAttrib failed: %d.\n", var);
goto error;
}
ANativeWindow_setBuffersGeometry(android_app->window, 0, 0, format);
if (!(g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, android_app->window, 0)))
{
RARCH_ERR("eglCreateWindowSurface failed.\n");
goto error;
}
if (!(g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, 0, context_attributes)))
{
RARCH_ERR("eglCreateContext failed.\n");
goto error;
}
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
{
RARCH_ERR("eglMakeCurrent failed.\n");
goto error;
}
ALooper *looper = ALooper_forThread();
if (!looper)
ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
return true;
error:
RARCH_ERR("EGL error: %d.\n", eglGetError());
gfx_ctx_destroy();
return false;
}
示例2: config_get_ptr
static void *gdi_gfx_init(const video_info_t *video,
const input_driver_t **input, void **input_data)
{
unsigned full_x, full_y;
gfx_ctx_input_t inp;
gfx_ctx_mode_t mode;
const gfx_ctx_driver_t *ctx_driver = NULL;
unsigned win_width = 0, win_height = 0;
unsigned temp_width = 0, temp_height = 0;
settings_t *settings = config_get_ptr();
gdi_t *gdi = (gdi_t*)calloc(1, sizeof(*gdi));
*input = NULL;
*input_data = NULL;
gdi_video_width = video->width;
gdi_video_height = video->height;
gdi_rgb32 = video->rgb32;
gdi_video_bits = video->rgb32 ? 32 : 16;
if (video->rgb32)
gdi_video_pitch = video->width * 4;
else
gdi_video_pitch = video->width * 2;
gdi_gfx_create();
ctx_driver = video_context_driver_init_first(gdi,
settings->video.context_driver,
GFX_CTX_GDI_API, 1, 0, false);
if (!ctx_driver)
goto error;
video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver);
RARCH_LOG("Found GDI context: %s\n", ctx_driver->ident);
video_context_driver_get_video_size(&mode);
full_x = mode.width;
full_y = mode.height;
mode.width = 0;
mode.height = 0;
RARCH_LOG("Detecting screen resolution %ux%u.\n", full_x, full_y);
win_width = video->width;
win_height = video->height;
if (video->fullscreen && (win_width == 0) && (win_height == 0))
{
win_width = full_x;
win_height = full_y;
}
mode.width = win_width;
mode.height = win_height;
mode.fullscreen = video->fullscreen;
if (!video_context_driver_set_video_mode(&mode))
goto error;
mode.width = 0;
mode.height = 0;
video_context_driver_get_video_size(&mode);
temp_width = mode.width;
temp_height = mode.height;
mode.width = 0;
mode.height = 0;
/* Get real known video size, which might have been altered by context. */
if (temp_width != 0 && temp_height != 0)
video_driver_set_size(&temp_width, &temp_height);
video_driver_get_size(&temp_width, &temp_height);
RARCH_LOG("GDI: Using resolution %ux%u\n", temp_width, temp_height);
inp.input = input;
inp.input_data = input_data;
video_context_driver_input_driver(&inp);
if (settings->video.font_enable)
font_driver_init_osd(NULL, false, FONT_DRIVER_RENDER_GDI);
RARCH_LOG("[GDI]: Init complete.\n");
return gdi;
error:
video_context_driver_destroy();
if (gdi)
free(gdi);
return NULL;
}
示例3: recording_init
/**
* recording_init:
*
* Initializes recording.
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool recording_init(void)
{
char recording_file[PATH_MAX_LENGTH] = {0};
struct ffemu_params params = {0};
global_t *global = global_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
const struct retro_hw_render_callback *hw_render =
(const struct retro_hw_render_callback*)video_driver_callback();
bool *recording_enabled = recording_is_enabled();
if (!*recording_enabled)
return false;
if (global->inited.core.type == CORE_TYPE_DUMMY)
{
RARCH_WARN("%s\n", msg_hash_to_str(MSG_USING_LIBRETRO_DUMMY_CORE_RECORDING_SKIPPED));
return false;
}
if (!settings->video.gpu_record && hw_render->context_type)
{
RARCH_WARN("%s.\n", msg_hash_to_str(MSG_HW_RENDERED_MUST_USE_POSTSHADED_RECORDING));
return false;
}
RARCH_LOG("%s: FPS: %.4f, Sample rate: %.4f\n",
msg_hash_to_str(MSG_CUSTOM_TIMING_GIVEN),
(float)av_info->timing.fps,
(float)av_info->timing.sample_rate);
strlcpy(recording_file, global->record.path, sizeof(recording_file));
if (global->record.use_output_dir)
fill_pathname_join(recording_file,
global->record.output_dir,
global->record.path, sizeof(recording_file));
params.out_width = av_info->geometry.base_width;
params.out_height = av_info->geometry.base_height;
params.fb_width = av_info->geometry.max_width;
params.fb_height = av_info->geometry.max_height;
params.channels = 2;
params.filename = recording_file;
params.fps = av_info->timing.fps;
params.samplerate = av_info->timing.sample_rate;
params.pix_fmt = (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) ?
FFEMU_PIX_ARGB8888 : FFEMU_PIX_RGB565;
params.config = NULL;
if (*global->record.config)
params.config = global->record.config;
if (settings->video.gpu_record && driver->video->read_viewport)
{
struct video_viewport vp = {0};
video_driver_viewport_info(&vp);
if (!vp.width || !vp.height)
{
RARCH_ERR("Failed to get viewport information from video driver. "
"Cannot start recording ...\n");
return false;
}
params.out_width = vp.width;
params.out_height = vp.height;
params.fb_width = next_pow2(vp.width);
params.fb_height = next_pow2(vp.height);
if (settings->video.force_aspect &&
(video_driver_get_aspect_ratio() > 0.0f))
params.aspect_ratio = video_driver_get_aspect_ratio();
else
params.aspect_ratio = (float)vp.width / vp.height;
params.pix_fmt = FFEMU_PIX_BGR24;
global->record.gpu_width = vp.width;
global->record.gpu_height = vp.height;
RARCH_LOG("%s %u x %u\n", msg_hash_to_str(MSG_DETECTED_VIEWPORT_OF),
vp.width, vp.height);
global->record.gpu_buffer = (uint8_t*)malloc(vp.width * vp.height * 3);
if (!global->record.gpu_buffer)
return false;
}
else
{
if (global->record.width || global->record.height)
{
//.........这里部分代码省略.........
示例4: get_xml_shaders
static unsigned get_xml_shaders(const char *path, struct shader_program *prog, size_t size)
{
LIBXML_TEST_VERSION;
xmlParserCtxtPtr ctx = xmlNewParserCtxt();
if (!ctx)
{
RARCH_ERR("Failed to load libxml2 context.\n");
return false;
}
RARCH_LOG("Loading XML shader: %s\n", path);
xmlDocPtr doc = xmlCtxtReadFile(ctx, path, NULL, 0);
xmlNodePtr head = NULL;
xmlNodePtr cur = NULL;
unsigned num = 0;
if (!doc)
{
RARCH_ERR("Failed to parse XML file: %s\n", path);
goto error;
}
if (ctx->valid == 0)
{
RARCH_ERR("Cannot validate XML shader: %s\n", path);
goto error;
}
head = xmlDocGetRootElement(doc);
for (cur = head; cur; cur = cur->next)
{
if (cur->type != XML_ELEMENT_NODE)
continue;
if (strcmp((const char*)cur->name, "shader") != 0)
continue;
char attr[64];
xml_get_prop(attr, sizeof(attr), cur, "language");
if (strcmp(attr, "GLSL") != 0)
continue;
xml_get_prop(attr, sizeof(attr), cur, "style");
glsl_modern = strcmp(attr, "GLES2") == 0;
if (glsl_modern)
RARCH_LOG("[GL]: Shader reports a GLES2 style shader.\n");
break;
}
if (!cur) // We couldn't find any GLSL shader :(
goto error;
memset(prog, 0, sizeof(struct shader_program) * size);
// Iterate to check if we find fragment and/or vertex shaders.
for (cur = cur->children; cur && num < size; cur = cur->next)
{
if (cur->type != XML_ELEMENT_NODE)
continue;
char *content = xml_get_content(cur);
if (!content)
continue;
if (strcmp((const char*)cur->name, "vertex") == 0)
{
if (prog[num].vertex)
{
RARCH_ERR("Cannot have more than one vertex shader in a program.\n");
free(content);
goto error;
}
content = xml_replace_if_file(content, path, cur, "src");
if (!content)
{
RARCH_ERR("Shader source file was provided, but failed to read.\n");
goto error;
}
prog[num].vertex = content;
}
else if (strcmp((const char*)cur->name, "fragment") == 0)
{
if (glsl_modern && !prog[num].vertex)
{
RARCH_ERR("Modern GLSL was chosen and vertex shader was not provided. This is an error.\n");
free(content);
goto error;
}
content = xml_replace_if_file(content, path, cur, "src");
if (!content)
{
RARCH_ERR("Shader source file was provided, but failed to read.\n");
goto error;
}
//.........这里部分代码省略.........
示例5: xdk_d3d_reinit_textures
static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
HRESULT ret;
if (driver.video_data)
{
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
// Reinitialize textures as we might have changed pixel formats.
xdk_d3d_reinit_textures(d3d, video);
return driver.video_data;
}
//we'll just use driver.video_data throughout here because it needs to
//exist when we delegate initing to the context file
driver.video_data = (xdk_d3d_video_t*)calloc(1, sizeof(xdk_d3d_video_t));
if (!driver.video_data)
return NULL;
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
d3d->vsync = video->vsync;
d3d->tex_w = RARCH_SCALE_BASE * video->input_scale;
d3d->tex_h = RARCH_SCALE_BASE * video->input_scale;
#if defined(_XBOX1)
d3d->ctx_driver = gfx_ctx_init_first(GFX_CTX_DIRECT3D8_API, 8, 0);
#elif defined(_XBOX360)
d3d->ctx_driver = gfx_ctx_init_first(GFX_CTX_DIRECT3D9_API, 9, 0);
#endif
if (d3d->ctx_driver)
{
D3DPRESENT_PARAMETERS d3dpp;
xdk_d3d_generate_pp(&d3dpp, video);
ret = d3d->d3d_device->CreateDevice(0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &d3d->d3d_render_device);
if (ret != S_OK)
RARCH_ERR("Failed at CreateDevice.\n");
RD3DDevice_Clear(d3d->d3d_render_device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
}
else
{
free(d3d);
return NULL;
}
RARCH_LOG("Found D3D context: %s\n", d3d->ctx_driver->ident);
xdk_d3d_init_textures(d3d, video);
#if defined(_XBOX1)
// use an orthogonal matrix for the projection matrix
D3DXMATRIX mat;
D3DXMatrixOrthoOffCenterLH(&mat, 0, d3d->win_width , d3d->win_height , 0, 0.0f, 1.0f);
d3d->d3d_render_device->SetTransform(D3DTS_PROJECTION, &mat);
// use an identity matrix for the world and view matrices
D3DXMatrixIdentity(&mat);
d3d->d3d_render_device->SetTransform(D3DTS_WORLD, &mat);
d3d->d3d_render_device->SetTransform(D3DTS_VIEW, &mat);
ret = d3d->d3d_render_device->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats),
D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &d3d->vertex_buf);
if (ret != S_OK)
{
RARCH_ERR("[xdk_d3d_init::] Failed at CreateVertexBuffer.\n");
return NULL;
}
const DrawVerticeFormats init_verts[] = {
{ -1.0f, -1.0f, 1.0f, 0.0f, 1.0f },
{ 1.0f, -1.0f, 1.0f, 1.0f, 1.0f },
{ -1.0f, 1.0f, 1.0f, 0.0f, 0.0f },
{ 1.0f, 1.0f, 1.0f, 1.0f, 0.0f },
};
BYTE *verts_ptr;
RD3DVertexBuffer_Lock(d3d->vertex_buf, 0, 0, &verts_ptr, 0);
memcpy(verts_ptr, init_verts, sizeof(init_verts));
RD3DVertexBuffer_Unlock(d3d->vertex_buf);
RD3DDevice_SetVertexShader(d3d->d3d_render_device, D3DFVF_XYZ | D3DFVF_TEX1);
#elif defined(_XBOX360)
ret = d3d->d3d_render_device->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats),
0, 0, 0, &d3d->vertex_buf, NULL);
if (ret != S_OK)
{
RARCH_ERR("[xdk_d3d_init::] Failed at CreateVertexBuffer.\n");
return NULL;
}
static const DrawVerticeFormats init_verts[] = {
{ -1.0f, -1.0f, 0.0f, 1.0f },
{ 1.0f, -1.0f, 1.0f, 1.0f },
{ -1.0f, 1.0f, 0.0f, 0.0f },
{ 1.0f, 1.0f, 1.0f, 0.0f },
//.........这里部分代码省略.........
示例6: environment_cb
static bool environment_cb(unsigned cmd, void *data)
{
switch (cmd)
{
case RETRO_ENVIRONMENT_GET_OVERSCAN:
*(bool*)data = !g_settings.video.crop_overscan;
RARCH_LOG("Environ GET_OVERSCAN: %u\n", (unsigned)!g_settings.video.crop_overscan);
break;
case RETRO_ENVIRONMENT_GET_CAN_DUPE:
*(bool*)data = true;
RARCH_LOG("Environ GET_CAN_DUPE: true\n");
break;
case RETRO_ENVIRONMENT_GET_VARIABLE:
{
struct retro_variable *var = (struct retro_variable*)data;
RARCH_LOG("Environ GET_VARIABLE %s:\n", var->key);
if (g_extern.system.core_options)
core_option_get(g_extern.system.core_options, var);
else
var->value = NULL;
RARCH_LOG("\t%s\n", var->value ? var->value : "N/A");
break;
}
case RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE:
*(bool*)data = g_extern.system.core_options ?
core_option_updated(g_extern.system.core_options) : false;
break;
case RETRO_ENVIRONMENT_SET_VARIABLES:
{
RARCH_LOG("Environ SET_VARIABLES.\n");
if (g_extern.system.core_options)
{
core_option_flush(g_extern.system.core_options);
core_option_free(g_extern.system.core_options);
}
const struct retro_variable *vars = (const struct retro_variable*)data;
const char *options_path = g_settings.core_options_path;
char buf[PATH_MAX];
if (!*options_path && *g_extern.config_path)
{
fill_pathname_resolve_relative(buf, g_extern.config_path, ".retroarch-core-options.cfg", sizeof(buf));
options_path = buf;
}
g_extern.system.core_options = core_option_new(options_path, vars);
break;
}
case RETRO_ENVIRONMENT_SET_MESSAGE:
{
const struct retro_message *msg = (const struct retro_message*)data;
RARCH_LOG("Environ SET_MESSAGE: %s\n", msg->msg);
if (g_extern.msg_queue)
msg_queue_push(g_extern.msg_queue, msg->msg, 1, msg->frames);
break;
}
case RETRO_ENVIRONMENT_SET_ROTATION:
{
unsigned rotation = *(const unsigned*)data;
RARCH_LOG("Environ SET_ROTATION: %u\n", rotation);
if (!g_settings.video.allow_rotate)
break;
g_extern.system.rotation = rotation;
if (driver.video && driver.video->set_rotation)
{
if (driver.video_data)
video_set_rotation_func(rotation);
}
else
return false;
break;
}
case RETRO_ENVIRONMENT_SHUTDOWN:
RARCH_LOG("Environ SHUTDOWN.\n");
g_extern.system.shutdown = true;
break;
case RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL:
g_extern.system.performance_level = *(const unsigned*)data;
RARCH_LOG("Environ PERFORMANCE_LEVEL: %u.\n", g_extern.system.performance_level);
break;
case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
*(const char **)data = *g_settings.system_directory ? g_settings.system_directory : NULL;
RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n", g_settings.system_directory);
break;
//.........这里部分代码省略.........
示例7: get_xml_attrs
static bool get_xml_attrs(struct shader_program *prog, xmlNodePtr ptr)
{
prog->scale_x = 1.0;
prog->scale_y = 1.0;
prog->type_x = prog->type_y = RARCH_SCALE_INPUT;
prog->valid_scale = false;
// Check if shader forces a certain texture filtering.
char attr[64];
if (xml_get_prop(attr, sizeof(attr), ptr, "filter"))
{
if (strcmp(attr, "nearest") == 0)
{
prog->filter = RARCH_GL_NEAREST;
RARCH_LOG("XML: Shader forces GL_NEAREST.\n");
}
else if (strcmp(attr, "linear") == 0)
{
prog->filter = RARCH_GL_LINEAR;
RARCH_LOG("XML: Shader forces GL_LINEAR.\n");
}
else
RARCH_WARN("XML: Invalid property for filter.\n");
}
else
prog->filter = RARCH_GL_NOFORCE;
// Check for scaling attributes *lots of code <_<*
char attr_scale[64], attr_scale_x[64], attr_scale_y[64];
char attr_size[64], attr_size_x[64], attr_size_y[64];
char attr_outscale[64], attr_outscale_x[64], attr_outscale_y[64];
xml_get_prop(attr_scale, sizeof(attr_scale), ptr, "scale");
xml_get_prop(attr_scale_x, sizeof(attr_scale_x), ptr, "scale_x");
xml_get_prop(attr_scale_y, sizeof(attr_scale_y), ptr, "scale_y");
xml_get_prop(attr_size, sizeof(attr_size), ptr, "size");
xml_get_prop(attr_size_x, sizeof(attr_size_x), ptr, "size_x");
xml_get_prop(attr_size_y, sizeof(attr_size_y), ptr, "size_y");
xml_get_prop(attr_outscale, sizeof(attr_outscale), ptr, "outscale");
xml_get_prop(attr_outscale_x, sizeof(attr_outscale_x), ptr, "outscale_x");
xml_get_prop(attr_outscale_y, sizeof(attr_outscale_y), ptr, "outscale_y");
unsigned x_attr_cnt = 0, y_attr_cnt = 0;
if (*attr_scale)
{
float scale = strtod(attr_scale, NULL);
prog->scale_x = scale;
prog->scale_y = scale;
prog->valid_scale = true;
prog->type_x = prog->type_y = RARCH_SCALE_INPUT;
RARCH_LOG("Got scale attr: %.1f\n", scale);
x_attr_cnt++;
y_attr_cnt++;
}
if (*attr_scale_x)
{
float scale = strtod(attr_scale_x, NULL);
prog->scale_x = scale;
prog->valid_scale = true;
prog->type_x = RARCH_SCALE_INPUT;
RARCH_LOG("Got scale_x attr: %.1f\n", scale);
x_attr_cnt++;
}
if (*attr_scale_y)
{
float scale = strtod(attr_scale_y, NULL);
prog->scale_y = scale;
prog->valid_scale = true;
prog->type_y = RARCH_SCALE_INPUT;
RARCH_LOG("Got scale_y attr: %.1f\n", scale);
y_attr_cnt++;
}
if (*attr_size)
{
prog->abs_x = prog->abs_y = strtoul(attr_size, NULL, 0);
prog->valid_scale = true;
prog->type_x = prog->type_y = RARCH_SCALE_ABSOLUTE;
RARCH_LOG("Got size attr: %u\n", prog->abs_x);
x_attr_cnt++;
y_attr_cnt++;
}
if (*attr_size_x)
{
prog->abs_x = strtoul(attr_size_x, NULL, 0);
prog->valid_scale = true;
prog->type_x = RARCH_SCALE_ABSOLUTE;
RARCH_LOG("Got size_x attr: %u\n", prog->abs_x);
x_attr_cnt++;
}
if (*attr_size_y)
{
prog->abs_y = strtoul(attr_size_y, NULL, 0);
prog->valid_scale = true;
prog->type_y = RARCH_SCALE_ABSOLUTE;
//.........这里部分代码省略.........
示例8: gfx_ctx_ps3_init
static bool gfx_ctx_ps3_init(void *data)
{
gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)
calloc(1, sizeof(gfx_ctx_ps3_data_t));
(void)data;
if (!ps3)
return false;
#if defined(HAVE_PSGL)
PSGLinitOptions options = {
.enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS,
.maxSPUs = 1,
.initializeSPUs = GL_FALSE,
};
/* Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL. */
sys_spu_initialize(6, 1);
psglInit(&options);
PSGLdeviceParameters params;
params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT |
PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT |
PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE;
params.colorFormat = GL_ARGB_SCE;
params.depthFormat = GL_NONE;
params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE;
if (g_extern.console.screen.resolutions.current.id)
{
params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT;
params.width = gfx_ctx_ps3_get_resolution_width(g_extern.console.screen.resolutions.current.id);
params.height = gfx_ctx_ps3_get_resolution_height(g_extern.console.screen.resolutions.current.id);
g_extern.console.screen.pal_enable = false;
if (params.width == 720 && params.height == 576)
{
RARCH_LOG("[PSGL Context]: 720x576 resolution detected, setting MODE_VIDEO_PAL_ENABLE.\n");
g_extern.console.screen.pal_enable = true;
}
}
if (g_extern.console.screen.pal60_enable)
{
RARCH_LOG("[PSGL Context]: Setting temporal PAL60 mode.\n");
params.enable |= PSGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE;
params.enable |= PSGL_DEVICE_PARAMETERS_RESC_RATIO_MODE;
params.rescPalTemporalMode = RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE;
params.rescRatioMode = RESC_RATIO_MODE_FULLSCREEN;
}
ps3->gl_device = psglCreateDeviceExtended(¶ms);
ps3->gl_context = psglCreateContext();
psglMakeCurrent(ps3->gl_context, ps3->gl_device);
psglResetCurrentContext();
#endif
g_extern.console.screen.pal_enable =
cellVideoOutGetResolutionAvailability(
CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576,
CELL_VIDEO_OUT_ASPECT_AUTO, 0);
gfx_ctx_ps3_get_available_resolutions();
driver.video_context_data = ps3;
return true;
}
static bool gfx_ctx_ps3_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
{
(void)data;
return true;
}
示例9: load_state
bool load_state(const char *path)
{
unsigned i;
void *buf = NULL;
ssize_t size = read_file(path, &buf);
RARCH_LOG("Loading state: \"%s\".\n", path);
if (size < 0)
{
RARCH_ERR("Failed to load state from \"%s\".\n", path);
return false;
}
bool ret = true;
RARCH_LOG("State size: %u bytes.\n", (unsigned)size);
struct sram_block *blocks = NULL;
unsigned num_blocks = 0;
if (g_settings.block_sram_overwrite && g_extern.savefiles
&& g_extern.savefiles->size)
{
RARCH_LOG("Blocking SRAM overwrite.\n");
blocks = (struct sram_block*)
calloc(g_extern.savefiles->size, sizeof(*blocks));
if (blocks)
{
num_blocks = g_extern.savefiles->size;
for (i = 0; i < num_blocks; i++)
blocks[i].type = g_extern.savefiles->elems[i].attr.i;
}
}
for (i = 0; i < num_blocks; i++)
blocks[i].size = pretro_get_memory_size(blocks[i].type);
for (i = 0; i < num_blocks; i++)
if (blocks[i].size)
blocks[i].data = malloc(blocks[i].size);
/* Backup current SRAM which is overwritten by unserialize. */
for (i = 0; i < num_blocks; i++)
{
if (blocks[i].data)
{
const void *ptr = pretro_get_memory_data(blocks[i].type);
if (ptr)
memcpy(blocks[i].data, ptr, blocks[i].size);
}
}
ret = pretro_unserialize(buf, size);
/* Flush back. */
for (i = 0; i < num_blocks; i++)
{
if (blocks[i].data)
{
void *ptr = pretro_get_memory_data(blocks[i].type);
if (ptr)
memcpy(ptr, blocks[i].data, blocks[i].size);
}
}
for (i = 0; i < num_blocks; i++)
free(blocks[i].data);
free(blocks);
return ret;
}
示例10: gfx_ctx_qnx_init
static bool gfx_ctx_qnx_init(void *data)
{
EGLint num_config;
EGLint egl_version_major, egl_version_minor;
EGLint context_attributes[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
const EGLint attribs[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_NONE
};
int angle, size[2];
int usage, format = SCREEN_FORMAT_RGBX8888;
/* Create a screen context that will be used to
* create an EGL surface to receive libscreen events */
RARCH_LOG("Initializing screen context...\n");
if (!screen_ctx)
{
screen_create_context(&screen_ctx, 0);
if (screen_request_events(screen_ctx) != BPS_SUCCESS)
{
RARCH_ERR("screen_request_events failed.\n");
goto screen_error;
}
if (navigator_request_events(0) != BPS_SUCCESS)
{
RARCH_ERR("navigator_request_events failed.\n");
goto screen_error;
}
if (navigator_rotation_lock(false) != BPS_SUCCESS)
{
RARCH_ERR("navigator_location_lock failed.\n");
goto screen_error;
}
}
usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
RARCH_LOG("Initializing context\n");
if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
{
RARCH_ERR("eglGetDisplay failed.\n");
goto error;
}
if (!eglInitialize(g_egl_dpy, &egl_version_major, &egl_version_minor))
{
RARCH_ERR("eglInitialize failed.\n");
goto error;
}
if (!eglBindAPI(EGL_OPENGL_ES_API))
{
RARCH_ERR("eglBindAPI failed.\n");
goto error;
}
RARCH_LOG("[BLACKBERRY QNX/EGL]: EGL version: %d.%d\n", egl_version_major, egl_version_minor);
if (!eglChooseConfig(g_egl_dpy, attribs, &g_config, 1, &num_config))
goto error;
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, context_attributes);
if (g_egl_ctx == EGL_NO_CONTEXT)
goto error;
if (g_use_hw_ctx)
{
g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_config, g_egl_ctx,
context_attributes);
RARCH_LOG("[Android/EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx);
if (g_egl_hw_ctx == EGL_NO_CONTEXT)
goto error;
}
if(!screen_win)
{
if (screen_create_window(&screen_win, screen_ctx))
{
RARCH_ERR("screen_create_window failed:.\n");
goto error;
}
}
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format))
{
RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_FORMAT] failed.\n");
//.........这里部分代码省略.........
示例11: handle_screen_event
static void handle_screen_event(void *data, bps_event_t *event)
{
int type;
qnx_input_t *qnx = (qnx_input_t*)data;
screen_event_t screen_event = screen_event_get_event(event);
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &type);
switch(type)
{
case SCREEN_EVENT_MTOUCH_TOUCH:
case SCREEN_EVENT_MTOUCH_RELEASE:
case SCREEN_EVENT_MTOUCH_MOVE:
process_touch_event(data, screen_event, type);
break;
case SCREEN_EVENT_KEYBOARD:
process_keyboard_event(data, screen_event, type);
break;
#ifdef HAVE_BB10
case SCREEN_EVENT_GAMEPAD:
case SCREEN_EVENT_JOYSTICK:
process_gamepad_event(data, screen_event, type);
break;
case SCREEN_EVENT_DEVICE:
{
// A device was attached or removed.
screen_device_t device;
int attached, type, i;
screen_get_event_property_pv(screen_event,
SCREEN_PROPERTY_DEVICE, (void**)&device);
screen_get_event_property_iv(screen_event,
SCREEN_PROPERTY_ATTACHED, &attached);
if (attached)
screen_get_device_property_iv(device,
SCREEN_PROPERTY_TYPE, &type);
if (attached && (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK || type == SCREEN_EVENT_KEYBOARD))
{
for (i = 0; i < MAX_PADS; ++i)
{
if (!qnx->devices[i].handle)
{
qnx->devices[i].handle = device;
loadController(data, &qnx->devices[i]);
break;
}
}
}
else
{
for (i = 0; i < MAX_PADS; ++i)
{
if (device == qnx->devices[i].handle)
{
RARCH_LOG("Device %s: Disconnected.\n", qnx->devices[i].id);
initController(data, &qnx->devices[i]);
break;
}
}
}
}
break;
#endif
default:
break;
}
}
示例12: RARCH_LOG
rarch_resampler_t *resampler_new(void)
{
RARCH_LOG("Hermite resampler [C]\n");
return (rarch_resampler_t*)calloc(1, sizeof(rarch_resampler_t));
}
示例13: winxinput_joypad_init
static bool winxinput_joypad_init(void)
{
unsigned i, autoconf_pad;
g_winxinput_dll = NULL;
// Find the correct path to load the DLL from.
// Usually this will be from the system directory,
// but occasionally a user may wish to use a third-party
// wrapper DLL (such as x360ce); support these by checking
// the working directory first.
// No need to check for existance as we will be checking LoadLibrary's
// success anyway.
const char *version = "1.4";
g_winxinput_dll = LoadLibrary("xinput1_4.dll"); // Using dylib_* complicates building joyconfig.
if (!g_winxinput_dll)
{
g_winxinput_dll = LoadLibrary("xinput1_3.dll");
version = "1.3";
}
if (!g_winxinput_dll)
{
RARCH_ERR("Failed to load XInput, ensure DirectX and controller drivers are up to date.\n");
return false;
}
RARCH_LOG("Found XInput v%s.\n", version);
// If we get here then an xinput DLL is correctly loaded.
// First try to load ordinal 100 (XInputGetStateEx).
g_XInputGetStateEx = (XInputGetStateEx_t) GetProcAddress(g_winxinput_dll, (const char*)100);
g_winxinput_guide_button_supported = true;
if (!g_XInputGetStateEx)
{
// no ordinal 100. (Presumably a wrapper.) Load the ordinary
// XInputGetState, at the cost of losing guide button support.
g_winxinput_guide_button_supported = false;
g_XInputGetStateEx = (XInputGetStateEx_t) GetProcAddress(g_winxinput_dll, "XInputGetState");
if (!g_XInputGetStateEx)
{
RARCH_ERR("Failed to init XInput: DLL is invalid or corrupt.\n");
FreeLibrary(g_winxinput_dll);
return false; // DLL was loaded but did not contain the correct function.
}
RARCH_WARN("XInput: No guide button support.\n");
}
g_XInputSetState = (XInputSetState_t) GetProcAddress(g_winxinput_dll, "XInputSetState");
if (!g_XInputSetState)
{
RARCH_ERR("Failed to init XInput: DLL is invalid or corrupt.\n");
FreeLibrary(g_winxinput_dll);
return false; // DLL was loaded but did not contain the correct function.
}
// Zero out the states
for (i = 0; i < 4; ++i)
memset(&g_winxinput_states[i], 0, sizeof(winxinput_joypad_state));
// Do a dummy poll to check which controllers are connected.
XINPUT_STATE dummy_state;
for (i = 0; i < 4; ++i)
{
g_winxinput_states[i].connected = !(g_XInputGetStateEx(i, &dummy_state) == ERROR_DEVICE_NOT_CONNECTED);
if (g_winxinput_states[i].connected)
RARCH_LOG("Found XInput controller, player #%u\n", i);
}
if ((!g_winxinput_states[0].connected) &&
(!g_winxinput_states[1].connected) &&
(!g_winxinput_states[2].connected) &&
(!g_winxinput_states[3].connected))
return false;
g_xinput_block_pads = true;
// We're going to have to be buddies with dinput if we want to be able
// to use XI and non-XI controllers together.
if (!dinput_joypad.init())
{
g_xinput_block_pads = false;
return false;
}
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
{
if (pad_index_to_xplayer_index(autoconf_pad) > -1)
{
strlcpy(g_settings.input.device_names[autoconf_pad], winxinput_joypad_name(autoconf_pad), sizeof(g_settings.input.device_names[autoconf_pad]));
input_config_autoconfigure_joypad(autoconf_pad, winxinput_joypad_name(autoconf_pad), winxinput_joypad.ident);
}
}
return true;
}
示例14: sizeof
static void *alsa_thread_init(const char *device,
unsigned rate, unsigned latency)
{
alsa_thread_t *alsa = (alsa_thread_t*)calloc(1, sizeof(alsa_thread_t));
snd_pcm_hw_params_t *params = NULL;
snd_pcm_sw_params_t *sw_params = NULL;
const char *alsa_dev = device ? device : "default";
unsigned latency_usec = latency * 1000 / 2;
unsigned channels = 2;
unsigned periods = 4;
snd_pcm_uframes_t buffer_size;
snd_pcm_format_t format;
if (!alsa)
return NULL;
TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, 0));
TRY_ALSA(snd_pcm_hw_params_malloc(¶ms));
alsa->has_float = alsathread_find_float_format(alsa->pcm, params);
format = alsa->has_float ? SND_PCM_FORMAT_FLOAT : SND_PCM_FORMAT_S16;
TRY_ALSA(snd_pcm_hw_params_any(alsa->pcm, params));
TRY_ALSA(snd_pcm_hw_params_set_access(
alsa->pcm, params, SND_PCM_ACCESS_RW_INTERLEAVED));
TRY_ALSA(snd_pcm_hw_params_set_format(alsa->pcm, params, format));
TRY_ALSA(snd_pcm_hw_params_set_channels(alsa->pcm, params, channels));
TRY_ALSA(snd_pcm_hw_params_set_rate(alsa->pcm, params, rate, 0));
TRY_ALSA(snd_pcm_hw_params_set_buffer_time_near(
alsa->pcm, params, &latency_usec, NULL));
TRY_ALSA(snd_pcm_hw_params_set_periods_near(
alsa->pcm, params, &periods, NULL));
TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params));
/* Shouldn't have to bother with this,
* but some drivers are apparently broken. */
if (snd_pcm_hw_params_get_period_size(params, &alsa->period_frames, NULL))
snd_pcm_hw_params_get_period_size_min(
params, &alsa->period_frames, NULL);
RARCH_LOG("ALSA: Period size: %d frames\n", (int)alsa->period_frames);
if (snd_pcm_hw_params_get_buffer_size(params, &buffer_size))
snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size);
RARCH_LOG("ALSA: Buffer size: %d frames\n", (int)buffer_size);
alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size);
alsa->period_size = snd_pcm_frames_to_bytes(alsa->pcm, alsa->period_frames);
TRY_ALSA(snd_pcm_sw_params_malloc(&sw_params));
TRY_ALSA(snd_pcm_sw_params_current(alsa->pcm, sw_params));
TRY_ALSA(snd_pcm_sw_params_set_start_threshold(
alsa->pcm, sw_params, buffer_size / 2));
TRY_ALSA(snd_pcm_sw_params(alsa->pcm, sw_params));
snd_pcm_hw_params_free(params);
snd_pcm_sw_params_free(sw_params);
alsa->fifo_lock = slock_new();
alsa->cond_lock = slock_new();
alsa->cond = scond_new();
alsa->buffer = fifo_new(alsa->buffer_size);
if (!alsa->fifo_lock || !alsa->cond_lock || !alsa->cond || !alsa->buffer)
goto error;
alsa->worker_thread = sthread_create(alsa_worker_thread, alsa);
if (!alsa->worker_thread)
{
RARCH_ERR("error initializing worker thread");
goto error;
}
return alsa;
error:
RARCH_ERR("ALSA: Failed to initialize...\n");
if (params)
snd_pcm_hw_params_free(params);
if (sw_params)
snd_pcm_sw_params_free(sw_params);
alsa_thread_free(alsa);
return NULL;
}
示例15: create_softfilter_graph
static bool create_softfilter_graph(rarch_softfilter_t *filt,
enum retro_pixel_format in_pixel_format,
unsigned max_width, unsigned max_height,
softfilter_simd_mask_t cpu_features,
unsigned threads)
{
unsigned input_fmts, input_fmt, output_fmts, i = 0;
struct config_file_userdata userdata;
char key[64], name[64];
(void)i;
key[0] = name[0] = '\0';
snprintf(key, sizeof(key), "filter");
if (!config_get_array(filt->conf, key, name, sizeof(name)))
{
RARCH_ERR("Could not find 'filter' array in config.\n");
return false;
}
if (filt->num_plugs == 0)
{
RARCH_ERR("No filter plugs found. Exiting...\n");
return false;
}
filt->impl = softfilter_find_implementation(filt, name);
if (!filt->impl)
{
RARCH_ERR("Could not find implementation.\n");
return false;
}
userdata.conf = filt->conf;
/* Index-specific configs take priority over ident-specific. */
userdata.prefix[0] = key;
userdata.prefix[1] = filt->impl->short_ident;
/* Simple assumptions. */
filt->pix_fmt = in_pixel_format;
input_fmts = filt->impl->query_input_formats();
switch (in_pixel_format)
{
case RETRO_PIXEL_FORMAT_XRGB8888:
input_fmt = SOFTFILTER_FMT_XRGB8888;
break;
case RETRO_PIXEL_FORMAT_RGB565:
input_fmt = SOFTFILTER_FMT_RGB565;
break;
default:
return false;
}
if (!(input_fmt & input_fmts))
{
RARCH_ERR("Softfilter does not support input format.\n");
return false;
}
output_fmts = filt->impl->query_output_formats(input_fmt);
/* If we have a match of input/output formats, use that. */
if (output_fmts & input_fmt)
filt->out_pix_fmt = in_pixel_format;
else if (output_fmts & SOFTFILTER_FMT_XRGB8888)
filt->out_pix_fmt = RETRO_PIXEL_FORMAT_XRGB8888;
else if (output_fmts & SOFTFILTER_FMT_RGB565)
filt->out_pix_fmt = RETRO_PIXEL_FORMAT_RGB565;
else
{
RARCH_ERR("Did not find suitable output format for softfilter.\n");
return false;
}
filt->max_width = max_width;
filt->max_height = max_height;
filt->impl_data = filt->impl->create(
&softfilter_config, input_fmt, input_fmt, max_width, max_height,
threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads :
cpu_features_get_core_amount(), cpu_features,
&userdata);
if (!filt->impl_data)
{
RARCH_ERR("Failed to create softfilter state.\n");
return false;
}
threads = filt->impl->query_num_threads(filt->impl_data);
if (!threads)
{
RARCH_ERR("Invalid number of threads.\n");
return false;
}
filt->threads = threads;
RARCH_LOG("Using %u threads for softfilter.\n", threads);
//.........这里部分代码省略.........