mirror of https://github.com/bjornbytes/lovr.git
Fix texture reference counting;
This commit is contained in:
parent
00656b928e
commit
d014daaa53
|
@ -33,19 +33,23 @@ Texture* lovrTextureCreateFromBuffer(Buffer* buffer) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Texture* texture = malloc(sizeof(Texture));
|
||||
Texture* texture = lovrAlloc(sizeof(Texture), lovrTextureDestroy);
|
||||
if (!texture) return NULL;
|
||||
|
||||
glGenTextures(1, &texture->id);
|
||||
texture->buffer = buffer->vbo;
|
||||
texture->buffer = buffer;
|
||||
lovrTextureBind(texture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGB32F, buffer->vbo);
|
||||
lovrRetain(&buffer->ref);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
void lovrTextureDestroy(const Ref* ref) {
|
||||
Texture* texture = containerof(ref, Texture);
|
||||
if (texture->buffer) {
|
||||
lovrRelease(&texture->buffer->ref);
|
||||
}
|
||||
glDeleteTextures(1, &texture->id);
|
||||
free(texture);
|
||||
}
|
||||
|
@ -60,7 +64,7 @@ void lovrTextureRefresh(Texture* texture) {
|
|||
}
|
||||
|
||||
lovrTextureBind(texture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGB32F, texture->buffer);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGB32F, texture->buffer->vbo);
|
||||
}
|
||||
|
||||
int lovrTextureGetHeight(Texture* texture) {
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef enum {
|
|||
typedef struct {
|
||||
Ref ref;
|
||||
GLuint id;
|
||||
GLuint buffer;
|
||||
struct Buffer* buffer;
|
||||
int width;
|
||||
int height;
|
||||
FilterMode filterMin;
|
||||
|
|
Loading…
Reference in New Issue