mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-27 12:04:16 +01:00
renderer_opengl: Allow usage of Stereoscopic 3D
This commit is contained in:
parent
e4788130e5
commit
2814bbc3da
@ -103,12 +103,13 @@ void RendererOpenGL::SwapBuffers() {
|
|||||||
OpenGLState prev_state = OpenGLState::GetCurState();
|
OpenGLState prev_state = OpenGLState::GetCurState();
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
for (int i : {0, 1}) {
|
for (int i : {0, 1, 2}) {
|
||||||
const auto& framebuffer = GPU::g_regs.framebuffer_config[i];
|
int fb_id = i == 2 ? 1 : 0;
|
||||||
|
const auto& framebuffer = GPU::g_regs.framebuffer_config[fb_id];
|
||||||
|
|
||||||
// Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04
|
// Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04
|
||||||
u32 lcd_color_addr =
|
u32 lcd_color_addr =
|
||||||
(i == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom);
|
(fb_id == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom);
|
||||||
lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr;
|
lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr;
|
||||||
LCD::Regs::ColorFill color_fill = {0};
|
LCD::Regs::ColorFill color_fill = {0};
|
||||||
LCD::Read(color_fill.raw, lcd_color_addr);
|
LCD::Read(color_fill.raw, lcd_color_addr);
|
||||||
@ -129,7 +130,7 @@ void RendererOpenGL::SwapBuffers() {
|
|||||||
// performance problem.
|
// performance problem.
|
||||||
ConfigureFramebufferTexture(screen_infos[i].texture, framebuffer);
|
ConfigureFramebufferTexture(screen_infos[i].texture, framebuffer);
|
||||||
}
|
}
|
||||||
LoadFBToScreenInfo(framebuffer, screen_infos[i]);
|
LoadFBToScreenInfo(framebuffer, screen_infos[i], i == 1);
|
||||||
|
|
||||||
// Resize the texture in case the framebuffer size has changed
|
// Resize the texture in case the framebuffer size has changed
|
||||||
screen_infos[i].texture.width = framebuffer.width;
|
screen_infos[i].texture.width = framebuffer.width;
|
||||||
@ -160,10 +161,12 @@ void RendererOpenGL::SwapBuffers() {
|
|||||||
* Loads framebuffer from emulated memory into the active OpenGL texture.
|
* Loads framebuffer from emulated memory into the active OpenGL texture.
|
||||||
*/
|
*/
|
||||||
void RendererOpenGL::LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& framebuffer,
|
void RendererOpenGL::LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& framebuffer,
|
||||||
ScreenInfo& screen_info) {
|
ScreenInfo& screen_info, bool right_eye) {
|
||||||
|
|
||||||
const PAddr framebuffer_addr =
|
const PAddr framebuffer_addr =
|
||||||
framebuffer.active_fb == 0 ? framebuffer.address_left1 : framebuffer.address_left2;
|
framebuffer.active_fb == 0
|
||||||
|
? (!right_eye ? framebuffer.address_left1 : framebuffer.address_right1)
|
||||||
|
: (!right_eye ? framebuffer.address_left2 : framebuffer.address_right2);
|
||||||
|
|
||||||
LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%08x(%dx%d), fmt %x",
|
LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%08x(%dx%d), fmt %x",
|
||||||
framebuffer.stride * framebuffer.height, framebuffer_addr, (int)framebuffer.width,
|
framebuffer.stride * framebuffer.height, framebuffer_addr, (int)framebuffer.width,
|
||||||
@ -397,11 +400,22 @@ void RendererOpenGL::DrawScreens() {
|
|||||||
if (layout.top_screen_enabled) {
|
if (layout.top_screen_enabled) {
|
||||||
DrawSingleScreenRotated(screen_infos[0], (float)top_screen.left, (float)top_screen.top,
|
DrawSingleScreenRotated(screen_infos[0], (float)top_screen.left, (float)top_screen.top,
|
||||||
(float)top_screen.GetWidth(), (float)top_screen.GetHeight());
|
(float)top_screen.GetWidth(), (float)top_screen.GetHeight());
|
||||||
|
if (Settings::values.toggle_3d) {
|
||||||
|
DrawSingleScreenRotated(
|
||||||
|
screen_infos[1], ((float)top_screen.left * 3) + (float)top_screen.GetWidth(),
|
||||||
|
(float)top_screen.top, (float)top_screen.GetWidth(), (float)top_screen.GetHeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (layout.bottom_screen_enabled) {
|
if (layout.bottom_screen_enabled) {
|
||||||
DrawSingleScreenRotated(screen_infos[1], (float)bottom_screen.left,
|
DrawSingleScreenRotated(screen_infos[2], (float)bottom_screen.left,
|
||||||
(float)bottom_screen.top, (float)bottom_screen.GetWidth(),
|
(float)bottom_screen.top, (float)bottom_screen.GetWidth(),
|
||||||
(float)bottom_screen.GetHeight());
|
(float)bottom_screen.GetHeight());
|
||||||
|
if (Settings::values.toggle_3d) {
|
||||||
|
DrawSingleScreenRotated(
|
||||||
|
screen_infos[2], ((float)bottom_screen.left * 3) + (float)bottom_screen.GetWidth(),
|
||||||
|
(float)bottom_screen.top, (float)bottom_screen.GetWidth(),
|
||||||
|
(float)bottom_screen.GetHeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_current_frame++;
|
m_current_frame++;
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
|
|
||||||
// Loads framebuffer from emulated memory into the display information structure
|
// Loads framebuffer from emulated memory into the display information structure
|
||||||
void LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& framebuffer,
|
void LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& framebuffer,
|
||||||
ScreenInfo& screen_info);
|
ScreenInfo& screen_info, bool right_eye);
|
||||||
// Fills active OpenGL texture with the given RGB color.
|
// Fills active OpenGL texture with the given RGB color.
|
||||||
void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture);
|
void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture);
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ private:
|
|||||||
OGLProgram shader;
|
OGLProgram shader;
|
||||||
|
|
||||||
/// Display information for top and bottom screens respectively
|
/// Display information for top and bottom screens respectively
|
||||||
std::array<ScreenInfo, 2> screen_infos;
|
std::array<ScreenInfo, 3> screen_infos;
|
||||||
|
|
||||||
// Shader uniform location indices
|
// Shader uniform location indices
|
||||||
GLuint uniform_modelview_matrix;
|
GLuint uniform_modelview_matrix;
|
||||||
|
Loading…
Reference in New Issue
Block a user