当前位置: 首页>>代码示例>>Golang>>正文


Golang C.SDL_CreateRGBSurface函数代码示例

本文整理汇总了Golang中C.SDL_CreateRGBSurface函数的典型用法代码示例。如果您正苦于以下问题:Golang SDL_CreateRGBSurface函数的具体用法?Golang SDL_CreateRGBSurface怎么用?Golang SDL_CreateRGBSurface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_CreateRGBSurface函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewPaletteSurface

func NewPaletteSurface(w, h int) (s *Surface) {
	mutex.Lock()
	defer mutex.Unlock()

	ptr := C.SDL_CreateRGBSurface(0, C.int(w), C.int(h), 8, 0, 0, 0, 0)
	s = &Surface{ptr}
	runtime.SetFinalizer(s, func(s *Surface) { C.SDL_FreeSurface(s.ptr) })
	return
}
开发者ID:rsaarelm,项目名称:teratogen,代码行数:9,代码来源:video.go

示例2: CreateRGBSurface

// 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)
}
开发者ID:kearsley,项目名称:Go-SDL,代码行数:11,代码来源:sdl.go

示例3: CreateRGBSurface

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))))
}
开发者ID:JalfResi,项目名称:go-sdl2,代码行数:10,代码来源:surface.go

示例4: CreateRGBSurface

func CreateRGBSurface(flags uint32, width, height, depth int32,
	Rmask, Gmask, Bmask, Amask uint32) *Surface {
	_flags := (C.Uint32)(flags)
	_width := (C.int)(width)
	_height := (C.int)(height)
	_depth := (C.int)(depth)
	_Rmask := (C.Uint32)(Rmask)
	_Gmask := (C.Uint32)(Gmask)
	_Bmask := (C.Uint32)(Bmask)
	_Amask := (C.Uint32)(Amask)
	return (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurface(_flags, _width, _height,
		_depth, _Rmask, _Gmask, _Bmask, _Amask)))
}
开发者ID:kyleconroy,项目名称:golds,代码行数:13,代码来源:sdl_surface.go

示例5: NewSurface

func NewSurface(w, h int) (s *Surface) {
	mutex.Lock()
	defer mutex.Unlock()

	video := C.SDL_GetVideoSurface()
	ptr := C.SDL_CreateRGBSurface(
		0, C.int(w), C.int(h), C.int(video.format.BitsPerPixel),
		video.format.Rmask,
		video.format.Gmask,
		video.format.Bmask,
		video.format.Amask)
	s = &Surface{ptr}
	runtime.SetFinalizer(s, func(s *Surface) { C.SDL_FreeSurface(s.ptr) })
	return
}
开发者ID:rsaarelm,项目名称:teratogen,代码行数:15,代码来源:video.go

示例6: CreateRGBSurface

// 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
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:16,代码来源:surface.go

示例7: CreateRGBSurface

func CreateRGBSurface(w, h, d int, rm, gm, bm, am uint32) (*Surface, error) {
	s := C.SDL_CreateRGBSurface(0,
		C.int(w),
		C.int(h),
		C.int(d),
		C.Uint32(rm),
		C.Uint32(gm),
		C.Uint32(bm),
		C.Uint32(am),
	)
	if s == nil {
		return nil, getError()
	}

	return (*Surface)(unsafe.Pointer(s)), nil
}
开发者ID:willemvds,项目名称:sdl,代码行数:16,代码来源:surface.go

示例8: NewSurface

func NewSurface(w, h int) (*Surface, error) {
	var curr C.SDL_DisplayMode
	if C.SDL_GetCurrentDisplayMode(0, &curr) != 0 {
		return nil, sdlerr()
	}
	pixfmt := C.SDL_AllocFormat(curr.format)

	s := C.SDL_CreateRGBSurface(0, C.int(w), C.int(h),
		C.int(pixfmt.BitsPerPixel),
		pixfmt.Rmask, pixfmt.Gmask,
		pixfmt.Bmask, pixfmt.Amask)
	if s == nil {
		return nil, sdlerr()
	}

	surf := &Surface{s, pixfmt}
	runtime.SetFinalizer(surf, freesurf)
	return surf, nil
}
开发者ID:rwcarlsen,项目名称:sdl,代码行数:19,代码来源:sdl.go

示例9: CreateSurface

// CreateSurface returns a newly allocated surface.
//
// Note: Free must be called when finished using the surface.
func CreateSurface(w, h int) (surface *Surface, err error) {
	surface = new(Surface)
	// SDL_PIXELFORMAT_RGBA8888
	rMask := C.Uint32(0xFF000000)
	gMask := C.Uint32(0x00FF0000)
	bMask := C.Uint32(0x0000FF00)
	aMask := C.Uint32(0x000000FF)
	if nativeEndian == binary.BigEndian {
		// SDL_PIXELFORMAT_ABGR8888
		rMask = 0x000000FF
		gMask = 0x0000FF00
		bMask = 0x00FF0000
		aMask = 0xFF000000
	}
	surface.cSurface = C.SDL_CreateRGBSurface(0, C.int(w), C.int(h), 32, rMask, gMask, bMask, aMask)
	if surface.cSurface == nil {
		return nil, getError()
	}
	return surface, nil
}
开发者ID:salihdb,项目名称:sdl,代码行数:23,代码来源:surface.go

示例10: CreateRGBSurface

// Creates an empty Surface.
func CreateRGBSurface(flags uint32, width int, height int, bpp int, Rmask uint32, Gmask uint32, Bmask uint32, Amask uint32) *Surface {
	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))
	return (*Surface)(cast(p))
}
开发者ID:gnanderson,项目名称:Go-SDL,代码行数:6,代码来源:sdl.go

示例11: createRGBSurface

// Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
// If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
// If the depth is greater than 8 bits, the pixel format is set using the
// flags '[RGB]mask'.
// If the function runs out of memory, it will return NULL.
//
// The 'flags' tell what kind of surface to create.
// SDL_SWSURFACE means that the surface should be created in system memory.
// SDL_HWSURFACE means that the surface should be created in video memory,
// with the same format as the display surface.  This is useful for surfaces
// that will not change much, to take advantage of hardware acceleration
// when being blitted to the display surface.
// SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
// this surface, but you must always lock it before accessing the pixels.
// SDL will wait for current blits to finish before returning from the lock.
// SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
// If the hardware supports acceleration of colorkey blits between
// two surfaces in video memory, SDL will try to place the surface in
// video memory. If this isn't possible or if there is no hardware
// acceleration available, the surface will be placed in system memory.
// SDL_SRCALPHA means that the surface will be used for alpha blits and
// if the hardware supports hardware acceleration of alpha blits between
// two surfaces in video memory, to place the surface in video memory
// if possible, otherwise it will be placed in system memory.
// If the surface is created in video memory, blits will be _much_ faster,
// but the surface format must be identical to the video surface format,
// and the only way to access the pixels member of the surface is to use
// the SDL_LockSurface() and SDL_UnlockSurface() calls.
// If the requested surface actually resides in video memory, SDL_HWSURFACE
// will be set in the flags member of the returned surface.  If for some
// reason the surface could not be placed in video memory, it will not have
// the SDL_HWSURFACE flag set, and will be created in system memory instead.
func createRGBSurface(flags uint32, width, height, depth int,
	rmask, gmask, bmask, amask uint32) *C.SDL_Surface {
	return 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))
}
开发者ID:beoran,项目名称:fungo,代码行数:38,代码来源:video.go


注:本文中的C.SDL_CreateRGBSurface函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。