本文整理匯總了Golang中C.Uint16函數的典型用法代碼示例。如果您正苦於以下問題:Golang Uint16函數的具體用法?Golang Uint16怎麽用?Golang Uint16使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Uint16函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: toSDL_Rect
func toSDL_Rect(b util.Bounds) C.SDL_Rect {
var r C.SDL_Rect
r.x = C.Sint16(b.X)
r.y = C.Sint16(b.Y)
r.w = C.Uint16(b.Width)
r.h = C.Uint16(b.Height)
return r
}
示例2: sdl_Rect
func sdl_Rect(x, y, width, height int) C.SDL_Rect {
var r C.SDL_Rect
r.x = C.Sint16(x)
r.y = C.Sint16(y)
r.w = C.Uint16(width)
r.h = C.Uint16(height)
return r
}
示例3: OpenAudio
func OpenAudio(desired, obtained_orNil *AudioSpec) int {
if alreadyOpened {
panic("more than 1 audio stream currently not supported")
}
// copy handle to user-defined callback function, if defined
// it is perfectly supported to not specify the callback function
// in that case you will use default SendAudio semantics
// note that if you specify a callback and use SendAudio, a hangup will instead happen
// when calling SendAudio
if nil != desired.UserDefinedCallback {
userDefinedCallback = desired.UserDefinedCallback
} else {
// default playback (16-bit signed)
userDefinedCallback = DownstreamPlaybackS16
PlayLoop = make(chan AudioEvent)
}
var C_desired, C_obtained *C.SDL_AudioSpec
C_desired = new(C.SDL_AudioSpec)
C_desired.freq = C.int(desired.Freq)
C_desired.format = C.Uint16(desired.Format)
C_desired.channels = C.Uint8(desired.Channels)
C_desired.samples = C.Uint16(desired.Samples)
// there is an unique C callback acting as proxy to the different Go callbacks
// see streamContext()
C_desired.callback = C.callback_getCallback()
if obtained_orNil != nil {
if desired != obtained_orNil {
C_obtained = new(C.SDL_AudioSpec)
} else {
C_obtained = C_desired
}
}
status := C.SDL_OpenAudio(C_desired, C_obtained)
if status == 0 {
alreadyOpened = true
}
if obtained_orNil != nil {
obtained := obtained_orNil
obtained.Freq = int(C_obtained.freq)
obtained.Format = uint16(C_obtained.format)
obtained.Channels = uint8(C_obtained.channels)
obtained.Samples = uint16(C_obtained.samples)
obtained.Out_Silence = uint8(C_obtained.silence)
obtained.Out_Size = uint32(C_obtained.size)
}
return int(status)
}
示例4: convertRect
func convertRect(rect image.Rectangle) C.SDL_Rect {
rect = rect.Canon()
return C.SDL_Rect{
C.Sint16(rect.Min.X),
C.Sint16(rect.Min.Y),
C.Uint16(rect.Max.X - rect.Min.X),
C.Uint16(rect.Max.Y - rect.Min.Y),
}
}
示例5: OpenMixer
// Open the mixer with a certain audio format
func OpenMixer(frequency int, format uint16, channels int, chunksize int) (bool) {
res := (int(C.Mix_OpenAudio(C.int(frequency),
C.Uint16(format), C.int( channels), C.int(chunksize))))
ok := (res == 0)
MixerOpened = ok
return ok
}
示例6: routine
func (d *Display) routine() {
rect := C.SDL_Rect{x: 0, y: 0, w: C.Uint16(d.width), h: C.Uint16(d.height)}
for d.rendering {
frame := <-d.frame
C.SDL_LockYUVOverlay(d.overlay)
pixels := (*[1 << 30]*C.Uint8)(unsafe.Pointer(d.overlay.pixels))
pitches := (*[1 << 30]C.Uint8)(unsafe.Pointer(d.overlay.pitches))
pixels[0] = (*C.Uint8)(frame.data[0])
pixels[1] = (*C.Uint8)(frame.data[1])
pixels[2] = (*C.Uint8)(frame.data[2])
pitches[0] = (C.Uint8)(frame.linesize[0])
pitches[1] = (C.Uint8)(frame.linesize[1])
pitches[2] = (C.Uint8)(frame.linesize[2])
C.SDL_UnlockYUVOverlay(d.overlay)
C.SDL_DisplayYUVOverlay(d.overlay, &rect)
}
}
示例7: GlyphMetrics
// Returns the metrics (dimensions) of a glyph.
//
// Return values are:
// minx, maxx, miny, maxy, advance, err
//
// The last return value (err) is 0 for success, -1 for any error (for example
// if the glyph is not available in this font).
//
// For more information on glyph metrics, visit
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, int) {
minx := C.int(0)
maxx := C.int(0)
miny := C.int(0)
maxy := C.int(0)
advance := C.int(0)
err := C.TTF_GlyphMetrics(f.cfont, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)
return int(minx), int(maxx), int(miny), int(maxy), int(advance), int(err)
}
示例8: TTFGlyphMetrics
// Get the metrics (dimensions) of a glyph
// To understand what these metrics mean, here is a useful link:
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
// retuns minx, maxx, miny, maxy, advance
func TTFGlyphMetrics(font *C.TTF_Font, ch uint16) (int, int, int, int, int) {
var minx, maxx, miny, maxy, advance int
pminx := cintptr(&minx)
pmaxx := cintptr(&maxx)
pminy := cintptr(&miny)
pmaxy := cintptr(&maxy)
padv := cintptr(&advance)
C.TTF_GlyphMetrics(font, C.Uint16(ch), pminx, pmaxx, pminy, pmaxy, padv)
return minx, maxx, miny, maxy, advance
}
示例9: cAudioInfo
func cAudioInfo(info *AudioInfo) *C.Sound_AudioInfo {
if info == nil {
return nil
}
cinfo := new(C.Sound_AudioInfo)
cinfo.format = C.Uint16(info.Format)
cinfo.channels = C.Uint8(info.Channels)
cinfo.rate = C.Uint32(info.Rate)
return cinfo
}
示例10: GlyphMetrics
// Returns the metrics (dimensions) of a glyph.
//
// Return values are:
// minx, maxx, miny, maxy, advance, err
//
// For more information on glyph metrics, visit
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, error) {
minx := C.int(0)
maxx := C.int(0)
miny := C.int(0)
maxy := C.int(0)
advance := C.int(0)
err := C.TTF_GlyphMetrics(f.cfont, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)
if int(err) != 0 {
return int(minx), int(maxx), int(miny), int(maxy), int(advance), sdl.NewSDLError()
}
return int(minx), int(maxx), int(miny), int(maxy), int(advance), nil
}
示例11: OpenAudio
func OpenAudio(desired, obtained_orNil *AudioSpec) int {
var C_desired, C_obtained *C.SDL_AudioSpec
C_desired = new(C.SDL_AudioSpec)
C_desired.freq = C.int(desired.Freq)
C_desired.format = C.Uint16(desired.Format)
C_desired.channels = C.Uint8(desired.Channels)
C_desired.samples = C.Uint16(desired.Samples)
C_desired.callback = C.callback_getCallback()
if obtained_orNil != nil {
if desired != obtained_orNil {
C_obtained = new(C.SDL_AudioSpec)
} else {
C_obtained = C_desired
}
}
status := C.SDL_OpenAudio(C_desired, C_obtained)
if status == 0 {
mutex.Lock()
opened++
mutex.Unlock()
}
if obtained_orNil != nil {
obtained := obtained_orNil
obtained.Freq = int(C_obtained.freq)
obtained.Format = uint16(C_obtained.format)
obtained.Channels = uint8(C_obtained.channels)
obtained.Samples = uint16(C_obtained.samples)
obtained.Out_Silence = uint8(C_obtained.silence)
obtained.Out_Size = uint32(C_obtained.size)
}
return int(status)
}
示例12: GlyphMetrics
func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, error) {
minx := C.int(0)
maxx := C.int(0)
miny := C.int(0)
maxy := C.int(0)
advance := C.int(0)
res := C.TTF_GlyphMetrics(f.c, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)
var err error
if res != 0 {
err = getError()
}
return int(minx), int(maxx), int(miny), int(maxy), int(advance), err
}
示例13: GlyphMetrics
// Returns the metrics (dimensions) of a glyph.
//
// Return values are:
// minx, maxx, miny, maxy, advance, err
//
// The last return value (err) is 0 for success, -1 for any error (for example
// if the glyph is not available in this font).
//
// For more information on glyph metrics, visit
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, int) {
sdl.GlobalMutex.Lock() // Because the underlying C code is fairly complex
f.mutex.Lock() // Use a write lock, because 'C.TTF_GlyphMetrics' may update font's internal caches
minx := C.int(0)
maxx := C.int(0)
miny := C.int(0)
maxy := C.int(0)
advance := C.int(0)
err := C.TTF_GlyphMetrics(f.cfont, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)
sdl.GlobalMutex.Unlock()
f.mutex.Unlock()
return int(minx), int(maxx), int(miny), int(maxy), int(advance), int(err)
}
示例14: OpenAudio
func OpenAudio(desired, obtained *AudioSpec, callback func(*byte, int)) bool {
var cdesired C.SDL_AudioSpec
var cobtained C.SDL_AudioSpec
cdesired.freq = C.int(desired.Freq)
cdesired.format = C.SDL_AudioFormat(int(desired.Format))
cdesired.channels = C.Uint8(desired.Channels)
cdesired.samples = C.Uint16(desired.Samples)
cdesired.size = C.Uint32(0)
cdesired.callback = C.go_sdl2_get_callback()
cdesired.userdata = unsafe.Pointer(&callback)
ret := C.SDL_OpenAudio(&cdesired, &cobtained)
if obtained != nil {
obtained.Freq = int32(cobtained.freq)
obtained.Format = AudioFormat(int(cobtained.format))
obtained.Channels = uint8(cobtained.channels)
obtained.Silence = uint8(cobtained.silence)
obtained.Samples = uint16(cobtained.samples)
obtained.Size = uint32(cobtained.size)
}
return int(ret) == 0
}
示例15: Init
func Init(initSDL, stereo bool, rate, nchannels, nbuffers int) {
if initSDL {
GSDLWasInitHere = true
if C.SDL_Init(C.SDL_INIT_AUDIO) != 0 {
panic(fmt.Sprintf("Unable to initialize SDL: %v\n", util.GetSdlError()))
}
}
//initFlags := C.MIX_INIT_FLAC | C.MIX_INIT_MP3 | C.MIX_INIT_OGG
//C.Mix_Init(initFlags)
audio_format := C.AUDIO_S16SYS
nstereo := 1
if stereo {
nstereo = 2
}
if C.Mix_OpenAudio(C.int(rate), C.Uint16(audio_format),
C.int(nstereo), C.int(nbuffers)) != 0 {
panic(fmt.Sprintf("Unable to initialize audio: %v\n", util.GetMixError()))
}
channel.Allocate(nchannels)
}