mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-27 07:20:05 +00:00
Add implementation for color filling.
TODO: Get LCD Color Fill data from GPU
This commit is contained in:
parent
e4905143c8
commit
81fa66e9a8
@ -61,6 +61,15 @@ void RendererOpenGL::SwapBuffers() {
|
|||||||
for(int i : {0, 1}) {
|
for(int i : {0, 1}) {
|
||||||
const auto& framebuffer = GPU::g_regs.framebuffer_config[i];
|
const auto& framebuffer = GPU::g_regs.framebuffer_config[i];
|
||||||
|
|
||||||
|
u32 lcd_color_fill = 0;
|
||||||
|
// TODO: Get LCD Color Fill data from GPU (main: 0x202204, sub: 0x202A04)
|
||||||
|
|
||||||
|
if (lcd_color_fill & 1 << 24) { //Enabled
|
||||||
|
u8 r = (lcd_color_fill >> 0) & 0xFF;
|
||||||
|
u8 g = (lcd_color_fill >> 8) & 0xFF;
|
||||||
|
u8 b = (lcd_color_fill >> 16) & 0xFF;
|
||||||
|
LoadColorToActiveGLTexture(r, g, b, &textures[i]);
|
||||||
|
} else {
|
||||||
if (textures[i].width != framebuffer.width || textures[i].height != framebuffer.height) {
|
if (textures[i].width != framebuffer.width || textures[i].height != framebuffer.height) {
|
||||||
// Reallocate texture if the framebuffer size has changed.
|
// Reallocate texture if the framebuffer size has changed.
|
||||||
// This is expected to not happen very often and hence should not be a
|
// This is expected to not happen very often and hence should not be a
|
||||||
@ -74,6 +83,7 @@ void RendererOpenGL::SwapBuffers() {
|
|||||||
|
|
||||||
LoadFBToActiveGLTexture(GPU::g_regs.framebuffer_config[i], textures[i]);
|
LoadFBToActiveGLTexture(GPU::g_regs.framebuffer_config[i], textures[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DrawScreens();
|
DrawScreens();
|
||||||
|
|
||||||
@ -124,6 +134,31 @@ void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig&
|
|||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates 1x1 framebuffer from color, loads into the active OpenGL texture.
|
||||||
|
* Since the color is solid, the texture can be 1x1 but will stretch across whatever it's rendered on.
|
||||||
|
* This has the added benefit of being *really fast*.
|
||||||
|
*/
|
||||||
|
void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, TextureInfo* texture) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture->handle);
|
||||||
|
|
||||||
|
u8 framebuffer_data[3] = { color_r, color_g, color_b };
|
||||||
|
|
||||||
|
if (texture->width != 1 || texture->height != 1) {
|
||||||
|
// Reallocate texture if the framebuffer size has changed.
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0,
|
||||||
|
GL_RGB, GL_UNSIGNED_BYTE, framebuffer_data);
|
||||||
|
texture->width = 1;
|
||||||
|
texture->height = 1;
|
||||||
|
} else {
|
||||||
|
// Update existing texture
|
||||||
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->width, texture->height,
|
||||||
|
GL_RGB, GL_UNSIGNED_BYTE, framebuffer_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the OpenGL state and creates persistent objects.
|
* Initializes the OpenGL state and creates persistent objects.
|
||||||
*/
|
*/
|
||||||
|
@ -51,6 +51,8 @@ private:
|
|||||||
// Loads framebuffer from emulated memory into the active OpenGL texture.
|
// Loads framebuffer from emulated memory into the active OpenGL texture.
|
||||||
static void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
|
static void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
|
||||||
const TextureInfo& texture);
|
const TextureInfo& texture);
|
||||||
|
// Creates 1x1 framebuffer from color, loads into the active OpenGL texture.
|
||||||
|
static void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, TextureInfo* texture);
|
||||||
|
|
||||||
EmuWindow* render_window; ///< Handle to render window
|
EmuWindow* render_window; ///< Handle to render window
|
||||||
u32 last_mode; ///< Last render mode
|
u32 last_mode; ///< Last render mode
|
||||||
@ -62,7 +64,7 @@ private:
|
|||||||
GLuint vertex_array_handle;
|
GLuint vertex_array_handle;
|
||||||
GLuint vertex_buffer_handle;
|
GLuint vertex_buffer_handle;
|
||||||
GLuint program_id;
|
GLuint program_id;
|
||||||
std::array<TextureInfo, 2> textures;
|
std::array<TextureInfo, 2> textures; // main, sub respectively
|
||||||
// Shader uniform location indices
|
// Shader uniform location indices
|
||||||
GLuint uniform_modelview_matrix;
|
GLuint uniform_modelview_matrix;
|
||||||
GLuint uniform_color_texture;
|
GLuint uniform_color_texture;
|
||||||
|
Loading…
Reference in New Issue
Block a user