Esempio n. 1
0
func DrawObjects(objRef ObjectRef, count int, positions []DrawInfo, lighting, earthRelative bool) {
	if len(positions) == 0 {
		C.XPLMDrawObjects(C.XPLMObjectRef(objRef), C.int(count), nil, C.int(goplane.FromBoolToInt(lighting)), C.int(goplane.FromBoolToInt(earthRelative)))
	} else {
		C.XPLMDrawObjects(C.XPLMObjectRef(objRef), C.int(count), (*C.XPLMDrawInfo_t)(unsafe.Pointer(&positions[0])), C.int(goplane.FromBoolToInt(lighting)), C.int(goplane.FromBoolToInt(earthRelative)))
	}
}
Esempio n. 2
0
func CreateWindow(left, top, right, bottom int, isVisible bool, drawCallback DrawWindow, keyCallback HandleKey, mouseClickCallback HandleMouseClick, ref interface{}) WindowID {
	regInfo := &CreateWindowData{}
	regInfo.Left = left
	regInfo.Top = top
	regInfo.Right = right
	regInfo.Bottom = bottom
	regInfo.Visible = isVisible
	regInfo.DrawWindowFunc = drawCallback
	regInfo.HandleKeyFunc = keyCallback
	regInfo.HandleMouseClickFunc = mouseClickCallback
	regInfo.Ref = ref

	id := C.CString(goplane.IdGenerator())
	windows[id] = regInfo

	return WindowID(C.XPLMCreateWindow(
		C.int(left),
		C.int(top),
		C.int(right),
		C.int(bottom),
		C.int(goplane.FromBoolToInt(isVisible)),
		C.XPLMDrawWindow_f(unsafe.Pointer(C.drawWindowCallback)),
		C.XPLMHandleKey_f(unsafe.Pointer(C.windowHandleKey)),
		C.XPLMHandleMouseClick_f(unsafe.Pointer(C.windowHandleMouseClick)),
		unsafe.Pointer(id)))
}
Esempio n. 3
0
func DrawAircraft(index int, x,y,z,pitch,roll,yaw float32, fullDraw bool,drawState  PlaneDrawState) {
	drawState.structSize=int(unsafe.Sizeof(drawState))
	C.XPLMDrawAircraft(
		C.int(index),
		C.float(x),
		C.float(y),
		C.float(z),
		C.float(pitch),
		C.float(roll),
		C.float(yaw),
		C.int(goplane.FromBoolToInt(fullDraw)),
		(*C.XPLMPlaneDrawState_t)(unsafe.Pointer(&drawState)))
}
Esempio n. 4
0
func SetGraphicsState(enableFog bool, numberTexUnits int, enableLighting, enableAlphaTesting, enableAlphaBlending, enableDepthTesting, enableDepthWriting bool) {
	C.XPLMSetGraphicsState(
		C.int(goplane.FromBoolToInt(enableFog)),
		C.int(numberTexUnits),
		C.int(goplane.FromBoolToInt(enableLighting)),
		C.int(goplane.FromBoolToInt(enableAlphaTesting)),
		C.int(goplane.FromBoolToInt(enableAlphaBlending)),
		C.int(goplane.FromBoolToInt(enableDepthTesting)),
		C.int(goplane.FromBoolToInt(enableDepthWriting)))
}
Esempio n. 5
0
func CreateWindowEx(params *CreateWindowData) WindowID {
	id := C.CString(goplane.IdGenerator())
	windows[id] = params
	cCreateWindowData := C.XPLMCreateWindow_t{}
	cCreateWindowData.structSize = C.int(unsafe.Sizeof(cCreateWindowData))
	cCreateWindowData.left = C.int(params.Left)
	cCreateWindowData.top = C.int(params.Top)
	cCreateWindowData.right = C.int(params.Right)
	cCreateWindowData.bottom = C.int(params.Bottom)
	cCreateWindowData.visible = C.int(goplane.FromBoolToInt(params.Visible))
	cCreateWindowData.drawWindowFunc = C.XPLMDrawWindow_f(unsafe.Pointer(C.drawWindowCallback))
	cCreateWindowData.handleMouseClickFunc = C.XPLMHandleMouseClick_f(unsafe.Pointer(C.windowHandleMouseClick))
	cCreateWindowData.handleKeyFunc = C.XPLMHandleKey_f(unsafe.Pointer(C.windowHandleKey))
	cCreateWindowData.handleCursorFunc = C.XPLMHandleCursor_f(unsafe.Pointer(C.windowHandleCursorStatus))
	cCreateWindowData.handleMouseWheelFunc = C.XPLMHandleMouseWheel_f(unsafe.Pointer(C.windowHandleMouseWheel))
	cCreateWindowData.refcon = unsafe.Pointer(id)
	return WindowID(C.XPLMCreateWindowEx((*C.XPLMCreateWindow_t)(unsafe.Pointer(&cCreateWindowData))))
}
Esempio n. 6
0
func UnregisterCommandHandler(command CommandRef, callback CommandCallback, before bool, ref interface{}) {
	callbackAsString := fmt.Sprint(callback)
	for cId, regInfo := range callbacks {
		if regInfo.command == command && regInfo.callbackAsString == callbackAsString && regInfo.ref == ref {
			C.XPLMUnregisterCommandHandler(C.XPLMCommandRef(command), C.XPLMCommandCallback_f(unsafe.Pointer(C.commandCallback)), C.int(goplane.FromBoolToInt(before)), unsafe.Pointer(cId))
			defer C.free(unsafe.Pointer(cId))
		}
	}
}
Esempio n. 7
0
func RegisterCommandHandler(command CommandRef, callback CommandCallback, before bool, ref interface{}) {
	cId := C.CString(goplane.IdGenerator())
	callbacks[cId] = &regInfo{fmt.Sprint(callback), command, callback, ref}
	C.XPLMRegisterCommandHandler(C.XPLMCommandRef(command), C.XPLMCommandCallback_f(unsafe.Pointer(C.commandCallback)), C.int(goplane.FromBoolToInt(before)), unsafe.Pointer(cId))
}
Esempio n. 8
0
func UnregisterDrawCallback(callback DrawCallback, phase DrawingPhase, wantsBefore bool, ref interface{}) bool {
	var id *C.char
	for key, info := range callbacks {
		if info.funcPointerAsString == fmt.Sprint(callback) && info.ref == ref {
			id = key
			defer C.free(unsafe.Pointer(id))
		}
	}
	return C.XPLMUnregisterDrawCallback(C.XPLMDrawCallback_f(unsafe.Pointer(C.drawCallback)), C.XPLMDrawingPhase(phase), C.int(goplane.FromBoolToInt(wantsBefore)), unsafe.Pointer(id)) == 1
}
Esempio n. 9
0
func RegisterDrawCallback(callback DrawCallback, phase DrawingPhase, wantsBefore bool, ref interface{}) bool {
	id := C.CString(goplane.IdGenerator())
	callbacks[id] = regData{fmt.Sprint(callback), callback, ref}
	return C.XPLMRegisterDrawCallback(C.XPLMDrawCallback_f(unsafe.Pointer(C.drawCallback)), C.XPLMDrawingPhase(phase), C.int(goplane.FromBoolToInt(wantsBefore)), unsafe.Pointer(id)) == 1
}
Esempio n. 10
0
func UnregisterKeySniffer(callback KeySnifferCallback, beforeWindows bool, ref interface{}) bool {
	var id *C.char
	for key, info := range keySnifferCallbacks {
		if info.funcPointerAsString == fmt.Sprint(callback) && info.ref == ref {
			id = key
			defer C.free(unsafe.Pointer(id))
		}
	}
	return C.XPLMUnregisterKeySniffer(C.XPLMKeySniffer_f(unsafe.Pointer(C.keySnifferCallback)), C.int(goplane.FromBoolToInt(beforeWindows)), unsafe.Pointer(id)) == 1
}
Esempio n. 11
0
func RegisterKeySniffer(callback KeySnifferCallback, beforeWindows bool, ref interface{}) bool {
	id := C.CString(goplane.IdGenerator())
	keySnifferCallbacks[id] = regSnifferData{fmt.Sprint(callback), callback, ref}
	return C.XPLMRegisterKeySniffer(C.XPLMKeySniffer_f(unsafe.Pointer(C.keySnifferCallback)), C.int(goplane.FromBoolToInt(beforeWindows)), unsafe.Pointer(id)) == 1
}
Esempio n. 12
0
func DrawNumber(color color.Color, xOffset, yOffset int, value float64, digits, decimal int, showSign bool, fontId FontID) {
	r, g, b, _ := color.RGBA()
	cColor := [3]float32{float32(r>>8) / 255.0, float32(g>>8) / 255.0, float32(b>>8) / 255.0}
	C.XPLMDrawNumber((*C.float)(unsafe.Pointer(&cColor[0])), C.int(xOffset), C.int(yOffset), C.double(value), C.int(digits), C.int(decimal), C.int(goplane.FromBoolToInt(showSign)), C.XPLMFontID(fontId))
}
Esempio n. 13
0
func SetWindowIsVisible(windowId WindowID, isVisible bool) {
	C.XPLMSetWindowIsVisible(C.XPLMWindowID(windowId), C.int(goplane.FromBoolToInt(isVisible)))
}