Skip to content

Commit 3cd638b

Browse files
committed
change ktx format to enum
1 parent 25765df commit 3cd638b

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

code/graphics/opengl/gropengltexture.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static int opengl_texture_set_level(int bitmap_handle, int bitmap_type, int bmap
455455
case KTX_ETC2_SRGB_A1:
456456
case KTX_EAC_R11_SNORM:
457457
case KTX_EAC_RG11_SNORM:
458-
intFormat = ktx_map_ktx_type_to_gl_internal(bm_handle);
458+
intFormat = ktx_map_ktx_format_to_gl_internal(bm_handle);
459459
block_size = ktx_etc_block_bytes(intFormat);
460460
break;
461461
}
@@ -784,7 +784,7 @@ static GLenum opengl_get_internal_format(int handle, int bitmap_type, int bpp) {
784784
case KTX_ETC2_SRGB_A1:
785785
case KTX_EAC_R11_SNORM:
786786
case KTX_EAC_RG11_SNORM:
787-
return ktx_map_ktx_type_to_gl_internal(bm_handle);
787+
return ktx_map_ktx_format_to_gl_internal(bm_handle);
788788

789789
default:
790790
// Not compressed

code/ktxutils/ktxutils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
static const uint8_t KTX_ID[12] = { 0xAB, 'K', 'T', 'X', ' ', '1', '1', 0xBB, '\r', '\n', 0x1A, '\n' };
88

99
// BPB ETC/EAC
10-
uint32_t ktx_etc_block_bytes(GLenum internal_format)
10+
uint32_t ktx_etc_block_bytes(const int internal_format)
1111
{
1212
switch (internal_format)
1313
{
@@ -31,7 +31,7 @@ uint32_t ktx_etc_block_bytes(GLenum internal_format)
3131
}
3232

3333

34-
int ktx_map_ktx_type_to_gl_internal(unsigned int ktx_format)
34+
int ktx_map_ktx_format_to_gl_internal(const int ktx_format)
3535
{
3636
switch (ktx_format)
3737
{
@@ -60,7 +60,7 @@ int ktx_map_ktx_type_to_gl_internal(unsigned int ktx_format)
6060
}
6161
}
6262

63-
int ktx_map_gl_internal_to_bm(GLenum internal_format)
63+
int ktx_map_gl_internal_to_bm(const int internal_format)
6464
{
6565
switch (internal_format)
6666
{

code/ktxutils/ktxutils.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
#include "cfile/cfile.h"
44
#ifdef WITH_OPENGL
55
#include <glad/glad.h>
6-
#else
7-
#define GLenum int
86
#endif
97

108
// ETC2 types
11-
#define KTX_ETC2_RGB 101
12-
#define KTX_ETC2_RGBA_EAC 102
13-
#define KTX_EAC_R11 103
14-
#define KTX_EAC_RG11 104
15-
#define KTX_ETC2_SRGB 105
16-
#define KTX_ETC2_SRGBA_EAC 106
17-
#define KTX_ETC2_RGB_A1 107
18-
#define KTX_ETC2_SRGB_A1 108
19-
#define KTX_EAC_R11_SNORM 109
20-
#define KTX_EAC_RG11_SNORM 110
9+
enum KTX_Format {
10+
KTX_ETC2_RGB = 100,
11+
KTX_ETC2_RGBA_EAC,
12+
KTX_EAC_R11,
13+
KTX_EAC_RG11,
14+
KTX_ETC2_SRGB,
15+
KTX_ETC2_SRGBA_EAC,
16+
KTX_ETC2_RGB_A1,
17+
KTX_ETC2_SRGB_A1,
18+
KTX_EAC_R11_SNORM,
19+
KTX_EAC_RG11_SNORM
20+
};
2121

2222
// GLenum definitions, ETC2 is guarranted on ES 3.2, but in desktop GL it is supported from 4.3
2323
// glad loader is GL 3.2 and these definitions are not there. But these will work if the GPU is GL 4.3
@@ -80,6 +80,6 @@ int ktx1_read_header(const char* filename, CFILE* img_cfp, int* w, int* h, int*
8080

8181
int ktx1_read_bitmap(const char* filename, ubyte* dst, ubyte* out_bpp);
8282

83-
int ktx_map_ktx_type_to_gl_internal(unsigned int ktx_format);
83+
int ktx_map_ktx_format_to_gl_internal(const int ktx_format);
8484

85-
uint32_t ktx_etc_block_bytes(GLenum internal_format);
85+
uint32_t ktx_etc_block_bytes(const int internal_format);

0 commit comments

Comments
 (0)