2017-04-02 12:55:21 +00:00
|
|
|
#include "filesystem/blob.h"
|
2017-09-23 03:29:46 +00:00
|
|
|
#include "lib/glfw.h"
|
2017-01-09 05:29:16 +00:00
|
|
|
#include <stdint.h>
|
2017-10-31 08:14:09 +00:00
|
|
|
#include <stdbool.h>
|
2016-11-26 07:54:45 +00:00
|
|
|
|
2017-02-19 09:54:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-11-23 22:19:20 +00:00
|
|
|
// WEBGL_compressed_texture_s3tc_srgb isn't ratified yet...
|
|
|
|
#ifdef EMSCRIPTEN
|
|
|
|
#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
|
|
|
|
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
|
|
|
|
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
|
|
|
|
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 10:11:43 +00:00
|
|
|
typedef struct {
|
2017-11-23 22:19:20 +00:00
|
|
|
struct {
|
|
|
|
GLenum linear;
|
|
|
|
GLenum srgb;
|
|
|
|
} glInternalFormat;
|
2017-07-22 10:11:43 +00:00
|
|
|
GLenum glFormat;
|
|
|
|
int blockBytes;
|
2017-10-31 08:14:09 +00:00
|
|
|
bool compressed;
|
2017-02-19 09:54:58 +00:00
|
|
|
} TextureFormat;
|
|
|
|
|
2017-07-22 10:14:36 +00:00
|
|
|
extern const TextureFormat FORMAT_RGB, FORMAT_RGBA, FORMAT_DXT1, FORMAT_DXT3, FORMAT_DXT5;
|
2017-07-22 10:11:43 +00:00
|
|
|
|
2017-02-19 09:54:58 +00:00
|
|
|
typedef struct {
|
2017-07-22 10:42:05 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
void* data;
|
|
|
|
size_t size;
|
|
|
|
} Mipmap;
|
2017-06-19 00:28:15 +00:00
|
|
|
|
2017-07-22 10:42:05 +00:00
|
|
|
typedef vec_t(Mipmap) vec_mipmap_t;
|
2017-06-19 00:28:15 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2017-02-19 09:54:58 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
TextureFormat format;
|
2017-06-19 00:28:15 +00:00
|
|
|
void* data;
|
2017-07-23 01:15:03 +00:00
|
|
|
union MipmapType {
|
|
|
|
vec_mipmap_t list;
|
2017-10-31 08:14:09 +00:00
|
|
|
bool generated;
|
2017-07-23 01:15:03 +00:00
|
|
|
} mipmaps;
|
2017-07-22 10:42:05 +00:00
|
|
|
Blob* blob;
|
2017-02-19 09:54:58 +00:00
|
|
|
} TextureData;
|
|
|
|
|
2017-02-03 23:16:30 +00:00
|
|
|
TextureData* lovrTextureDataGetBlank(int width, int height, uint8_t value, TextureFormat format);
|
2017-02-06 04:30:17 +00:00
|
|
|
TextureData* lovrTextureDataGetEmpty(int width, int height, TextureFormat format);
|
2017-04-02 12:55:21 +00:00
|
|
|
TextureData* lovrTextureDataFromBlob(Blob* blob);
|
2017-02-19 09:54:58 +00:00
|
|
|
void lovrTextureDataDestroy(TextureData* textureData);
|