Fixed the textured cube from being broken.
The problem was caused by vector re-allocation. This is a similar problem to what happened with the mesh factory. It was solved by converting the texture factory to use lists instead of vectors. The reason for using lists is to prevent the need for explicit deallocation of resources and instead allow the use of a list to automatically allocate/deallocate the textures/samplers/meshes.
This commit is contained in:
parent
5a9765b111
commit
49f7a3e2d7
@ -43,7 +43,6 @@ namespace charcoal
|
||||
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, TextureRenderable<VertexType, IndexType> >::m_vertex_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
// TODO: Figure out how to do this without offsetof :(
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexType), (void*)position_offset);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(VertexType), (void*)uv_offset);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, TextureRenderable<VertexType, IndexType> >::m_element_buffers[0]);
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
namespace charcoal
|
||||
{
|
||||
std::vector<Texture> TextureFactory::m_textures;
|
||||
std::vector<Sampler> TextureFactory::m_samplers;
|
||||
std::list<Texture> TextureFactory::m_textures;
|
||||
std::list<Sampler> TextureFactory::m_samplers;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#include "ImageLoader.h"
|
||||
|
||||
@ -49,7 +49,7 @@ namespace charcoal
|
||||
}
|
||||
|
||||
private:
|
||||
static std::vector<Texture> m_textures;
|
||||
static std::vector<Sampler> m_samplers;
|
||||
static std::list<Texture> m_textures;
|
||||
static std::list<Sampler> m_samplers;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "TexturedBatch.h"
|
||||
|
||||
#include "Util.h" // CHECK_GL_ERR
|
||||
|
||||
namespace charcoal
|
||||
{
|
||||
namespace builtin
|
||||
@ -10,7 +12,9 @@ namespace charcoal
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_p_renderable->get_texture()->get_texture());
|
||||
CHECK_GL_ERR();
|
||||
glBindSampler(0, m_p_renderable->get_sampler()->get_sampler());
|
||||
CHECK_GL_ERR();
|
||||
}
|
||||
|
||||
void Batch::setup_vao()
|
||||
|
Loading…
Reference in New Issue
Block a user