lovr/src/graphics/texture.h

65 lines
1.7 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
2017-01-11 17:22:18 +00:00
struct CanvasState;
2016-11-14 01:28:22 +00:00
2016-11-08 11:14:33 +00:00
#ifndef LOVR_TEXTURE_TYPES
#define LOVR_TEXTURE_TYPES
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;
2017-01-12 07:38:28 +00:00
typedef enum {
PROJECTION_ORTHOGRAPHIC,
PROJECTION_PERSPECTIVE
} TextureProjection;
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-15 01:38:25 +00:00
GLuint msaaId;
2017-01-12 07:38:28 +00:00
GLuint framebuffer;
2017-01-15 01:38:25 +00:00
GLuint resolveFramebuffer;
GLuint depthBuffer;
2017-01-12 07:38:28 +00:00
TextureProjection projection;
2016-11-08 22:44:22 +00:00
FilterMode filterMin;
FilterMode filterMag;
WrapMode wrapHorizontal;
WrapMode wrapVertical;
2017-01-15 01:38:25 +00:00
int msaa;
2016-11-08 11:14:33 +00:00
} Texture;
#endif
2017-01-12 07:38:28 +00:00
Texture* lovrTextureCreate(TextureData* textureData);
2017-01-15 01:38:25 +00:00
Texture* lovrTextureCreateWithFramebuffer(TextureData* textureData, TextureProjection projection, int msaa);
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);
2017-01-12 04:26:08 +00:00
void lovrTextureBindFramebuffer(Texture* texture);
2017-01-15 01:38:25 +00:00
void lovrTextureResolveMSAA(Texture* texture);
2016-11-17 09:30:40 +00:00
void lovrTextureRefresh(Texture* texture);
2016-11-08 11:14:33 +00:00
int lovrTextureGetHeight(Texture* texture);
int lovrTextureGetWidth(Texture* texture);
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);