mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
refactor & fix random deleting texture
This commit is contained in:
parent
e158b384fa
commit
8bb03a004f
7 changed files with 65 additions and 64 deletions
|
|
@ -60,17 +60,17 @@ void Batch2D::vertex(
|
|||
index++;
|
||||
}
|
||||
|
||||
void Batch2D::texture(const Texture* new_texture){
|
||||
if (currentTexture == new_texture) {
|
||||
void Batch2D::texture(const Texture* newTexture){
|
||||
if (currentTexture == newTexture) {
|
||||
return;
|
||||
}
|
||||
flush();
|
||||
currentTexture = new_texture;
|
||||
if (new_texture == nullptr) {
|
||||
currentTexture = newTexture;
|
||||
if (newTexture == nullptr) {
|
||||
blank->bind();
|
||||
region = blank->getUVRegion();
|
||||
} else {
|
||||
new_texture->bind();
|
||||
newTexture->bind();
|
||||
region = currentTexture->getUVRegion();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
Batch3D::Batch3D(size_t capacity)
|
||||
: capacity(capacity) {
|
||||
|
||||
|
||||
buffer = std::make_unique<Batch3DVertex[]>(capacity);
|
||||
mesh = std::make_unique<Mesh<Batch3DVertex>>(buffer.get(), 0);
|
||||
index = 0;
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@ Framebuffer::Framebuffer(uint width, uint height, bool alpha)
|
|||
// Setup color attachment (texture)
|
||||
texture = create_texture(width, height, format);
|
||||
|
||||
unsigned int attachments[1] = { GL_COLOR_ATTACHMENT0 };
|
||||
glDrawBuffers(1, attachments);
|
||||
|
||||
// Setup depth attachment
|
||||
glGenRenderbuffers(1, &depth);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, depth);
|
||||
|
|
@ -60,7 +57,7 @@ Framebuffer::Framebuffer(uint width, uint height, bool alpha)
|
|||
|
||||
Framebuffer::~Framebuffer() {
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
glDeleteTextures(1, &depth);
|
||||
glDeleteRenderbuffers(1, &depth);
|
||||
}
|
||||
|
||||
void Framebuffer::bind() {
|
||||
|
|
|
|||
|
|
@ -135,20 +135,21 @@ void PostProcessing::render(
|
|||
const auto& vp = context.getViewport();
|
||||
refreshFbos(vp.x, vp.y);
|
||||
|
||||
glActiveTexture(GL_TEXTURE4);
|
||||
glBindTexture(GL_TEXTURE_2D, shadowMap);
|
||||
|
||||
if (gbuffer) {
|
||||
gbuffer->bindBuffers();
|
||||
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, noiseTexture);
|
||||
|
||||
glActiveTexture(GL_TEXTURE4);
|
||||
glBindTexture(GL_TEXTURE_2D, shadowMap);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
} else {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
fbo->getTexture()->bind();
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
if (totalPasses == 0) {
|
||||
auto& effect = assets.require<PostEffect>("default");
|
||||
auto& shader = effect.use();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue