1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-03 04:53:35 +00:00
lovr/src/graphics/texture.h

57 lines
1.5 KiB
C
Raw Normal View History

2016-11-19 09:28:01 +00:00
#include "glfw.h"
2016-11-19 07:41:23 +00:00
#include "util.h"
2016-11-08 11:14:33 +00:00
2016-11-14 01:28:22 +00:00
struct Buffer;
2016-11-08 11:14:33 +00:00
#ifndef LOVR_TEXTURE_TYPES
#define LOVR_TEXTURE_TYPES
2017-01-09 06:51:43 +00:00
typedef void (*textureRenderCallback)(void*);
2016-11-26 07:54:45 +00:00
typedef struct {
void* data;
int width;
int height;
int channels;
} TextureData;
2016-11-08 22:44:22 +00:00
typedef enum {
FILTER_NEAREST = GL_NEAREST,
FILTER_LINEAR = GL_LINEAR
} FilterMode;
typedef enum {
WRAP_CLAMP = GL_CLAMP_TO_EDGE,
WRAP_REPEAT = GL_REPEAT,
WRAP_MIRRORED_REPEAT = GL_MIRRORED_REPEAT,
WRAP_CLAMP_ZERO = GL_CLAMP_TO_BORDER
} WrapMode;
2016-11-08 11:14:33 +00:00
typedef struct {
2016-11-19 07:41:23 +00:00
Ref ref;
2016-11-26 07:54:45 +00:00
TextureData* textureData;
2016-11-08 11:14:33 +00:00
GLuint id;
2017-01-09 06:51:43 +00:00
GLuint fbo;
2016-11-08 11:14:33 +00:00
int width;
int height;
2016-11-08 22:44:22 +00:00
FilterMode filterMin;
FilterMode filterMag;
WrapMode wrapHorizontal;
WrapMode wrapVertical;
2016-11-08 11:14:33 +00:00
} Texture;
#endif
2017-01-09 06:51:43 +00:00
Texture* lovrTextureCreate(TextureData* textureData, int hasFramebuffer);
2016-11-19 07:41:23 +00:00
void lovrTextureDestroy(const Ref* ref);
2016-11-26 07:54:45 +00:00
void lovrTextureDataDestroy(TextureData* textureData);
2016-11-17 09:30:40 +00:00
void lovrTextureBind(Texture* texture);
void lovrTextureRefresh(Texture* texture);
2016-11-08 11:14:33 +00:00
int lovrTextureGetHeight(Texture* texture);
int lovrTextureGetWidth(Texture* texture);
2017-01-09 06:51:43 +00:00
void lovrTextureRenderTo(Texture* texture, textureRenderCallback callback, void* userdata);
2016-11-08 22:44:22 +00:00
void lovrTextureGetFilter(Texture* texture, FilterMode* min, FilterMode* mag);
void lovrTextureSetFilter(Texture* texture, FilterMode min, FilterMode mag);
void lovrTextureGetWrap(Texture* texture, WrapMode* horizontal, WrapMode* vertical);
void lovrTextureSetWrap(Texture* texture, WrapMode horizontal, WrapMode vertical);