123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include "client/engine/shader/FramebufferRectangle.h"
- #include "client/engine/Wrapper.h"
- FramebufferRectangle::FramebufferRectangle()
- {
- }
- FramebufferRectangle::~FramebufferRectangle()
- {
- glDeleteVertexArrays(1, &vba);
- glDeleteBuffers(1, &vbo);
- }
- bool FramebufferRectangle::init()
- {
- glGenVertexArrays(1, &vba);
- glBindVertexArray(vba);
-
- glGenBuffers(1, &vbo);
- glBindBuffer(GL_ARRAY_BUFFER, vbo);
- glVertexAttribPointer(0, 2, GL_FLOAT, 0, sizeof(float) * 4, (GLvoid*) 0);
- glEnableVertexAttribArray(0);
- glVertexAttribPointer(2, 2, GL_FLOAT, 0, sizeof(float) * 4, (GLvoid*) (sizeof(float) * 2));
- glEnableVertexAttribArray(2);
-
- Engine::printError();
-
- float data[] =
- {
- -1.0f, 1.0f, 0.0f, 1.0f,
- -1.0f, -1.0f, 0.0f, 0.0f,
- 1.0f, -1.0f, 1.0f, 0.0f,
- -1.0f, 1.0f, 0.0f, 1.0f,
- 1.0f, -1.0f, 1.0f, 0.0f,
- 1.0f, 1.0f, 1.0f, 1.0f
- };
-
- glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 24, data, GL_STATIC_DRAW);
-
- return true;
- }
- void FramebufferRectangle::draw()
- {
- glBindVertexArray(vba);
- glBindBuffer(GL_ARRAY_BUFFER, vbo);
- glDrawArrays(GL_TRIANGLES, 0, 6);
- }
|