From b25d345e7284a24b2da6c3552d126be6566fed9e Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 22 Jul 2017 03:14:36 -0700 Subject: [PATCH] Add compressed texture formats; --- src/graphics/graphics.c | 2 +- src/lib/glfw.h | 2 +- src/loaders/texture.c | 21 +++++++++++++++++++++ src/loaders/texture.h | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index a1ebcf9a..4f236c69 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -49,7 +49,7 @@ void lovrGraphicsInit() { // Initialize all the things glfwMakeContextCurrent(state.window); glfwSetWindowCloseCallback(state.window, onCloseWindow); -#ifdef _WIN32 +#ifndef LOVR_WEB gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); #endif glfwSetTime(0); diff --git a/src/lib/glfw.h b/src/lib/glfw.h index dee83c67..ff36e0b5 100644 --- a/src/lib/glfw.h +++ b/src/lib/glfw.h @@ -6,7 +6,7 @@ #define GLFW_INCLUDE_GLCOREARB #elif _WIN32 #define APIENTRY __stdcall -#include "glad/glad.h" #endif +#include "glad/glad.h" #include diff --git a/src/loaders/texture.c b/src/loaders/texture.c index 9e97ec1a..4b6ad6b4 100644 --- a/src/loaders/texture.c +++ b/src/loaders/texture.c @@ -17,6 +17,27 @@ const TextureFormat FORMAT_RGBA = { .blockBytes = 4 }; +const TextureFormat FORMAT_DXT1 = { + .glInternalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + .glFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + .compressed = 1, + .blockBytes = 8 +}; + +const TextureFormat FORMAT_DXT3 = { + .glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + .glFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + .compressed = 1, + .blockBytes = 16 +}; + +const TextureFormat FORMAT_DXT5 = { + .glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + .glFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + .compressed = 1, + .blockBytes = 16 +}; + TextureData* lovrTextureDataGetBlank(int width, int height, uint8_t value, TextureFormat format) { TextureData* textureData = malloc(sizeof(TextureData)); if (!textureData) return NULL; diff --git a/src/loaders/texture.h b/src/loaders/texture.h index 4fb1c700..cf1f1bb0 100644 --- a/src/loaders/texture.h +++ b/src/loaders/texture.h @@ -11,7 +11,7 @@ typedef struct { int compressed; } TextureFormat; -extern const TextureFormat FORMAT_RGB, FORMAT_RGBA; +extern const TextureFormat FORMAT_RGB, FORMAT_RGBA, FORMAT_DXT1, FORMAT_DXT3, FORMAT_DXT5; typedef struct {