remove LocationPointType and MaterialMapType, remain using const values

This commit is contained in:
jackji 2021-06-22 22:10:29 +08:00
parent 15ed58856b
commit 698c972d9f

View file

@ -716,10 +716,8 @@ const (
) )
// Shader location point type // Shader location point type
type LocationPointType int32
const ( const (
LocVertexPosition LocationPointType = iota LocVertexPosition = iota
LocVertexTexcoord01 LocVertexTexcoord01
LocVertexTexcoord02 LocVertexTexcoord02
LocVertexNormal LocVertexNormal
@ -748,10 +746,8 @@ const (
) )
// Material map type // Material map type
type MaterialMapType int32
const ( const (
MapAlbedo MaterialMapType = iota MapAlbedo = iota
MapMetalness MapMetalness
MapNormal MapNormal
MapRoughness MapRoughness
@ -835,7 +831,7 @@ func newMaterialFromPointer(ptr unsafe.Pointer) Material {
} }
// GetMap - Get pointer to MaterialMap by map type // GetMap - Get pointer to MaterialMap by map type
func (mt Material) GetMap(index MaterialMapType) *MaterialMap { func (mt Material) GetMap(index int32) *MaterialMap {
return (*MaterialMap)(unsafe.Pointer(uintptr(unsafe.Pointer(mt.Maps)) + uintptr(index)*uintptr(unsafe.Sizeof(MaterialMap{})))) return (*MaterialMap)(unsafe.Pointer(uintptr(unsafe.Pointer(mt.Maps)) + uintptr(index)*uintptr(unsafe.Sizeof(MaterialMap{}))))
} }
@ -930,12 +926,12 @@ func newShaderFromPointer(ptr unsafe.Pointer) Shader {
} }
// GetLocation - Get shader value's location // GetLocation - Get shader value's location
func (sh Shader) GetLocation(index LocationPointType) int32 { func (sh Shader) GetLocation(index int32) int32 {
return *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(sh.Locs)) + uintptr(index*4))) return *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(sh.Locs)) + uintptr(index*4)))
} }
// UpdateLocation - Update shader value's location // UpdateLocation - Update shader value's location
func (sh Shader) UpdateLocation(index LocationPointType, loc int32) { func (sh Shader) UpdateLocation(index int32, loc int32) {
*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(sh.Locs)) + uintptr(index*4))) = loc *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(sh.Locs)) + uintptr(index*4))) = loc
} }