Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
melonDS
Commits
ac2f1ef8
Unverified
Commit
ac2f1ef8
authored
Aug 18, 2021
by
Libretro-Admin
Committed by
GitHub
Aug 18, 2021
Browse files
Merge pull request #117 from stuken/opengl_hybrid_fix
Fix hybrid screen layout for OpenGL renderer
parents
244392d2
3b5fce09
Pipeline
#48599
passed with stages
in 6 minutes and 46 seconds
Changes
1
Pipelines
12
Hide whitespace changes
Inline
Side-by-side
src/libretro/opengl.cpp
View file @
ac2f1ef8
...
...
@@ -19,7 +19,7 @@ extern bool opengl_linear_filtering;
static
bool
initialized_glsm
;
static
GLuint
shader
[
3
];
static
GLuint
screen_framebuffer_texture
;
static
float
screen_vertices
[
2
*
3
*
2
*
4
];
static
float
screen_vertices
[
7
2
];
static
GLuint
vao
,
vbo
;
struct
...
...
@@ -186,6 +186,23 @@ void setup_opengl_frame_state(void)
float
bottom_screen_y
=
0.0
f
;
float
bottom_screen_scale
=
1.0
f
;
float
primary_x
=
0.0
f
;
float
primary_y
=
0.0
f
;
float
primary_tex_v0_x
=
0.0
f
;
float
primary_tex_v0_y
=
0.0
f
;
float
primary_tex_v1_x
=
0.0
f
;
float
primary_tex_v1_y
=
0.0
f
;
float
primary_tex_v2_x
=
0.0
f
;
float
primary_tex_v2_y
=
0.0
f
;
float
primary_tex_v3_x
=
0.0
f
;
float
primary_tex_v3_y
=
0.0
f
;
float
primary_tex_v4_x
=
0.0
f
;
float
primary_tex_v4_y
=
0.0
f
;
float
primary_tex_v5_x
=
0.0
f
;
float
primary_tex_v5_y
=
0.0
f
;
const
float
pixel_pad
=
1.0
f
/
(
192
*
2
+
2
);
switch
(
screen_layout_data
.
displayed_layout
)
{
case
ScreenLayout
::
TopBottom
:
...
...
@@ -207,17 +224,39 @@ void setup_opengl_frame_state(void)
top_screen_y
=
screen_height
;
// ditto
break
;
case
ScreenLayout
::
HybridTop
:
top_screen_scale
=
(
float
)
screen_layout_data
.
hybrid_ratio
;
bottom_screen_x
=
screen_width
*
screen_layout_data
.
hybrid_ratio
;
bottom_screen_y
=
screen_height
*
(
screen_layout_data
.
hybrid_ratio
-
1
);
primary_x
=
screen_width
*
screen_layout_data
.
hybrid_ratio
;
primary_y
=
screen_height
*
screen_layout_data
.
hybrid_ratio
;
primary_tex_v0_x
=
0.0
f
;
primary_tex_v0_y
=
0.0
f
;
primary_tex_v1_x
=
0.0
f
;
primary_tex_v1_y
=
0.5
f
-
pixel_pad
;
primary_tex_v2_x
=
1.0
f
;
primary_tex_v2_y
=
0.5
f
-
pixel_pad
;
primary_tex_v3_x
=
0.0
f
;
primary_tex_v3_y
=
0.0
f
;
primary_tex_v4_x
=
1.0
f
;
primary_tex_v4_y
=
0.0
f
;
primary_tex_v5_x
=
1.0
f
;
primary_tex_v5_y
=
0.5
f
-
pixel_pad
;
break
;
case
ScreenLayout
::
HybridBottom
:
bottom_screen_scale
=
(
float
)
screen_layout_data
.
hybrid_ratio
;
top_screen_x
=
screen_width
*
screen_layout_data
.
hybrid_ratio
;
top_screen_y
=
screen_height
*
(
screen_layout_data
.
hybrid_ratio
-
1
);
primary_x
=
screen_width
*
screen_layout_data
.
hybrid_ratio
;
primary_y
=
screen_height
*
screen_layout_data
.
hybrid_ratio
;
primary_tex_v0_x
=
0.0
f
;
primary_tex_v0_y
=
0.5
f
+
pixel_pad
;
primary_tex_v1_x
=
0.0
f
;
primary_tex_v1_y
=
1.0
f
;
primary_tex_v2_x
=
1.0
f
;
primary_tex_v2_y
=
1.0
f
;
primary_tex_v3_x
=
0.0
f
;
primary_tex_v3_y
=
0.5
f
+
pixel_pad
;
primary_tex_v4_x
=
1.0
f
;
primary_tex_v4_y
=
0.5
f
+
pixel_pad
;
primary_tex_v5_x
=
1.0
f
;
primary_tex_v5_y
=
01.0
;
break
;
}
...
...
@@ -228,23 +267,54 @@ void setup_opengl_frame_state(void)
screen_vertices[(4 * i) + 2] = t_x; \
screen_vertices[(4 * i) + 3] = t_y;
const
float
pixel_pad
=
1.0
f
/
(
192
*
2
+
2
);
if
(
screen_layout_data
.
displayed_layout
==
ScreenLayout
::
HybridTop
||
screen_layout_data
.
displayed_layout
==
ScreenLayout
::
HybridBottom
)
{
//Primary Screen
SETVERTEX
(
0
,
0.0
f
,
0.0
f
,
primary_tex_v0_x
,
primary_tex_v0_y
);
// top left
SETVERTEX
(
1
,
0.0
f
,
primary_y
,
primary_tex_v1_x
,
primary_tex_v1_y
);
// bottom left
SETVERTEX
(
2
,
primary_x
,
primary_y
,
primary_tex_v2_x
,
primary_tex_v2_y
);
// bottom right
SETVERTEX
(
3
,
0.0
f
,
0.0
f
,
primary_tex_v3_x
,
primary_tex_v3_y
);
// top left
SETVERTEX
(
4
,
primary_x
,
0.0
f
,
primary_tex_v4_x
,
primary_tex_v4_y
);
// top right
SETVERTEX
(
5
,
primary_x
,
primary_y
,
primary_tex_v5_x
,
primary_tex_v5_y
);
// bottom right
//Top screen
SETVERTEX
(
6
,
primary_x
,
0.0
f
,
0.0
f
,
0.0
f
);
// top left
SETVERTEX
(
7
,
primary_x
,
0.0
f
+
screen_height
,
0.0
f
,
0.5
f
-
pixel_pad
);
// bottom left
SETVERTEX
(
8
,
primary_x
+
screen_width
,
0.0
f
+
screen_height
,
1.0
f
,
0.5
f
-
pixel_pad
);
// bottom right
SETVERTEX
(
9
,
primary_x
,
0.0
f
,
0.0
f
,
0.0
f
);
// top left
SETVERTEX
(
10
,
primary_x
+
screen_width
,
0.0
f
,
1.0
f
,
0.0
f
);
// top right
SETVERTEX
(
11
,
primary_x
+
screen_width
,
0.0
f
+
screen_height
,
1.0
f
,
0.5
f
-
pixel_pad
);
// bottom right
//Bottom Screen
SETVERTEX
(
12
,
primary_x
,
primary_y
-
screen_height
,
0.0
f
,
0.5
f
+
pixel_pad
);
// top left
SETVERTEX
(
13
,
primary_x
,
primary_y
,
0.0
f
,
1.0
f
);
// bottom left
SETVERTEX
(
14
,
primary_x
+
screen_width
,
primary_y
,
1.0
f
,
1.0
f
);
// bottom right
SETVERTEX
(
15
,
primary_x
,
primary_y
-
screen_height
,
0.0
f
,
0.5
f
+
pixel_pad
);
// top left
SETVERTEX
(
16
,
primary_x
+
screen_width
,
primary_y
-
screen_height
,
1.0
f
,
0.5
f
+
pixel_pad
);
// top right
SETVERTEX
(
17
,
primary_x
+
screen_width
,
primary_y
,
1.0
f
,
1.0
f
);
// bottom right
}
else
{
// top screen
SETVERTEX
(
0
,
top_screen_x
,
top_screen_y
,
0.0
f
,
0.0
f
);
// top left
SETVERTEX
(
1
,
top_screen_x
,
top_screen_y
+
screen_height
*
top_screen_scale
,
0.0
f
,
0.5
f
-
pixel_pad
);
// bottom left
SETVERTEX
(
2
,
top_screen_x
+
screen_width
*
top_screen_scale
,
top_screen_y
+
screen_height
*
top_screen_scale
,
1.0
f
,
0.5
f
-
pixel_pad
);
// bottom right
SETVERTEX
(
3
,
top_screen_x
,
top_screen_y
,
0.0
f
,
0.0
f
);
// top left
SETVERTEX
(
4
,
top_screen_x
+
screen_width
*
top_screen_scale
,
top_screen_y
,
1.0
f
,
0.0
f
);
// top right
SETVERTEX
(
5
,
top_screen_x
+
screen_width
*
top_screen_scale
,
top_screen_y
+
screen_height
*
top_screen_scale
,
1.0
f
,
0.5
f
-
pixel_pad
);
// bottom right
// bottom screen
SETVERTEX
(
6
,
bottom_screen_x
,
bottom_screen_y
,
0.0
f
,
0.5
f
+
pixel_pad
);
// top left
SETVERTEX
(
7
,
bottom_screen_x
,
bottom_screen_y
+
screen_height
*
bottom_screen_scale
,
0.0
f
,
1.0
f
);
// bottom left
SETVERTEX
(
8
,
bottom_screen_x
+
screen_width
*
bottom_screen_scale
,
bottom_screen_y
+
screen_height
*
bottom_screen_scale
,
1.0
f
,
1.0
f
);
// bottom right
SETVERTEX
(
9
,
bottom_screen_x
,
bottom_screen_y
,
0.0
f
,
0.5
f
+
pixel_pad
);
// top left
SETVERTEX
(
10
,
bottom_screen_x
+
screen_width
*
bottom_screen_scale
,
bottom_screen_y
,
1.0
f
,
0.5
f
+
pixel_pad
);
// top right
SETVERTEX
(
11
,
bottom_screen_x
+
screen_width
*
bottom_screen_scale
,
bottom_screen_y
+
screen_height
*
bottom_screen_scale
,
1.0
f
,
1.0
f
);
// bottom right
}
// top screen
SETVERTEX
(
0
,
top_screen_x
,
top_screen_y
,
0.0
f
,
0.0
f
);
// top left
SETVERTEX
(
1
,
top_screen_x
,
top_screen_y
+
screen_height
*
top_screen_scale
,
0.0
f
,
0.5
f
-
pixel_pad
);
// bottom left
SETVERTEX
(
2
,
top_screen_x
+
screen_width
*
top_screen_scale
,
top_screen_y
+
screen_height
*
top_screen_scale
,
1.0
f
,
0.5
f
-
pixel_pad
);
// bottom right
SETVERTEX
(
3
,
top_screen_x
,
top_screen_y
,
0.0
f
,
0.0
f
);
// top left
SETVERTEX
(
4
,
top_screen_x
+
screen_width
*
top_screen_scale
,
top_screen_y
,
1.0
f
,
0.0
f
);
// top right
SETVERTEX
(
5
,
top_screen_x
+
screen_width
*
top_screen_scale
,
top_screen_y
+
screen_height
*
top_screen_scale
,
1.0
f
,
0.5
f
-
pixel_pad
);
// bottom right
// bottom screen
SETVERTEX
(
6
,
bottom_screen_x
,
bottom_screen_y
,
0.0
f
,
0.5
f
-
pixel_pad
);
// top left
SETVERTEX
(
7
,
bottom_screen_x
,
bottom_screen_y
+
screen_height
*
bottom_screen_scale
,
0.0
f
,
1.0
f
);
// bottom left
SETVERTEX
(
8
,
bottom_screen_x
+
screen_width
*
bottom_screen_scale
,
bottom_screen_y
+
screen_height
*
bottom_screen_scale
,
1.0
f
,
1.0
f
);
// bottom right
SETVERTEX
(
9
,
bottom_screen_x
,
bottom_screen_y
,
0.0
f
,
0.5
f
-
pixel_pad
);
// top left
SETVERTEX
(
10
,
bottom_screen_x
+
screen_width
*
bottom_screen_scale
,
bottom_screen_y
,
1.0
f
,
0.5
f
-
pixel_pad
);
// top right
SETVERTEX
(
11
,
bottom_screen_x
+
screen_width
*
bottom_screen_scale
,
bottom_screen_y
+
screen_height
*
bottom_screen_scale
,
1.0
f
,
1.0
f
);
// bottom right
glBindBuffer
(
GL_ARRAY_BUFFER
,
vbo
);
glBufferSubData
(
GL_ARRAY_BUFFER
,
0
,
sizeof
(
screen_vertices
),
screen_vertices
);
...
...
@@ -311,7 +381,7 @@ void render_opengl_frame(bool sw)
glBindBuffer
(
GL_ARRAY_BUFFER
,
vbo
);
glBindVertexArray
(
vao
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
4
*
3
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
18
);
glFlush
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment