本文整理匯總了Golang中C.Sint32函數的典型用法代碼示例。如果您正苦於以下問題:Golang Sint32函數的具體用法?Golang Sint32怎麽用?Golang Sint32使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Sint32函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UpdateRect
func (this Surface) UpdateRect(rect Rect) {
c_surface := (*C.SDL_Surface)(this.Ptr)
c_x := C.Sint32(rect.X)
c_y := C.Sint32(rect.Y)
c_w := C.Uint32(rect.W)
c_h := C.Uint32(rect.H)
C.SDL_UpdateRect(c_surface, c_x, c_y, c_w, c_h)
}
示例2: UpdateRect
// Makes sure the given area is updated on the given screen. If x, y, w, and
// h are all 0, the whole screen will be updated.
func (screen *Surface) UpdateRect(x int32, y int32, w uint32, h uint32) {
GlobalMutex.Lock()
screen.mutex.Lock()
C.SDL_UpdateRect(screen.cSurface, C.Sint32(x), C.Sint32(y), C.Uint32(w), C.Uint32(h))
screen.mutex.Unlock()
GlobalMutex.Unlock()
}
示例3: UpdateRect
// Makes sure the given area is updated on the given screen. If x, y, w, and
// h are all 0, the whole screen will be updated.
func (screen *Surface) UpdateRect(x int32, y int32, w uint32, h uint32) {
C.SDL_UpdateRect((*C.SDL_Surface)(cast(screen)), C.Sint32(x), C.Sint32(y), C.Uint32(w), C.Uint32(h))
}
示例4: main
func main() {
runtime.GOMAXPROCS(32)
// sdl
C.SDL_Init(C.SDL_INIT_AUDIO | C.SDL_INIT_VIDEO | C.SDL_INIT_TIMER)
defer C.SDL_Quit()
runtime.LockOSThread()
window := C.SDL_CreateWindow(C.CString("play"), 0, 0, 1680, 1050,
C.SDL_WINDOW_BORDERLESS|C.SDL_WINDOW_RESIZABLE|C.SDL_WINDOW_MAXIMIZED|C.SDL_WINDOW_OPENGL)
if window == nil {
fatalSDLError()
}
defer C.SDL_DestroyWindow(window)
C.SDL_DisableScreenSaver()
renderer := C.SDL_CreateRenderer(window, -1, C.SDL_RENDERER_ACCELERATED)
if renderer == nil {
fatalSDLError()
}
defer C.SDL_DestroyRenderer(renderer)
var width, height C.int
C.SDL_GetWindowSize(window, &width, &height)
texture := C.SDL_CreateTexture(renderer,
C.SDL_PIXELFORMAT_YV12,
C.SDL_TEXTUREACCESS_STREAMING,
width, height)
if texture == nil {
fatalSDLError()
}
defer C.SDL_DestroyTexture(texture)
// sdl ttf
if C.TTF_Init() == C.int(-1) {
log.Fatal("sdl ttf init failed")
}
defer C.TTF_Quit()
font := C.TTF_OpenFont(C.CString("/home/reus/font.ttf"), 32)
if font == nil {
fatalTTFError()
}
defer C.TTF_CloseFont(font)
// open decoder
decoder, err := NewDecoder(os.Args[1])
if err != nil {
log.Fatal(err)
}
if len(decoder.AudioStreams) == 0 || len(decoder.VideoStreams) == 0 {
log.Fatal("no video or audio")
}
defer decoder.Close()
// audio
aCodecCtx := decoder.AudioStreams[0].codec
audioStream := setupAudioOutput(int(aCodecCtx.sample_rate), int(aCodecCtx.channels), decoder)
// call closure in sdl thread
callEventCode := C.SDL_RegisterEvents(1)
callbacks := make(chan func(Env), 1024)
call := func(f func(env Env)) {
var event C.SDL_Event
var userevent C.SDL_UserEvent
userevent._type = C.SDL_USEREVENT
userevent.code = C.Sint32(callEventCode)
C.set_userevent(&event, userevent)
callbacks <- f
C.SDL_PushEvent(&event)
}
// show fps
nFrames := 0
var fpsTexture *C.SDL_Texture
var fpsColor C.SDL_Color
var fpsSrc, fpsDst C.SDL_Rect
fpsColor.r = 255
fpsColor.g = 255
fpsColor.b = 255
fpsColor.a = 0
go func() {
for _ = range time.NewTicker(time.Second * 1).C {
call(func(env Env) {
cText := C.CString(fmt.Sprintf("%d", nFrames))
sur := C.TTF_RenderUTF8_Blended(font, cText, fpsColor)
fpsSrc.w = sur.w
fpsSrc.h = sur.h
fpsDst.w = sur.w
fpsDst.h = sur.h
C.SDL_DestroyTexture(fpsTexture)
fpsTexture = C.SDL_CreateTextureFromSurface(env.renderer, sur)
C.SDL_FreeSurface(sur)
C.free(unsafe.Pointer(cText))
nFrames = 0
})
}
}()
// render
go func() {
for {
frame := <-decoder.timedFrames
nFrames++
//.........這裏部分代碼省略.........
示例5: updateRect
// Makes sure the given list of rectangles is updated on the given screen.
// If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
// screen.
// These functions should not be called while 'screen' is locked.
// extern DECLSPEC void SDLCALL SDL_UpdateRects
// (SDL_Surface *screen, int numrects, SDL_Rect *rects);
func updateRect(screen *C.SDL_Surface, x, y int32, w, h uint32) {
C.SDL_UpdateRect(screen, C.Sint32(x), C.Sint32(y), C.Uint32(w), C.Uint32(h))
}