Golang C.Uint32类(方法)实例源码

下面列出了Golang C.Uint32 类(方法)源码代码实例,从而了解它的用法。

作者:rsaarel    项目:teratoge   
func mainLoop(width, height int) {
	// SDL window must be created in the same thread where the events are
	// polled. Hence this stuff must be in a separate goroutine along with the
	// event loop.

	initFlags := int64(C.SDL_INIT_VIDEO) | int64(C.SDL_INIT_AUDIO)
	screenFlags := 0

	if C.SDL_Init(C.Uint32(initFlags)) == C.int(-1) {
		panic(getError())
	}

	screen := C.SDL_SetVideoMode(
		C.int(width), C.int(height), 32, C.Uint32(screenFlags))
	if screen == nil {
		panic(getError())
	}
	C.SDL_EnableUNICODE(1)
	C.SDL_EnableKeyRepeat(C.SDL_DEFAULT_REPEAT_DELAY, C.SDL_DEFAULT_REPEAT_INTERVAL)

	initAudio()

	// Synchronize with Run function.
	coord <- true

	eventLoop()
	C.SDL_Quit()

	// Synchronize with Stop function.
	coord <- true
	runLevel = off
}

作者:DeedleFak    项目:sd   
func MasksToPixelFormatEnum(bpp int, rm, gm, bm, am uint32) (uint32, error) {
	f := C.SDL_MasksToPixelFormatEnum(C.int(bpp), C.Uint32(rm), C.Uint32(gm), C.Uint32(bm), C.Uint32(am))
	if f == PIXELFORMAT_UNKNOWN {
		return 0, getError()
	}

	return uint32(f), nil
}

作者:willemvd    项目:sd   
func (s *Surface) ConvertFormat(pf uint32, flags uint32) (*Surface, error) {
	cs := C.SDL_ConvertSurfaceFormat(s.c(), C.Uint32(pf), C.Uint32(flags))
	if cs == nil {
		return nil, getError()
	}

	return (*Surface)(unsafe.Pointer(cs)), nil
}

作者:badgerodo    项目:g   
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)
}

作者:kearsle    项目:Go-SD   
// 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()
}

作者:kearsle    项目:Go-SD   
// Creates an empty Surface.
func CreateRGBSurface(flags uint32, width int, height int, bpp int, Rmask uint32, Gmask uint32, Bmask uint32, Amask uint32) *Surface {
	GlobalMutex.Lock()

	p := C.SDL_CreateRGBSurface(C.Uint32(flags), C.int(width), C.int(height), C.int(bpp),
		C.Uint32(Rmask), C.Uint32(Gmask), C.Uint32(Bmask), C.Uint32(Amask))

	GlobalMutex.Unlock()

	return wrap(p)
}

