|
@@ -433,7 +433,6 @@ static void gl2_set_viewport(gl2_t *gl,
|
|
|
{
|
|
|
float desired_aspect = video_driver_get_aspect_ratio();
|
|
|
|
|
|
-#if defined(HAVE_MENU)
|
|
|
if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
|
|
{
|
|
|
const struct video_viewport *custom = video_viewport_get_custom();
|
|
@@ -444,7 +443,6 @@ static void gl2_set_viewport(gl2_t *gl,
|
|
|
viewport_height = custom->height;
|
|
|
}
|
|
|
else
|
|
|
-#endif
|
|
|
{
|
|
|
float delta;
|
|
|
|
|
@@ -835,7 +833,7 @@ static void gl2_create_fbo_texture(gl2_t *gl,
|
|
|
}
|
|
|
|
|
|
#if !defined(HAVE_OPENGLES2)
|
|
|
- if ( fp_fbo
|
|
|
+ if ( fp_fbo
|
|
|
&& (chain->flags & GL2_CHAIN_FLAG_HAS_FP_FBO))
|
|
|
{
|
|
|
RARCH_LOG("[GL]: FBO pass #%d is floating-point.\n", i);
|
|
@@ -858,7 +856,7 @@ static void gl2_create_fbo_texture(gl2_t *gl,
|
|
|
if (force_srgb_disable)
|
|
|
srgb_fbo = false;
|
|
|
|
|
|
- if ( srgb_fbo
|
|
|
+ if ( srgb_fbo
|
|
|
&& (chain->flags & GL2_CHAIN_FLAG_HAS_SRGB_FBO))
|
|
|
{
|
|
|
RARCH_LOG("[GL]: FBO pass #%d is sRGB.\n", i);
|
|
@@ -868,8 +866,8 @@ static void gl2_create_fbo_texture(gl2_t *gl,
|
|
|
glTexImage2D(GL_TEXTURE_2D,
|
|
|
0, GL_SRGB_ALPHA_EXT,
|
|
|
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
|
|
- (chain->flags & GL2_CHAIN_FLAG_HAS_SRGB_FBO_GLES3)
|
|
|
- ? GL_RGBA
|
|
|
+ (chain->flags & GL2_CHAIN_FLAG_HAS_SRGB_FBO_GLES3)
|
|
|
+ ? GL_RGBA
|
|
|
: GL_SRGB_ALPHA_EXT,
|
|
|
GL_UNSIGNED_BYTE, NULL);
|
|
|
#else
|
|
@@ -1096,7 +1094,7 @@ static void gl2_renderchain_init(
|
|
|
gl2_shader_scale(gl, &scaler, shader_info_num);
|
|
|
|
|
|
/* we always want FBO to be at least initialized on startup for consoles */
|
|
|
- if ( shader_info_num == 1
|
|
|
+ if ( shader_info_num == 1
|
|
|
&& (!(scale.flags & FBO_SCALE_FLAG_VALID)))
|
|
|
return;
|
|
|
|
|
@@ -1747,15 +1745,15 @@ static void gl_load_texture_data(
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
|
|
glTexImage2D(GL_TEXTURE_2D,
|
|
|
0,
|
|
|
- (use_rgba || !rgb32)
|
|
|
- ? GL_RGBA
|
|
|
+ (use_rgba || !rgb32)
|
|
|
+ ? GL_RGBA
|
|
|
: RARCH_GL_INTERNAL_FORMAT32,
|
|
|
width, height, 0,
|
|
|
- (use_rgba || !rgb32)
|
|
|
- ? GL_RGBA
|
|
|
+ (use_rgba || !rgb32)
|
|
|
+ ? GL_RGBA
|
|
|
: RARCH_GL_TEXTURE_TYPE32,
|
|
|
- (rgb32)
|
|
|
- ? RARCH_GL_FORMAT32
|
|
|
+ (rgb32)
|
|
|
+ ? RARCH_GL_FORMAT32
|
|
|
: GL_UNSIGNED_SHORT_4_4_4_4,
|
|
|
frame);
|
|
|
|
|
@@ -1969,7 +1967,7 @@ static void gl2_set_viewport_wrapper(void *data, unsigned viewport_width,
|
|
|
*
|
|
|
* gl2_get_fallback_shader_type(RARCH_SHADER_NONE) returns a default shader type.
|
|
|
* if gl2_get_fallback_shader_type(type) != type, type was not supported.
|
|
|
- *
|
|
|
+ *
|
|
|
* Returns: A supported shader type.
|
|
|
* If RARCH_SHADER_NONE is returned, no shader backend is supported.
|
|
|
**/
|
|
@@ -2242,7 +2240,7 @@ static void gl2_init_textures(gl2_t *gl)
|
|
|
/* GLES is picky about which format we use here.
|
|
|
* Without extensions, we can *only* render to 16-bit FBOs. */
|
|
|
|
|
|
- if ( (gl->flags & GL2_FLAG_HW_RENDER_USE)
|
|
|
+ if ( (gl->flags & GL2_FLAG_HW_RENDER_USE)
|
|
|
&& (gl->base_size == sizeof(uint32_t)))
|
|
|
{
|
|
|
if (gl_check_capability(GL_CAPS_ARGB8))
|
|
@@ -2295,9 +2293,9 @@ static void gl2_set_texture_frame(void *data,
|
|
|
float alpha)
|
|
|
{
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
- enum texture_filter_type
|
|
|
- menu_filter = settings->bools.menu_linear_filter
|
|
|
- ? TEXTURE_FILTER_LINEAR
|
|
|
+ enum texture_filter_type
|
|
|
+ menu_filter = settings->bools.menu_linear_filter
|
|
|
+ ? TEXTURE_FILTER_LINEAR
|
|
|
: TEXTURE_FILTER_NEAREST;
|
|
|
unsigned base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
|
|
gl2_t *gl = (gl2_t*)data;
|
|
@@ -2549,6 +2547,52 @@ static void gl2_pbo_async_readback(gl2_t *gl)
|
|
|
gl2_renderchain_unbind_pbo();
|
|
|
}
|
|
|
|
|
|
+static void gl2_render_background(gl2_t *gl) {
|
|
|
+ GLfloat color[16];
|
|
|
+ unsigned width = gl->video_width;
|
|
|
+ unsigned height = gl->video_height;
|
|
|
+
|
|
|
+ color[ 0] = 1.0f;
|
|
|
+ color[ 1] = 1.0f;
|
|
|
+ color[ 2] = 1.0f;
|
|
|
+ color[ 3] = 1.0f;
|
|
|
+ color[ 4] = 1.0f;
|
|
|
+ color[ 5] = 1.0f;
|
|
|
+ color[ 6] = 1.0f;
|
|
|
+ color[ 7] = 1.0f;
|
|
|
+ color[ 8] = 1.0f;
|
|
|
+ color[ 9] = 1.0f;
|
|
|
+ color[10] = 1.0f;
|
|
|
+ color[11] = 1.0f;
|
|
|
+ color[12] = 1.0f;
|
|
|
+ color[13] = 1.0f;
|
|
|
+ color[14] = 1.0f;
|
|
|
+ color[15] = 1.0f;
|
|
|
+
|
|
|
+ glEnable(GL_BLEND);
|
|
|
+ glViewport(0, 0, width, height);
|
|
|
+
|
|
|
+ gl->shader->use(gl, gl->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
|
|
|
+
|
|
|
+ gl->coords.vertex = vertexes_flipped;
|
|
|
+ gl->coords.tex_coord = tex_coords;
|
|
|
+ gl->coords.color = color;
|
|
|
+ gl->coords.vertices = 4;
|
|
|
+
|
|
|
+ gl->shader->set_coords(gl->shader_data, &gl->coords);
|
|
|
+ gl->shader->set_mvp(gl->shader_data, &gl->mvp_no_rot);
|
|
|
+
|
|
|
+ glBindTexture(GL_TEXTURE_2D, gl->background_texture);
|
|
|
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
+
|
|
|
+ glDisable(GL_BLEND);
|
|
|
+ gl->coords.vertex = gl->vertex_ptr;
|
|
|
+ gl->coords.tex_coord = gl->tex_info.coord;
|
|
|
+ gl->coords.color = gl->white_color_ptr;
|
|
|
+ gl->coords.vertices = 4;
|
|
|
+ glViewport(gl->vp.x, gl->vp.y, gl->vp.width, gl->vp.height);
|
|
|
+}
|
|
|
+
|
|
|
static bool gl2_frame(void *data, const void *frame,
|
|
|
unsigned frame_width, unsigned frame_height,
|
|
|
uint64_t frame_count,
|
|
@@ -2567,7 +2611,7 @@ static bool gl2_frame(void *data, const void *frame,
|
|
|
#ifndef EMSCRIPTEN
|
|
|
unsigned black_frame_insertion = video_info->black_frame_insertion;
|
|
|
#endif
|
|
|
- bool input_driver_nonblock_state = video_info->input_driver_nonblock_state;
|
|
|
+ bool input_driver_nonblock_state = video_info->input_driver_nonblock_state;
|
|
|
bool hard_sync = video_info->hard_sync;
|
|
|
unsigned hard_sync_frames = video_info->hard_sync_frames;
|
|
|
struct font_params *osd_params = (struct font_params*)
|
|
@@ -2588,6 +2632,9 @@ static bool gl2_frame(void *data, const void *frame,
|
|
|
if (!gl)
|
|
|
return false;
|
|
|
|
|
|
+ glClear(GL_COLOR_BUFFER_BIT);
|
|
|
+ gl2_render_background(gl);
|
|
|
+
|
|
|
if (gl->flags & GL2_FLAG_SHARED_CONTEXT_USE)
|
|
|
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
|
|
|
|
@@ -2745,7 +2792,7 @@ static bool gl2_frame(void *data, const void *frame,
|
|
|
SET_TEXTURE_COORDS(feedback_info.coord, xamt, yamt);
|
|
|
}
|
|
|
|
|
|
- glClear(GL_COLOR_BUFFER_BIT);
|
|
|
+// glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
params.data = gl;
|
|
|
params.width = frame_width;
|
|
@@ -2842,9 +2889,9 @@ static bool gl2_frame(void *data, const void *frame,
|
|
|
#endif
|
|
|
gl2_pbo_async_readback(gl);
|
|
|
|
|
|
- if (gl->ctx_driver->swap_buffers)
|
|
|
+ if (gl->ctx_driver->swap_buffers)
|
|
|
gl->ctx_driver->swap_buffers(gl->ctx_data);
|
|
|
-
|
|
|
+
|
|
|
/* Emscripten has to do black frame insertion in its main loop */
|
|
|
#ifndef EMSCRIPTEN
|
|
|
/* Disable BFI during fast forward, slow-motion,
|
|
@@ -2853,7 +2900,7 @@ static bool gl2_frame(void *data, const void *frame,
|
|
|
black_frame_insertion
|
|
|
&& !input_driver_nonblock_state
|
|
|
&& !runloop_is_slowmotion
|
|
|
- && !runloop_is_paused
|
|
|
+ && !runloop_is_paused
|
|
|
&& (!(gl->flags & GL2_FLAG_MENU_TEXTURE_ENABLE)))
|
|
|
{
|
|
|
size_t n;
|
|
@@ -2863,12 +2910,12 @@ static bool gl2_frame(void *data, const void *frame,
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
if (gl->ctx_driver->swap_buffers)
|
|
|
- gl->ctx_driver->swap_buffers(gl->ctx_data);
|
|
|
- }
|
|
|
- }
|
|
|
-#endif
|
|
|
+ gl->ctx_driver->swap_buffers(gl->ctx_data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
- /* check if we are fast forwarding or in menu,
|
|
|
+ /* check if we are fast forwarding or in menu,
|
|
|
* if we are ignore hard sync */
|
|
|
if ( (gl->flags & GL2_FLAG_HAVE_SYNC)
|
|
|
&& hard_sync
|
|
@@ -3352,6 +3399,39 @@ static bool renderchain_gl2_init_first(void **renderchain_handle)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+static bool gl2_load_background(gl2_t *gl) {
|
|
|
+ struct texture_image img;
|
|
|
+ const char *path = "/sdcard/app_main_bg.png";
|
|
|
+
|
|
|
+ img.width = 0;
|
|
|
+ img.height = 0;
|
|
|
+ img.pixels = NULL;
|
|
|
+ img.supports_rgba = video_driver_supports_rgba();
|
|
|
+
|
|
|
+ if (!image_texture_load(&img, path)) {
|
|
|
+ RARCH_ERR("[GL]: Failed to load texture image from: \"%s\".\n",
|
|
|
+ path);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ RARCH_LOG("[GL]: Loaded texture image(%d, %d) from: \"%s\" ...\n",
|
|
|
+ img.width,
|
|
|
+ img.height,
|
|
|
+ path);
|
|
|
+
|
|
|
+ gl_load_texture_data(
|
|
|
+ gl->background_texture,
|
|
|
+ RARCH_WRAP_DEFAULT,
|
|
|
+ TEXTURE_FILTER_LINEAR,
|
|
|
+ 4,
|
|
|
+ img.width, img.height,
|
|
|
+ img.pixels,
|
|
|
+ sizeof(uint32_t)
|
|
|
+ );
|
|
|
+ image_texture_free(&img);
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
static void *gl2_init(const video_info_t *video,
|
|
|
input_driver_t **input, void **input_data)
|
|
|
{
|
|
@@ -3661,7 +3741,7 @@ static void *gl2_init(const video_info_t *video,
|
|
|
|
|
|
if (gl->shader->filter_type(gl->shader_data,
|
|
|
1, &force_smooth))
|
|
|
- gl->tex_min_filter = (gl->flags & GL2_FLAG_TEXTURE_MIPMAP)
|
|
|
+ gl->tex_min_filter = (gl->flags & GL2_FLAG_TEXTURE_MIPMAP)
|
|
|
? (force_smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST)
|
|
|
: (force_smooth ? GL_LINEAR : GL_NEAREST);
|
|
|
else
|
|
@@ -3752,6 +3832,10 @@ static void *gl2_init(const video_info_t *video,
|
|
|
if (gl->flags & GL2_FLAG_SHARED_CONTEXT_USE)
|
|
|
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
|
|
|
|
|
+ glGenTextures(1, &gl->background_texture);
|
|
|
+ glBindTexture(GL_TEXTURE_2D, gl->background_texture);
|
|
|
+ gl2_load_background(gl);
|
|
|
+
|
|
|
return gl;
|
|
|
|
|
|
error:
|
|
@@ -4315,7 +4399,7 @@ static uintptr_t gl2_load_texture(void *video_data, void *data,
|
|
|
return id;
|
|
|
}
|
|
|
|
|
|
-static void gl2_unload_texture(void *data,
|
|
|
+static void gl2_unload_texture(void *data,
|
|
|
bool threaded, uintptr_t id)
|
|
|
{
|
|
|
GLuint glid;
|