mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-23 18:19:21 +01:00
renderer_opengl.cpp: Draw{Top, Bottom}Screen Clean up (#6422)
This commit is contained in:
parent
5f81940e63
commit
0da25736d9
@ -977,15 +977,15 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
|
|||||||
|
|
||||||
glUniform1i(uniform_layer, 0);
|
glUniform1i(uniform_layer, 0);
|
||||||
if (!Settings::values.swap_screen.GetValue()) {
|
if (!Settings::values.swap_screen.GetValue()) {
|
||||||
DrawTopScreen(layout, top_screen, stereo_single_screen);
|
DrawTopScreen(layout, top_screen);
|
||||||
glUniform1i(uniform_layer, 0);
|
glUniform1i(uniform_layer, 0);
|
||||||
ApplySecondLayerOpacity();
|
ApplySecondLayerOpacity();
|
||||||
DrawBottomScreen(layout, bottom_screen, stereo_single_screen);
|
DrawBottomScreen(layout, bottom_screen);
|
||||||
} else {
|
} else {
|
||||||
DrawBottomScreen(layout, bottom_screen, stereo_single_screen);
|
DrawBottomScreen(layout, bottom_screen);
|
||||||
glUniform1i(uniform_layer, 0);
|
glUniform1i(uniform_layer, 0);
|
||||||
ApplySecondLayerOpacity();
|
ApplySecondLayerOpacity();
|
||||||
DrawTopScreen(layout, top_screen, stereo_single_screen);
|
DrawTopScreen(layout, top_screen);
|
||||||
}
|
}
|
||||||
ResetSecondLayerOpacity();
|
ResetSecondLayerOpacity();
|
||||||
}
|
}
|
||||||
@ -1013,137 +1013,168 @@ void RendererOpenGL::ResetSecondLayerOpacity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout,
|
void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout,
|
||||||
const Common::Rectangle<u32>& top_screen,
|
const Common::Rectangle<u32>& top_screen) {
|
||||||
const bool stereo_single_screen) {
|
|
||||||
if (!layout.top_screen_enabled) {
|
if (!layout.top_screen_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float top_screen_left = static_cast<float>(top_screen.left);
|
||||||
|
const float top_screen_top = static_cast<float>(top_screen.top);
|
||||||
|
const float top_screen_width = static_cast<float>(top_screen.GetWidth());
|
||||||
|
const float top_screen_height = static_cast<float>(top_screen.GetHeight());
|
||||||
|
|
||||||
if (layout.is_rotated) {
|
if (layout.is_rotated) {
|
||||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Off) {
|
switch (Settings::values.render_3d.GetValue()) {
|
||||||
|
case Settings::StereoRenderOption::Off: {
|
||||||
int eye = static_cast<int>(Settings::values.mono_render_option.GetValue());
|
int eye = static_cast<int>(Settings::values.mono_render_option.GetValue());
|
||||||
DrawSingleScreenRotated(screen_infos[eye], (float)top_screen.left,
|
DrawSingleScreenRotated(screen_infos[eye], top_screen_left, top_screen_top,
|
||||||
(float)top_screen.top, (float)top_screen.GetWidth(),
|
top_screen_width, top_screen_height);
|
||||||
(float)top_screen.GetHeight());
|
break;
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
}
|
||||||
Settings::StereoRenderOption::SideBySide) {
|
case Settings::StereoRenderOption::SideBySide: {
|
||||||
DrawSingleScreenRotated(screen_infos[0], (float)top_screen.left / 2,
|
DrawSingleScreenRotated(screen_infos[0], top_screen_left / 2, top_screen_top,
|
||||||
(float)top_screen.top, (float)top_screen.GetWidth() / 2,
|
top_screen_width / 2, top_screen_height);
|
||||||
(float)top_screen.GetHeight());
|
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreenRotated(screen_infos[1],
|
DrawSingleScreenRotated(screen_infos[1],
|
||||||
((float)top_screen.left / 2) + ((float)layout.width / 2),
|
static_cast<float>((top_screen_left / 2) + (layout.width / 2)),
|
||||||
(float)top_screen.top, (float)top_screen.GetWidth() / 2,
|
top_screen_top, top_screen_width / 2, top_screen_height);
|
||||||
(float)top_screen.GetHeight());
|
break;
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
}
|
||||||
Settings::StereoRenderOption::CardboardVR) {
|
case Settings::StereoRenderOption::CardboardVR: {
|
||||||
DrawSingleScreenRotated(screen_infos[0], layout.top_screen.left, layout.top_screen.top,
|
DrawSingleScreenRotated(screen_infos[0], top_screen_left, top_screen_top,
|
||||||
layout.top_screen.GetWidth(), layout.top_screen.GetHeight());
|
top_screen_width, top_screen_height);
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreenRotated(
|
DrawSingleScreenRotated(
|
||||||
screen_infos[1], layout.cardboard.top_screen_right_eye + ((float)layout.width / 2),
|
screen_infos[1],
|
||||||
layout.top_screen.top, layout.top_screen.GetWidth(), layout.top_screen.GetHeight());
|
static_cast<float>(layout.cardboard.top_screen_right_eye + (layout.width / 2)),
|
||||||
} else if (stereo_single_screen) {
|
top_screen_top, top_screen_width, top_screen_height);
|
||||||
DrawSingleScreenStereoRotated(screen_infos[0], screen_infos[1], (float)top_screen.left,
|
break;
|
||||||
(float)top_screen.top, (float)top_screen.GetWidth(),
|
}
|
||||||
(float)top_screen.GetHeight());
|
case Settings::StereoRenderOption::Anaglyph:
|
||||||
|
case Settings::StereoRenderOption::Interlaced:
|
||||||
|
case Settings::StereoRenderOption::ReverseInterlaced: {
|
||||||
|
DrawSingleScreenStereoRotated(screen_infos[0], screen_infos[1], top_screen_left,
|
||||||
|
top_screen_top, top_screen_width, top_screen_height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Off) {
|
switch (Settings::values.render_3d.GetValue()) {
|
||||||
|
case Settings::StereoRenderOption::Off: {
|
||||||
int eye = static_cast<int>(Settings::values.mono_render_option.GetValue());
|
int eye = static_cast<int>(Settings::values.mono_render_option.GetValue());
|
||||||
DrawSingleScreen(screen_infos[eye], (float)top_screen.left, (float)top_screen.top,
|
DrawSingleScreen(screen_infos[eye], top_screen_left, top_screen_top, top_screen_width,
|
||||||
(float)top_screen.GetWidth(), (float)top_screen.GetHeight());
|
top_screen_height);
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
break;
|
||||||
Settings::StereoRenderOption::SideBySide) {
|
}
|
||||||
DrawSingleScreen(screen_infos[0], (float)top_screen.left / 2, (float)top_screen.top,
|
case Settings::StereoRenderOption::SideBySide: {
|
||||||
(float)top_screen.GetWidth() / 2, (float)top_screen.GetHeight());
|
DrawSingleScreen(screen_infos[0], top_screen_left / 2, top_screen_top,
|
||||||
|
top_screen_width / 2, top_screen_height);
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreen(screen_infos[1],
|
DrawSingleScreen(screen_infos[1],
|
||||||
((float)top_screen.left / 2) + ((float)layout.width / 2),
|
static_cast<float>((top_screen_left / 2) + (layout.width / 2)),
|
||||||
(float)top_screen.top, (float)top_screen.GetWidth() / 2,
|
top_screen_top, top_screen_width / 2, top_screen_height);
|
||||||
(float)top_screen.GetHeight());
|
break;
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
}
|
||||||
Settings::StereoRenderOption::CardboardVR) {
|
case Settings::StereoRenderOption::CardboardVR: {
|
||||||
DrawSingleScreen(screen_infos[0], layout.top_screen.left, layout.top_screen.top,
|
DrawSingleScreen(screen_infos[0], (float)top_screen.left, top_screen_top,
|
||||||
layout.top_screen.GetWidth(), layout.top_screen.GetHeight());
|
top_screen_width, top_screen_height);
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreen(
|
DrawSingleScreen(
|
||||||
screen_infos[1], layout.cardboard.top_screen_right_eye + ((float)layout.width / 2),
|
screen_infos[1],
|
||||||
layout.top_screen.top, layout.top_screen.GetWidth(), layout.top_screen.GetHeight());
|
static_cast<float>(layout.cardboard.top_screen_right_eye + (layout.width / 2)),
|
||||||
} else if (stereo_single_screen) {
|
top_screen_top, top_screen_width, top_screen_height);
|
||||||
DrawSingleScreenStereo(screen_infos[0], screen_infos[1], (float)top_screen.left,
|
break;
|
||||||
(float)top_screen.top, (float)top_screen.GetWidth(),
|
}
|
||||||
(float)top_screen.GetHeight());
|
case Settings::StereoRenderOption::Anaglyph:
|
||||||
|
case Settings::StereoRenderOption::Interlaced:
|
||||||
|
case Settings::StereoRenderOption::ReverseInterlaced: {
|
||||||
|
DrawSingleScreenStereo(screen_infos[0], screen_infos[1], top_screen_left,
|
||||||
|
top_screen_top, top_screen_width, top_screen_height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererOpenGL::DrawBottomScreen(const Layout::FramebufferLayout& layout,
|
void RendererOpenGL::DrawBottomScreen(const Layout::FramebufferLayout& layout,
|
||||||
const Common::Rectangle<u32>& bottom_screen,
|
const Common::Rectangle<u32>& bottom_screen) {
|
||||||
const bool stereo_single_screen) {
|
|
||||||
if (!layout.bottom_screen_enabled) {
|
if (!layout.bottom_screen_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float bottom_screen_left = static_cast<float>(bottom_screen.left);
|
||||||
|
const float bottom_screen_top = static_cast<float>(bottom_screen.top);
|
||||||
|
const float bottom_screen_width = static_cast<float>(bottom_screen.GetWidth());
|
||||||
|
const float bottom_screen_height = static_cast<float>(bottom_screen.GetHeight());
|
||||||
|
|
||||||
if (layout.is_rotated) {
|
if (layout.is_rotated) {
|
||||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Off) {
|
switch (Settings::values.render_3d.GetValue()) {
|
||||||
DrawSingleScreenRotated(screen_infos[2], (float)bottom_screen.left,
|
case Settings::StereoRenderOption::Off: {
|
||||||
(float)bottom_screen.top, (float)bottom_screen.GetWidth(),
|
DrawSingleScreenRotated(screen_infos[2], bottom_screen_left, bottom_screen_top,
|
||||||
(float)bottom_screen.GetHeight());
|
bottom_screen_width, bottom_screen_height);
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
break;
|
||||||
Settings::StereoRenderOption::SideBySide) {
|
}
|
||||||
DrawSingleScreenRotated(screen_infos[2], (float)bottom_screen.left / 2,
|
case Settings::StereoRenderOption::SideBySide: {
|
||||||
(float)bottom_screen.top, (float)bottom_screen.GetWidth() / 2,
|
DrawSingleScreenRotated(screen_infos[2], bottom_screen_left / 2, bottom_screen_top,
|
||||||
(float)bottom_screen.GetHeight());
|
bottom_screen_width / 2, bottom_screen_height);
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreenRotated(screen_infos[2],
|
DrawSingleScreenRotated(
|
||||||
((float)bottom_screen.left / 2) + ((float)layout.width / 2),
|
screen_infos[2], static_cast<float>((bottom_screen_left / 2) + (layout.width / 2)),
|
||||||
(float)bottom_screen.top, (float)bottom_screen.GetWidth() / 2,
|
bottom_screen_top, bottom_screen_width / 2, bottom_screen_height);
|
||||||
(float)bottom_screen.GetHeight());
|
break;
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
}
|
||||||
Settings::StereoRenderOption::CardboardVR) {
|
case Settings::StereoRenderOption::CardboardVR: {
|
||||||
DrawSingleScreenRotated(screen_infos[2], layout.bottom_screen.left,
|
DrawSingleScreenRotated(screen_infos[2], bottom_screen_left, bottom_screen_top,
|
||||||
layout.bottom_screen.top, layout.bottom_screen.GetWidth(),
|
bottom_screen_width, bottom_screen_height);
|
||||||
layout.bottom_screen.GetHeight());
|
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreenRotated(screen_infos[2],
|
DrawSingleScreenRotated(
|
||||||
layout.cardboard.bottom_screen_right_eye +
|
screen_infos[2],
|
||||||
((float)layout.width / 2),
|
static_cast<float>(layout.cardboard.bottom_screen_right_eye + (layout.width / 2)),
|
||||||
layout.bottom_screen.top, layout.bottom_screen.GetWidth(),
|
bottom_screen_top, bottom_screen_width, bottom_screen_height);
|
||||||
layout.bottom_screen.GetHeight());
|
break;
|
||||||
} else if (stereo_single_screen) {
|
}
|
||||||
DrawSingleScreenStereoRotated(screen_infos[2], screen_infos[2],
|
case Settings::StereoRenderOption::Anaglyph:
|
||||||
(float)bottom_screen.left, (float)bottom_screen.top,
|
case Settings::StereoRenderOption::Interlaced:
|
||||||
(float)bottom_screen.GetWidth(),
|
case Settings::StereoRenderOption::ReverseInterlaced: {
|
||||||
(float)bottom_screen.GetHeight());
|
DrawSingleScreenStereoRotated(screen_infos[2], screen_infos[2], bottom_screen_left,
|
||||||
|
bottom_screen_top, bottom_screen_width,
|
||||||
|
bottom_screen_height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::Off) {
|
switch (Settings::values.render_3d.GetValue()) {
|
||||||
DrawSingleScreen(screen_infos[2], (float)bottom_screen.left, (float)bottom_screen.top,
|
case Settings::StereoRenderOption::Off: {
|
||||||
(float)bottom_screen.GetWidth(), (float)bottom_screen.GetHeight());
|
DrawSingleScreen(screen_infos[2], bottom_screen_left, bottom_screen_top,
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
bottom_screen_width, bottom_screen_height);
|
||||||
Settings::StereoRenderOption::SideBySide) {
|
break;
|
||||||
DrawSingleScreen(screen_infos[2], (float)bottom_screen.left / 2,
|
}
|
||||||
(float)bottom_screen.top, (float)bottom_screen.GetWidth() / 2,
|
case Settings::StereoRenderOption::SideBySide: {
|
||||||
(float)bottom_screen.GetHeight());
|
DrawSingleScreen(screen_infos[2], bottom_screen_left / 2, bottom_screen_top,
|
||||||
|
bottom_screen_width / 2, bottom_screen_height);
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreen(screen_infos[2],
|
DrawSingleScreen(screen_infos[2],
|
||||||
((float)bottom_screen.left / 2) + ((float)layout.width / 2),
|
static_cast<float>((bottom_screen_left / 2) + (layout.width / 2)),
|
||||||
(float)bottom_screen.top, (float)bottom_screen.GetWidth() / 2,
|
bottom_screen_top, bottom_screen_width / 2, bottom_screen_height);
|
||||||
(float)bottom_screen.GetHeight());
|
break;
|
||||||
} else if (Settings::values.render_3d.GetValue() ==
|
}
|
||||||
Settings::StereoRenderOption::CardboardVR) {
|
case Settings::StereoRenderOption::CardboardVR: {
|
||||||
DrawSingleScreen(screen_infos[2], layout.bottom_screen.left, layout.bottom_screen.top,
|
DrawSingleScreen(screen_infos[2], (float)layout.bottom_screen.left, bottom_screen_top,
|
||||||
layout.bottom_screen.GetWidth(), layout.bottom_screen.GetHeight());
|
bottom_screen_width, bottom_screen_height);
|
||||||
glUniform1i(uniform_layer, 1);
|
glUniform1i(uniform_layer, 1);
|
||||||
DrawSingleScreen(screen_infos[2],
|
DrawSingleScreen(
|
||||||
layout.cardboard.bottom_screen_right_eye + ((float)layout.width / 2),
|
screen_infos[2],
|
||||||
layout.bottom_screen.top, layout.bottom_screen.GetWidth(),
|
static_cast<float>(layout.cardboard.bottom_screen_right_eye + (layout.width / 2)),
|
||||||
layout.bottom_screen.GetHeight());
|
bottom_screen_top, bottom_screen_width, bottom_screen_height);
|
||||||
} else if (stereo_single_screen) {
|
break;
|
||||||
DrawSingleScreenStereo(screen_infos[2], screen_infos[2], (float)bottom_screen.left,
|
}
|
||||||
(float)bottom_screen.top, (float)bottom_screen.GetWidth(),
|
case Settings::StereoRenderOption::Anaglyph:
|
||||||
(float)bottom_screen.GetHeight());
|
case Settings::StereoRenderOption::Interlaced:
|
||||||
|
case Settings::StereoRenderOption::ReverseInterlaced: {
|
||||||
|
DrawSingleScreenStereo(screen_infos[2], screen_infos[2], bottom_screen_left,
|
||||||
|
bottom_screen_top, bottom_screen_width, bottom_screen_height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,10 +84,9 @@ private:
|
|||||||
void ApplySecondLayerOpacity();
|
void ApplySecondLayerOpacity();
|
||||||
void ResetSecondLayerOpacity();
|
void ResetSecondLayerOpacity();
|
||||||
void DrawBottomScreen(const Layout::FramebufferLayout& layout,
|
void DrawBottomScreen(const Layout::FramebufferLayout& layout,
|
||||||
const Common::Rectangle<u32>& bottom_screen,
|
const Common::Rectangle<u32>& bottom_screen);
|
||||||
const bool stereo_single_screen);
|
|
||||||
void DrawTopScreen(const Layout::FramebufferLayout& layout,
|
void DrawTopScreen(const Layout::FramebufferLayout& layout,
|
||||||
const Common::Rectangle<u32>& top_screen, const bool stereo_single_screen);
|
const Common::Rectangle<u32>& top_screen);
|
||||||
void DrawSingleScreenRotated(const ScreenInfo& screen_info, float x, float y, float w, float h);
|
void DrawSingleScreenRotated(const ScreenInfo& screen_info, float x, float y, float w, float h);
|
||||||
void DrawSingleScreen(const ScreenInfo& screen_info, float x, float y, float w, float h);
|
void DrawSingleScreen(const ScreenInfo& screen_info, float x, float y, float w, float h);
|
||||||
void DrawSingleScreenStereoRotated(const ScreenInfo& screen_info_l,
|
void DrawSingleScreenStereoRotated(const ScreenInfo& screen_info_l,
|
||||||
|
Loading…
Reference in New Issue
Block a user