multi viewports (temporaily disable VAO)

This commit is contained in:
milek7
2019-03-12 00:53:34 +01:00
parent 3693c1660e
commit e85d588851
14 changed files with 314 additions and 173 deletions

View File

@@ -1,24 +1,72 @@
#include "stdafx.h"
#include "vao.h"
/*
gl::vao::vao()
{
glGenVertexArrays(1, *this);
glGenVertexArrays(1, *this);
}
gl::vao::~vao()
{
glDeleteVertexArrays(1, *this);
glDeleteVertexArrays(1, *this);
}
void gl::vao::setup_attrib(int attrib, int size, int type, int stride, int offset)
void gl::vao::setup_attrib(gl::buffer &buffer, int attrib, int size, int type, int stride, int offset)
{
bind();
glVertexAttribPointer(attrib, size, type, GL_FALSE, stride, reinterpret_cast<void*>(offset));
glEnableVertexAttribArray(attrib);
bind();
buffer.bind(gl::buffer::ARRAY_BUFFER);
glVertexAttribPointer(attrib, size, type, GL_FALSE, stride, reinterpret_cast<void*>(offset));
glEnableVertexAttribArray(attrib);
}
void gl::vao::setup_ebo(buffer &ebo)
{
bind();
ebo.bind(gl::buffer::ELEMENT_ARRAY_BUFFER);
}
void gl::vao::bind(GLuint i)
{
glBindVertexArray(i);
glBindVertexArray(i);
}
*/
void gl::vao::setup_attrib(gl::buffer &buffer, int attrib, int size, int type, int stride, int offset)
{
params.push_back({buffer, attrib, size, type, stride, offset});
active = nullptr;
}
void gl::vao::setup_ebo(buffer &e)
{
ebo = &e;
active = nullptr;
}
void gl::vao::bind()
{
if (active == this)
return;
active = this;
for (attrib_params &param : params) {
param.buffer.bind(gl::buffer::ARRAY_BUFFER);
glVertexAttribPointer(param.attrib, param.size, param.type, GL_FALSE, param.stride, reinterpret_cast<void*>(param.offset));
glEnableVertexAttribArray(param.attrib);
}
for (size_t i = params.size(); i < 4; i++)
glDisableVertexAttribArray(i);
if (ebo)
ebo->bind(gl::buffer::ELEMENT_ARRAY_BUFFER);
else
gl::buffer::unbind(gl::buffer::ELEMENT_ARRAY_BUFFER);
}
void gl::vao::unbind()
{
active = nullptr;
}