Example #1
0
func Create(windowInstance unsafe.Pointer) (obj DirectInput, err error) {
	DirectInput8Create, err := syscall.GetProcAddress(dll, "DirectInput8Create")
	if err != nil {
		return DirectInput{}, err
	}
	err = toError(C.create(
		unsafe.Pointer(DirectInput8Create),
		C.HINSTANCE(windowInstance),
		&obj.handle,
	))
	return
}
Example #2
0
// #include "helper_windows.h"
//
// extern LRESULT CALLBACK (*pGlobalOnEvent)(HWND handle, UINT message, WPARAM wParam, LPARAM lParam);
import "C"
import (
	"fmt"
	"image"
	"unsafe"
)

var className, classNameLength = utf16Convert("go-glml/window.Window")
var windowClass = C.WNDCLASSW{
	lpfnWndProc:   C.pGlobalOnEvent,
	style:         C.CS_OWNDC | C.CS_HREDRAW | C.CS_VREDRAW,
	hInstance:     C.HINSTANCE(C.GetModuleHandle(nil)),
	lpszClassName: className,
}

func init() {
	C.RegisterClassW(&windowClass)
}

type WindowHandle struct {
	Handle C.HWND
}

func (wh WindowHandle) IsValid() bool {
	return wh.Handle != nil
}