hopefully fixed clown vomit issue

This commit is contained in:
Shweet 2024-09-25 12:08:49 -04:00
parent 8931fe54d4
commit 664e33cb79
5 changed files with 22 additions and 5 deletions

View File

@ -142,6 +142,12 @@ renderer_buffer_use(Renderer* self, RendererBuffer buffer)
fbo_bind(&self->fbos[buffer]); fbo_bind(&self->fbos[buffer]);
} }
void
renderer_buffer_clear(Renderer* self, RendererBuffer buffer)
{
texture_clear(&self->fboTextures[buffer]);
}
void void
renderer_buffer_unbind(void) renderer_buffer_unbind(void)
{ {

View File

@ -47,6 +47,7 @@ void renderer_free(Renderer* self);
void renderer_update(Renderer* self); void renderer_update(Renderer* self);
void renderer_present(Renderer* self); void renderer_present(Renderer* self);
void renderer_buffer_unbind(void); void renderer_buffer_unbind(void);
void renderer_buffer_clear(Renderer* self, RendererBuffer buffer);
void renderer_buffer_position_from_window_position void renderer_buffer_position_from_window_position
( (

View File

@ -82,3 +82,11 @@ texture_free(Texture* self)
glDeleteTextures(1, &self->handle); glDeleteTextures(1, &self->handle);
memset(self, '\0', sizeof(Texture)); memset(self, '\0', sizeof(Texture));
} }
void
texture_clear(Texture* self)
{
texture_bind(self);
glClearTexImage(self->handle, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
texture_unbind();
}

View File

@ -20,6 +20,7 @@ typedef struct Texture
bool texture_from_path_init(Texture* self, const char* path); bool texture_from_path_init(Texture* self, const char* path);
void texture_init(Texture* self, ivec2 size, void* data); void texture_init(Texture* self, ivec2 size, void* data);
void texture_surface_init(Texture* self, SDL_Surface* surface); void texture_surface_init(Texture* self, SDL_Surface* surface);
void texture_clear(Texture* self);
void texture_parameter_set(GLenum pname, GLint parameter); void texture_parameter_set(GLenum pname, GLint parameter);
void texture_bind(Texture* self); void texture_bind(Texture* self);
void texture_unbind(void); void texture_unbind(void);

View File

@ -14,6 +14,8 @@ _game_quit(Game* self)
ecs_free(&self->ecs); ecs_free(&self->ecs);
renderer_free(&self->renderer);
window_free(&self->window); window_free(&self->window);
resources_free(&self->resources); resources_free(&self->resources);
@ -67,7 +69,7 @@ _game_draw(Game* self)
renderer_clear(&self->renderer); renderer_clear(&self->renderer);
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++) for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
renderer_buffer_init(&self->renderer, (RendererBuffer)i); renderer_buffer_clear(&self->renderer, (RendererBuffer)i);
ecs_draw(&self->ecs); ecs_draw(&self->ecs);
@ -80,7 +82,6 @@ _game_draw(Game* self)
(RendererBuffer)i, (RendererBuffer)i,
&self->postprocessing[i] &self->postprocessing[i]
); );
renderer_buffer_free(&self->renderer, (RendererBuffer)i);
} }
renderer_present(&self->renderer); renderer_present(&self->renderer);