2018-02-20 05:04:53 +00:00
|
|
|
#include "data/blob.h"
|
2018-01-21 05:33:09 +00:00
|
|
|
#include "util.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-12-08 16:44:28 +00:00
|
|
|
typedef enum {
|
|
|
|
FORMAT_RGB,
|
|
|
|
FORMAT_RGBA,
|
2017-12-09 18:07:05 +00:00
|
|
|
FORMAT_RGBA16F,
|
|
|
|
FORMAT_RGBA32F,
|
|
|
|
FORMAT_RG11B10F,
|
2017-12-08 16:44:28 +00:00
|
|
|
FORMAT_DXT1,
|
|
|
|
FORMAT_DXT3,
|
|
|
|
FORMAT_DXT5
|
2017-02-19 09:54:58 +00:00
|
|
|
} TextureFormat;
|
|
|
|
|
|
|
|
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 {
|
2018-03-11 05:28:22 +00:00
|
|
|
Blob blob;
|
2017-02-19 09:54:58 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
2018-03-11 05:28:22 +00:00
|
|
|
Blob* source;
|
2017-12-08 16:44:28 +00:00
|
|
|
TextureFormat format;
|
2018-01-14 21:21:34 +00:00
|
|
|
vec_mipmap_t mipmaps;
|
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);
|
2018-02-07 17:07:51 +00:00
|
|
|
Color lovrTextureDataGetPixel(TextureData* textureData, int x, int y);
|
|
|
|
void lovrTextureDataSetPixel(TextureData* textureData, int x, int y, Color color);
|
2018-02-09 04:17:50 +00:00
|
|
|
bool lovrTextureDataEncode(TextureData* textureData, const char* filename);
|
2018-02-26 08:59:03 +00:00
|
|
|
void lovrTextureDataDestroy(void* ref);
|