Esempio n. 1
0
File: ui.go Progetto: 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
}
Esempio n. 2
0
// 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
}
Esempio n. 3
0
func (r *Renderer) SetDrawBlendMode(mode BlendMode) error {
	if C.SDL_SetRenderDrawBlendMode(r.c, mode.c()) != 0 {
		return getError()
	}

	return nil
}
Esempio n. 4
0
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)
}
Esempio n. 5
0
func SetRenderDrawBlendMode(_renderer *Renderer, _mode int) {
	C.SDL_SetRenderDrawBlendMode(_renderer.Get(), C.SDL_BlendMode(_mode))
}
Esempio n. 6
0
func (r *Renderer) SetDrawBlendMode(blendmode int) bool {
	ret := C.SDL_SetRenderDrawBlendMode(r.cRenderer, C.SDL_BlendMode(blendmode))
	return int(ret) == 0
}
Esempio n. 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))
}
Esempio n. 8
0
func (renderer *Renderer) SetDrawBlendMode(bm BlendMode) int {
	return int(C.SDL_SetRenderDrawBlendMode(renderer.cptr(), bm.c()))
}