Example #1
0
File: ui.go Project: 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
}
Example #2
0
func (window *Window) GetID() uint32 {
	_window := (*C.SDL_Window)(unsafe.Pointer(window))
	return (uint32)(C.SDL_GetWindowID(_window))
}
Example #3
0
func (win *Window) GetID() uint32 {
	return uint32(C.SDL_GetWindowID(win.c))
}
Example #4
0
// Window (https://wiki.libsdl.org/SDL_GetWindowID)
func (window *Window) GetID() uint32 {
	return (uint32)(C.SDL_GetWindowID(window.cptr()))
}