/
texture.go
115 lines (95 loc) · 2.85 KB
/
texture.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package core
import "unsafe"
// TextureTarget specifies a texture target type (1D, 2D, 2DArray, Cubemap, etc)
type TextureTarget int
// TextureTargetXXX are the different texture types
const (
TextureTarget1D TextureTarget = iota
TextureTarget1DArray
TextureTarget2D
TextureTarget2DArray
TextureTargetCubemapXPositive
TextureTargetCubemapXNegative
TextureTargetCubemapYPositive
TextureTargetCubemapYNegative
TextureTargetCubemapZPositive
TextureTargetCubemapZNegative
)
// TextureFormat holds the texture component layout
type TextureFormat int
// These are the several supported texture component layouts
const (
TextureFormatR TextureFormat = iota
TextureFormatRG
TextureFormatRGB
TextureFormatRGBA
TextureFormatDEPTH
)
// TextureSizedFormat specified the format and size of a texture's components
type TextureSizedFormat int
// These are the several supportex texture component sizes
const (
TextureSizedFormatR8 TextureSizedFormat = iota
TextureSizedFormatR16F
TextureSizedFormatR32F
TextureSizedFormatRG8
TextureSizedFormatRG16F
TextureSizedFormatRG32F
TextureSizedFormatRGB8
TextureSizedFormatRGB16F
TextureSizedFormatRGB32F
TextureSizedFormatRGBA8
TextureSizedFormatRGBA16F
TextureSizedFormatRGBA32F
TextureSizedFormatDEPTH32F
)
// TextureComponentType specifies the texture component storage type
type TextureComponentType int
// These are the supported texture component storate types
const (
TextureComponentTypeUNSIGNEDBYTE TextureComponentType = iota
TextureComponentTypeFLOAT
)
// TextureWrapMode specifies the type of wrap around a sampler of this texture will use
type TextureWrapMode int
// These are the supported texture wrap modes
const (
TextureWrapModeClampEdge TextureWrapMode = iota
TextureWrapModeClampBorder
TextureWrapModeRepeat
)
// TextureFilter specifies the type of interpolation a sampler of this texture will use
type TextureFilter int
// These are the supported texture filtering modes
const (
TextureFilterNearest TextureFilter = iota
TextureFilterLinear
TextureFilterMipmapLinear
)
// TextureDescriptor contains the full description of a texture and its sampling parameters
// It is used as input to texture creation functions and at runtime inside rendersystems
// to setup samplers and memory allocation
type TextureDescriptor struct {
Width uint32
Height uint32
Mipmaps bool
Target TextureTarget
Format TextureFormat
SizedFormat TextureSizedFormat
ComponentType TextureComponentType
Filter TextureFilter
WrapMode TextureWrapMode
}
// Texture is an interface which wraps both a texture and settings for samplers sampling it
type Texture interface {
Descriptor() TextureDescriptor
Handle() unsafe.Pointer
// Lt is used for sorting
Lt(Texture) bool
// Gt
Gt(Texture) bool
// SetFilter
SetFilter(TextureFilter)
// SetWrapMode
SetWrapMode(TextureWrapMode)
}