示例#1
0
文件: ui.go 项目: velour/ui
// 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
}
示例#2
0
文件: render.go 项目: emlai/go-sdl2
// Renderer (https://wiki.libsdl.org/SDL_SetRenderDrawBlendMode)
func (renderer *Renderer) SetDrawBlendMode(bm BlendMode) error {
	_ret := C.SDL_SetRenderDrawBlendMode(renderer.cptr(), bm.c())
	if _ret < 0 {
		return GetError()
	}
	return nil
}
示例#3
0
文件: render.go 项目: willemvds/sdl
func (r *Renderer) SetDrawBlendMode(mode BlendMode) error {
	if C.SDL_SetRenderDrawBlendMode(r.c, mode.c()) != 0 {
		return getError()
	}

	return nil
}
示例#4
0
文件: sdl.go 项目: gtalent/starfish
func OpenDisplay(w, h int, full bool) {
	runtime.LockOSThread()
	var i C.int = 0
	if full {
		i = 1
	}
	screen = C.openDisplay(C.int(w), C.int(h), i)
	renderer = C.SDL_CreateRenderer(screen, -1, C.SDL_RENDERER_ACCELERATED)
	C.SDL_SetRenderDrawBlendMode(renderer, C.SDL_BLENDMODE_BLEND)

	Event_DrawEvent = C.SDL_RegisterEvents(1)
	Event_MainOpEvent = C.SDL_RegisterEvents(1)
}
示例#5
0
func SetRenderDrawBlendMode(_renderer *Renderer, _mode int) {
	C.SDL_SetRenderDrawBlendMode(_renderer.Get(), C.SDL_BlendMode(_mode))
}
示例#6
0
func (r *Renderer) SetDrawBlendMode(blendmode int) bool {
	ret := C.SDL_SetRenderDrawBlendMode(r.cRenderer, C.SDL_BlendMode(blendmode))
	return int(ret) == 0
}
示例#7
0
func (renderer *Renderer) SetDrawBlendMode(blendMode uint32) int {
	_renderer := (*C.SDL_Renderer)(unsafe.Pointer(renderer))
	_blendMode := (C.SDL_BlendMode)(blendMode)
	return (int)(C.SDL_SetRenderDrawBlendMode(_renderer, _blendMode))
}
示例#8
0
func (renderer *Renderer) SetDrawBlendMode(bm BlendMode) int {
	return int(C.SDL_SetRenderDrawBlendMode(renderer.cptr(), bm.c()))
}