| 117 | |
| 118 | template<typename T> |
| 119 | void Line<T>::draw(const GraphicsContext& context, const T width) |
| 120 | { |
| 121 | DISTRHO_SAFE_ASSERT_RETURN(width != 0,); |
| 122 | |
| 123 | const OpenGL3GraphicsContext& gl3context = static_cast<const OpenGL3GraphicsContext&>(context); |
| 124 | |
| 125 | if (gl3context.program == 0) |
| 126 | return; |
| 127 | |
| 128 | const GLfloat x1 = (static_cast<double>(posStart.x) / gl3context.width) * 2 - 1; |
| 129 | const GLfloat y1 = (static_cast<double>(posStart.y) / gl3context.height) * -2 + 1; |
| 130 | const GLfloat x2 = (static_cast<double>(posEnd.x) / gl3context.width) * 2 - 1; |
| 131 | const GLfloat y2 = (static_cast<double>(posEnd.y) / gl3context.height) * -2 + 1; |
| 132 | |
| 133 | glLineWidth(static_cast<GLfloat>(width)); |
| 134 | |
| 135 | const GLfloat vertices[] = { x1, y1, x2, y2, }; |
| 136 | glBindBuffer(GL_ARRAY_BUFFER, gl3context.buffers[0]); |
| 137 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STREAM_DRAW); |
| 138 | glEnableVertexAttribArray(gl3context.bounds); |
| 139 | glVertexAttribPointer(gl3context.bounds, 2, GL_FLOAT, GL_FALSE, 0, nullptr); |
| 140 | |
| 141 | const GLubyte order[] = { 0, 1 }; |
| 142 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl3context.buffers[1]); |
| 143 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(order), order, GL_STATIC_DRAW); |
| 144 | |
| 145 | glDrawElements(GL_LINES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, nullptr); |
| 146 | |
| 147 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 148 | glDisableVertexAttribArray(gl3context.bounds); |
| 149 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 150 | } |
| 151 | |
| 152 | #ifdef DGL_ALLOW_DEPRECATED_METHODS |
| 153 | template<typename T> |
no test coverage detected