Use an OpenGL array object to draw the cursor
This commit is contained in:
parent
33a190c495
commit
01bf455e68
@ -123,8 +123,12 @@ bool Window::create(std::shared_ptr<Buffer> buffer)
|
||||
m_font.get_advance(), 0,
|
||||
m_font.get_advance(), m_font.get_line_height(),
|
||||
0, m_font.get_line_height()};
|
||||
m_cursor_array = glcxx::Array::create();
|
||||
m_cursor_array->bind();
|
||||
m_cursor_buffer = glcxx::Buffer::create(GL_ARRAY_BUFFER, GL_STATIC_DRAW,
|
||||
cursor_bounds, sizeof(cursor_bounds));
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_INT, GL_FALSE, 0, 0);
|
||||
|
||||
m_buffer = buffer;
|
||||
m_cursor = m_buffer->piece_table->add_cursor();
|
||||
@ -276,15 +280,7 @@ void Window::redraw()
|
||||
glClearColor (0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBindVertexArray(0);
|
||||
m_shaders.flat->use();
|
||||
m_shaders.flat->set_color(1.0, 0.2, 1.0, 1.0);
|
||||
m_shaders.flat->set_position(0, m_height - m_font.get_line_height());
|
||||
m_cursor_buffer->bind();
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_INT, GL_FALSE, 0, 0);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
draw_cursor();
|
||||
m_shaders.text->use();
|
||||
|
||||
int advance = m_font.get_advance();
|
||||
@ -324,3 +320,12 @@ void Window::redraw()
|
||||
|
||||
SDL_GL_SwapWindow(m_window);
|
||||
}
|
||||
|
||||
void Window::draw_cursor()
|
||||
{
|
||||
m_cursor_array->bind();
|
||||
m_shaders.flat->use();
|
||||
m_shaders.flat->set_color(1.0, 0.2, 1.0, 1.0);
|
||||
m_shaders.flat->set_position(0, m_height - m_font.get_line_height());
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
protected:
|
||||
void resize();
|
||||
void redraw();
|
||||
void draw_cursor();
|
||||
void handle_event(SDL_Event & event);
|
||||
void handle_key(uint32_t scancode, uint32_t mod);
|
||||
void scroll_down();
|
||||
@ -38,6 +39,7 @@ protected:
|
||||
|
||||
std::shared_ptr<Buffer> m_buffer;
|
||||
|
||||
std::shared_ptr<glcxx::Array> m_cursor_array;
|
||||
std::shared_ptr<glcxx::Buffer> m_cursor_buffer;
|
||||
|
||||
std::shared_ptr<PieceTable::Cursor> m_cursor;
|
||||
|
Loading…
x
Reference in New Issue
Block a user