本文整理汇总了Golang中C.SDL_ListModes函数的典型用法代码示例。如果您正苦于以下问题:Golang SDL_ListModes函数的具体用法?Golang SDL_ListModes怎么用?Golang SDL_ListModes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_ListModes函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ListModes
// Returns the list of available screen dimensions for the given format.
//
// NOTE: The result of this function uses a different encoding than the underlying C function.
// It returns an empty array if no modes are available,
// and nil if any dimension is okay for the given format.
func ListModes(format *PixelFormat, flags uint32) []Rect {
modes := C.SDL_ListModes((*C.SDL_PixelFormat)(cast(format)), C.Uint32(flags))
// No modes available
if modes == nil {
return make([]Rect, 0)
}
// (modes == -1) --> Any dimension is ok
if uintptr(unsafe.Pointer(modes))+1 == uintptr(0) {
return nil
}
count := 0
ptr := *modes //first element in the list
for ptr != nil {
count++
ptr = *(**C.SDL_Rect)(unsafe.Pointer(uintptr(unsafe.Pointer(modes)) + uintptr(count*unsafe.Sizeof(ptr))))
}
ret := make([]Rect, count)
for i := 0; i < count; i++ {
ptr := (**C.SDL_Rect)(unsafe.Pointer(uintptr(unsafe.Pointer(modes)) + uintptr(i*unsafe.Sizeof(*modes))))
var r *C.SDL_Rect = *ptr
ret[i].X = int16(r.x)
ret[i].Y = int16(r.y)
ret[i].W = uint16(r.w)
ret[i].H = uint16(r.h)
}
return ret
}
示例2: ListModes
func ListModes(pixelFormat *PixelFormat, flags SurfaceFlags) []Rect {
var c_format *C.SDL_PixelFormat
if pixelFormat != nil {
c_format = (*C.SDL_PixelFormat)(unsafe.Pointer(pixelFormat))
}
c_flags := C.Uint32(flags)
ret := C.SDL_ListModes(c_format, c_flags)
modes := []Rect{}
walkArray(unsafe.Pointer(ret), func(v unsafe.Pointer) {
modes = append(modes, *(*Rect)(v))
})
return modes
}
示例3: ListModes
func ListModes(format *PixelFormat, flags uint32) []*Rect {
modes := C.SDL_ListModes((*C.SDL_PixelFormat)(cast(format)), C.Uint32(flags))
if modes == nil { //modes == 0, no modes available
return make([]*Rect, 0)
}
if ^uintptr(unsafe.Pointer(modes)) == 0 { //modes == -1, any dimension is ok
return nil
}
var ret = make([]*Rect, C.vectorLength((*unsafe.Pointer)(unsafe.Pointer(modes))))
*((***C.SDL_Rect)(unsafe.Pointer(&ret))) = modes // TODO
return ret
}
示例4: ListModes
func ListModes(format *PixelFormat, flags uint32) []Rect {
modes := C.SDL_ListModes((*C.SDL_PixelFormat)(cast(format)), C.Uint32(flags))
if modes == nil { //no modes available
return make([]Rect, 0)
}
var any int
*((***C.SDL_Rect)(unsafe.Pointer(&any))) = modes
if any == -1 { //any dimension is ok
return nil
}
var count int
ptr := *modes //first element in the list
for count = 0; ptr != nil; count++ {
ptr = *(**C.SDL_Rect)(unsafe.Pointer(uintptr(unsafe.Pointer(modes)) + uintptr(uintptr(count)*unsafe.Sizeof(ptr))))
}
var ret = make([]Rect, count-1)
*((***C.SDL_Rect)(unsafe.Pointer(&ret))) = modes // TODO
return ret
}