lovr/src/graphics/texture.h

71 lines
1.6 KiB
C
Raw Normal View History

2017-02-19 09:54:58 +00:00
#include "loaders/texture.h"
#include "lib/glfw.h"
2016-11-19 07:41:23 +00:00
#include "util.h"
2016-11-08 11:14:33 +00:00
2017-01-26 10:20:30 +00:00
#pragma once
2016-11-08 11:14:33 +00:00
2017-10-15 23:56:00 +00:00
typedef enum {
TEXTURE_2D = GL_TEXTURE_2D,
TEXTURE_CUBE = GL_TEXTURE_CUBE_MAP
} TextureType;
2016-11-08 22:44:22 +00:00
typedef enum {
FILTER_NEAREST,
FILTER_BILINEAR,
FILTER_TRILINEAR,
FILTER_ANISOTROPIC
2016-11-08 22:44:22 +00:00
} FilterMode;
2017-08-02 07:29:47 +00:00
typedef struct {
FilterMode mode;
float anisotropy;
} TextureFilter;
2016-11-08 22:44:22 +00:00
typedef enum {
WRAP_CLAMP = GL_CLAMP_TO_EDGE,
WRAP_REPEAT = GL_REPEAT,
WRAP_MIRRORED_REPEAT = GL_MIRRORED_REPEAT
2016-11-08 22:44:22 +00:00
} WrapMode;
2017-10-15 23:56:00 +00:00
typedef struct {
WrapMode s;
WrapMode t;
WrapMode r;
} TextureWrap;
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;
2017-10-15 23:56:00 +00:00
TextureType type;
TextureData* slices[6];
int sliceCount;
int width;
int height;
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;
2017-08-02 07:29:47 +00:00
TextureFilter filter;
2017-10-15 23:56:00 +00:00
TextureWrap wrap;
2017-01-15 01:38:25 +00:00
int msaa;
2016-11-08 11:14:33 +00:00
} Texture;
2017-06-10 23:25:46 +00:00
GLenum lovrTextureGetGLFormat(TextureFormat format);
2017-10-15 23:56:00 +00:00
Texture* lovrTextureCreate(TextureType type, TextureData* data[6], int count);
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);
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);
2017-08-02 07:29:47 +00:00
TextureFilter lovrTextureGetFilter(Texture* texture);
void lovrTextureSetFilter(Texture* texture, TextureFilter filter);
2017-10-15 23:56:00 +00:00
TextureWrap lovrTextureGetWrap(Texture* texture);
void lovrTextureSetWrap(Texture* texture, TextureWrap wrap);