| 100 | } |
| 101 | |
| 102 | void ScreenAlignedQuad::initialize() |
| 103 | { |
| 104 | // By default, counterclockwise polygons are taken to be front-facing. |
| 105 | // http://www.opengl.org/sdk/docs/man/xhtml/glFrontFace.xml |
| 106 | |
| 107 | static const std::array<vec2, 4> raw { { vec2(+1.f,-1.f), vec2(+1.f,+1.f), vec2(-1.f,-1.f), vec2(-1.f,+1.f) } }; |
| 108 | |
| 109 | m_vao = new VertexArray; |
| 110 | |
| 111 | m_buffer = new Buffer(); |
| 112 | m_buffer->setData(raw, GL_STATIC_DRAW); //needed for some drivers |
| 113 | |
| 114 | auto binding = m_vao->binding(0); |
| 115 | binding->setAttribute(0); |
| 116 | binding->setBuffer(m_buffer, 0, sizeof(vec2)); |
| 117 | binding->setFormat(2, GL_FLOAT, GL_FALSE, 0); |
| 118 | m_vao->enable(0); |
| 119 | |
| 120 | setSamplerUniform(0); |
| 121 | } |
| 122 | |
| 123 | void ScreenAlignedQuad::draw() |
| 124 | { |