作者:JalfRes    项目:go-sdl   
func CreateRGBSurface(flags uint32, width, height, depth int32, Rmask, Gmask, Bmask, Amask uint32) *Surface {
	return (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurface(C.Uint32(flags),
		C.int(width),
		C.int(height),
		C.int(depth),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
}

作者:JalfRes    项目:go-sdl   
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) *Surface {
	return (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(pixels,
		C.int(width),
		C.int(height),
		C.int(depth),
		C.int(pitch),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
}

作者:jbondeso    项目:Go-SDL   
// Initializes SDL.
func Init(flags uint32) int {
	status := int(C.SDL_Init(C.Uint32(flags)))
	if (status != 0) && (runtime.GOOS == "darwin") && (flags&INIT_VIDEO != 0) {
		if os.Getenv("SDL_VIDEODRIVER") == "" {
			os.Setenv("SDL_VIDEODRIVER", "x11")
			status = int(C.SDL_Init(C.Uint32(flags)))
			if status != 0 {
				os.Setenv("SDL_VIDEODRIVER", "")
			}
		}
	}
	return status
}

作者:emla    项目:go-sdl   
// CreateRGBSurface (https://wiki.libsdl.org/SDL_CreateRGBSurface)
func CreateRGBSurface(flags uint32, width, height, depth int32, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
	surface := (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurface(
		C.Uint32(flags),
		C.int(width),
		C.int(height),
		C.int(depth),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
	if surface == nil {
		return nil, GetError()
	}
	return surface, nil
}

作者:extram    项目:Go-SD   
// Initializes subsystems.
func InitSubSystem(flags uint32) int {
	GlobalMutex.Lock()
	status := int(C.SDL_InitSubSystem(C.Uint32(flags)))
	if (status != 0) && (runtime.GOOS == "darwin") && (flags&INIT_VIDEO != 0) {
		if os.Getenv("SDL_VIDEODRIVER") == "" {
			os.Setenv("SDL_VIDEODRIVER", "x11")
			status = int(C.SDL_InitSubSystem(C.Uint32(flags)))
			if status != 0 {
				os.Setenv("SDL_VIDEODRIVER", "")
			}
		}
	}
	GlobalMutex.Unlock()
	return status
}

作者:veandc    项目:go-sdl   
func FilledCircleColor(renderer *sdl.Renderer, x, y, rad int, color sdl.Color) bool {
	_x := C.Sint16(x)
	_y := C.Sint16(y)
	_rad := C.Sint16(rad)
	_color := C.Uint32(gfxColor(color))
	return C.filledCircleColor(renderer, _x, _y, _rad, _color) == 0
}

作者:emla    项目:go-sdl   
// AllocFormat creates a PixelFormat structure from a uint.
// AllocFormat (https://wiki.libsdl.org/SDL_AllocFormat)
func AllocFormat(format uint) (*PixelFormat, error) {
	r := (*PixelFormat)(unsafe.Pointer(C.SDL_AllocFormat(C.Uint32(format))))
	if r == nil {
		return nil, GetError()
	}
	return r, nil
}

作者:veandc    项目:go-sdl   
func StringColor(renderer *sdl.Renderer, x, y int, s string, color sdl.Color) bool {
	_x := C.Sint16(x)
	_y := C.Sint16(y)
	_s := C.CString(s)
	_color := C.Uint32(gfxColor(color))
	return C.stringColor(renderer, _x, _y, _s, _color) == 0
}

作者:veandc    项目:go-sdl   
func HlineColor(renderer *sdl.Renderer, x1, x2, y int, color sdl.Color) bool {
	_x1 := C.Sint16(x1)
	_x2 := C.Sint16(x2)
	_y := C.Sint16(y)
	_color := C.Uint32(gfxColor(color))
	return C.hlineColor(renderer, _x1, _x2, _y, _color) == 0
}

作者:willemvd    项目:sd   
func InitSubSystem(flags uint32) error {
	if C.SDL_InitSubSystem(C.Uint32(flags)) != 0 {
		return getError()
	}

	return nil
}

作者:velou    项目:u   
// NewWindow returns a new window.
func NewWindow(title string, w, h int) *Window {
	win := &Window{
		events: make(chan interface{}, eventChanSize),
		imgs:   make(map[string]texture),
	}
	do(func() {
		ctitle := C.CString(title)
		defer C.free(unsafe.Pointer(ctitle))
		x, y := C.SDL_WINDOWPOS_UNDEFINED, C.SDL_WINDOWPOS_UNDEFINED
		flags := C.SDL_WINDOW_SHOWN | C.SDL_WINDOW_OPENGL

		win.win = C.SDL_CreateWindow(ctitle, C.int(x), C.int(y), C.int(w), C.int(h), C.Uint32(flags))
		if win.win == nil {
			panic(sdlError())
		}

		win.rend = C.SDL_CreateRenderer(win.win, 0, C.SDL_RENDERER_ACCELERATED)
		if win.rend == nil {
			panic(sdlError())
		}
		if C.SDL_SetRenderDrawBlendMode(win.rend, C.SDL_BLENDMODE_BLEND) < 0 {
			panic(sdlError())
		}

		win.id = windowID(C.SDL_GetWindowID(win.win))
		windows[win.id] = win
	})
	return win
}

作者:tanem    项目:amor   
// CreateSemaphore (https://wiki.libsdl.org/SDL_CreateSemaphore)
func CreateSemaphore(initialValue uint32) (*Sem, error) {
	sem := C.SDL_CreateSemaphore(C.Uint32(initialValue))
	if sem == nil {
		return nil, GetError()
	}
	return (*Sem)(unsafe.Pointer(sem)), nil
}

作者:kearsle    项目:Go-SD   
// Sets up a video mode with the specified width, height, bits-per-pixel and
// returns a corresponding surface.  You don't need to call the Free method
// of the returned surface, as it will be done automatically by sdl.Quit.
func SetVideoMode(w int, h int, bpp int, flags uint32) *Surface {
	GlobalMutex.Lock()
	var screen = C.SDL_SetVideoMode(C.int(w), C.int(h), C.int(bpp), C.Uint32(flags))
	currentVideoSurface = wrap(screen)
	GlobalMutex.Unlock()
	return currentVideoSurface
}

作者:emla    项目:go-sdl   
// CreateRenderer (https://wiki.libsdl.org/SDL_CreateRenderer)
func CreateRenderer(window *Window, index int, flags uint32) (*Renderer, error) {
	_renderer := C.SDL_CreateRenderer(window.cptr(), C.int(index), C.Uint32(flags))
	if _renderer == nil {
		return nil, GetError()
	}
	return (*Renderer)(unsafe.Pointer(_renderer)), nil
}


问题


面经


文章

微信
公众号

扫码关注公众号