From 8a8e329959b9fd6a14dab0686a97e945039d3ccc Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 29 Dec 2016 19:24:45 -0500 Subject: [PATCH] change GL::draw_character() to accept a color --- src/gui/BufferPane.cc | 16 ++++++++-------- src/gui/gl/GL.cc | 4 +++- src/gui/gl/GL.h | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/gui/BufferPane.cc b/src/gui/BufferPane.cc index 306b6c1..207af91 100644 --- a/src/gui/BufferPane.cc +++ b/src/gui/BufferPane.cc @@ -236,12 +236,12 @@ int BufferPane::draw_buffer_line(int screen_row, const Buffer::Iterator & start_ { if (code_point < 0x20u) { - m_window->gl()->draw_character(win_x(x), win_y(y), '^', *m_window->font()); - m_window->gl()->draw_character(win_x(col_x(screen_column + 1)), win_y(y), code_point | 0x40u, *m_window->font()); + m_window->gl()->draw_character(win_x(x), win_y(y), '^', *m_window->font(), 1.0, 1.0, 1.0, 1.0); + m_window->gl()->draw_character(win_x(col_x(screen_column + 1)), win_y(y), code_point | 0x40u, *m_window->font(), 1.0, 1.0, 1.0, 1.0); } else { - m_window->gl()->draw_character(win_x(x), win_y(y), code_point, *m_window->font()); + m_window->gl()->draw_character(win_x(x), win_y(y), code_point, *m_window->font(), 1.0, 1.0, 1.0, 1.0); } } } @@ -271,14 +271,14 @@ void BufferPane::draw_buffer_character(int screen_column, int screen_row, uint32 if (character < 0x20u) { m_window->gl()->draw_character(win_x(col_x(screen_column)), win_y(row_y(screen_row)), - '^', *m_window->font()); + '^', *m_window->font(), 1.0, 1.0, 1.0, 1.0); m_window->gl()->draw_character(win_x(col_x(screen_column + 1)), win_y(row_y(screen_row)), - (character - 0x20u + 'A'), *m_window->font()); + (character - 0x20u + 'A'), *m_window->font(), 1.0, 1.0, 1.0, 1.0); } else { m_window->gl()->draw_character(win_x(col_x(screen_column)), win_y(row_y(screen_row)), - character, *m_window->font()); + character, *m_window->font(), 1.0, 1.0, 1.0, 1.0); } } @@ -536,12 +536,12 @@ void BufferPane::draw_status_bar() int filename_x = std::min(0, x - 3 - (int)filename.size() * m_window->font()->get_advance()); for (int i = 0; i < cursor_position_length; i++) { - m_window->gl()->draw_character(win_x(x), win_y(0), cursor_position[i], *m_window->font()); + m_window->gl()->draw_character(win_x(x), win_y(0), cursor_position[i], *m_window->font(), 1.0, 1.0, 1.0, 1.0); x += m_window->font()->get_advance(); } for (size_t i = 0; i < filename.size(); i++) { - m_window->gl()->draw_character(win_x(filename_x), win_y(0), filename[i], *m_window->font()); + m_window->gl()->draw_character(win_x(filename_x), win_y(0), filename[i], *m_window->font(), 1.0, 1.0, 1.0, 1.0); filename_x += m_window->font()->get_advance(); } } diff --git a/src/gui/gl/GL.cc b/src/gui/gl/GL.cc index 27da600..e8adcce 100644 --- a/src/gui/gl/GL.cc +++ b/src/gui/gl/GL.cc @@ -33,9 +33,11 @@ void GL::draw_rect(int x, int y, int width, int height, glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } -void GL::draw_character(int x, int y, uint32_t character, Font & font) +void GL::draw_character(int x, int y, uint32_t character, Font & font, + float r, float g, float b, float a) { m_shaders.text->use(); + m_shaders.text->set_color(r, g, b, a); m_shaders.text->set_position(x, y + font.get_baseline_offset()); font.get_glyph(character)->render(); } diff --git a/src/gui/gl/GL.h b/src/gui/gl/GL.h index 2cd7478..cfc7661 100644 --- a/src/gui/gl/GL.h +++ b/src/gui/gl/GL.h @@ -15,7 +15,8 @@ public: void draw_rect(int x, int y, int width, int height, float r, float g, float b, float a); - void draw_character(int x, int y, uint32_t character, Font & font); + void draw_character(int x, int y, uint32_t character, Font & font, + float r, float g, float b, float a); void resize(int width, int height); protected: