1/**
2 * Copyright (c) 2006-2023 LOVE Development Team
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
19 **/
20
21#pragma once
22
23#include "stddef.h"
24
25namespace love
26{
27
28enum PixelFormat
29{
30 PIXELFORMAT_UNKNOWN,
31
32 // these are converted to an actual format by love
33 PIXELFORMAT_NORMAL,
34 PIXELFORMAT_HDR,
35
36 // "regular" formats
37 PIXELFORMAT_R8,
38 PIXELFORMAT_RG8,
39 PIXELFORMAT_RGBA8,
40 PIXELFORMAT_sRGBA8,
41 PIXELFORMAT_R16,
42 PIXELFORMAT_RG16,
43 PIXELFORMAT_RGBA16,
44 PIXELFORMAT_R16F,
45 PIXELFORMAT_RG16F,
46 PIXELFORMAT_RGBA16F,
47 PIXELFORMAT_R32F,
48 PIXELFORMAT_RG32F,
49 PIXELFORMAT_RGBA32F,
50
51 PIXELFORMAT_LA8, // Same as RG8, but accessed as (L, L, L, A)
52
53 // packed formats
54 PIXELFORMAT_RGBA4, // LSB->MSB: [a, b, g, r]
55 PIXELFORMAT_RGB5A1, // LSB->MSB: [a, b, g, r]
56 PIXELFORMAT_RGB565, // LSB->MSB: [b, g, r]
57 PIXELFORMAT_RGB10A2, // LSB->MSB: [r, g, b, a]
58 PIXELFORMAT_RG11B10F, // LSB->MSB: [r, g, b]
59
60 // depth/stencil formats
61 PIXELFORMAT_STENCIL8,
62 PIXELFORMAT_DEPTH16,
63 PIXELFORMAT_DEPTH24,
64 PIXELFORMAT_DEPTH32F,
65 PIXELFORMAT_DEPTH24_STENCIL8,
66 PIXELFORMAT_DEPTH32F_STENCIL8,
67
68 // compressed formats
69 PIXELFORMAT_DXT1,
70 PIXELFORMAT_DXT3,
71 PIXELFORMAT_DXT5,
72 PIXELFORMAT_BC4,
73 PIXELFORMAT_BC4s,
74 PIXELFORMAT_BC5,
75 PIXELFORMAT_BC5s,
76 PIXELFORMAT_BC6H,
77 PIXELFORMAT_BC6Hs,
78 PIXELFORMAT_BC7,
79 PIXELFORMAT_PVR1_RGB2,
80 PIXELFORMAT_PVR1_RGB4,
81 PIXELFORMAT_PVR1_RGBA2,
82 PIXELFORMAT_PVR1_RGBA4,
83 PIXELFORMAT_ETC1,
84 PIXELFORMAT_ETC2_RGB,
85 PIXELFORMAT_ETC2_RGBA,
86 PIXELFORMAT_ETC2_RGBA1,
87 PIXELFORMAT_EAC_R,
88 PIXELFORMAT_EAC_Rs,
89 PIXELFORMAT_EAC_RG,
90 PIXELFORMAT_EAC_RGs,
91 PIXELFORMAT_ASTC_4x4,
92 PIXELFORMAT_ASTC_5x4,
93 PIXELFORMAT_ASTC_5x5,
94 PIXELFORMAT_ASTC_6x5,
95 PIXELFORMAT_ASTC_6x6,
96 PIXELFORMAT_ASTC_8x5,
97 PIXELFORMAT_ASTC_8x6,
98 PIXELFORMAT_ASTC_8x8,
99 PIXELFORMAT_ASTC_10x5,
100 PIXELFORMAT_ASTC_10x6,
101 PIXELFORMAT_ASTC_10x8,
102 PIXELFORMAT_ASTC_10x10,
103 PIXELFORMAT_ASTC_12x10,
104 PIXELFORMAT_ASTC_12x12,
105
106 PIXELFORMAT_MAX_ENUM
107};
108
109bool getConstant(PixelFormat in, const char *&out);
110bool getConstant(const char *in, PixelFormat &out);
111
112/**
113 * Gets whether the specified pixel format is a compressed type.
114 **/
115bool isPixelFormatCompressed(PixelFormat format);
116
117/**
118 * Gets whether the specified pixel format is a depth or stencil type.
119 **/
120bool isPixelFormatDepthStencil(PixelFormat format);
121
122/**
123 * Gets whether the specified pixel format is a depth type.
124 **/
125bool isPixelFormatDepth(PixelFormat format);
126
127/**
128 * Gets whether the specified pixel format is a stencil type.
129 **/
130bool isPixelFormatStencil(PixelFormat format);
131
132/**
133 * Gets the size in bytes of the specified pixel format.
134 * NOTE: Currently returns 0 for compressed formats.
135 **/
136size_t getPixelFormatSize(PixelFormat format);
137
138/**
139 * Gets the number of color components in the given pixel format.
140 **/
141int getPixelFormatColorComponents(PixelFormat format);
142
143} // love
144