Exemplo n.º 1
0
func (self *TextureManager) Enable() {
	self.taskManager.Start()
	//Textur für die Lichter asynchron laden, da die Tasks bein Plugin-Enable noch nicht ausgeführt werden
	go func() {
		var err error
		self.lightsTextureNum, _, err = self.LoadTexture(self.lightsFile, true)
		if err != nil {
			logging.Errorf("could not load lights texture: %v", err)
		}
	}()
}
Exemplo n.º 2
0
//export drawCallback
func drawCallback(phase, isBefore C.int, ref unsafe.Pointer) C.int {
	defer func() {
		err := recover()
		if err != nil {
			logging.Errorf("Error during drawCallback: %v", err)
			logging.Error(string(errors.Wrap(err, 1).Stack()))
		}
	}()
	id := (*C.char)(ref)
	data, _ := callbacks[id]
	return C.int(data.callback(DrawingPhase(phase), isBefore == 1, data.ref))
}
Exemplo n.º 3
0
//export flightLoop
func flightLoop(elapsedSinceLastCall, elapsedTimeSinceLastFlightLoop C.float, counter C.int, ref unsafe.Pointer) C.float {
	defer func() {
		err := recover()
		if err != nil {
			logging.Errorf("Error during flightLoop: %v", err)
			logging.Error(errors.Wrap(err, 1).ErrorStack())
		}
	}()

	id := (*C.char)(ref)
	regData, _ := callbacks[id]
	return C.float(regData.flightLoopData.Callback(float32(elapsedSinceLastCall), float32(elapsedTimeSinceLastFlightLoop), int(counter), regData.flightLoopData.Ref))
}
Exemplo n.º 4
0
func (self *DefaultRenderer) loadAttachment(attachment *csl.CslAircraftAttachment) {
	if attachment.ObjectLoadRequested {
		//Objekt wird bereits geladen --> ignorieren
		return
	}
	attachment.ObjectLoadRequested = true
	if self.configuration.DisableObj8LightSpills || len(attachment.ReplaceTexture) > 0 {
		//es sollen die OBJ8-LightSpills ausgeblendet werden bzw. es gibt eine Austauschtextur --> Objekt ersetzen
		var err error
		attachment.ObjFile, err = self.replaceObject(attachment.ObjFile, attachment.ReplaceTexture)
		if err != nil {
			logging.Errorf("could not replace object: %v (obj file = %v)", err, attachment.ObjFile)
		}
	}
	scenery.LoadObjectAsync(attachment.ObjFile, self.objectLoaded, attachment)
}
Exemplo n.º 5
0
func (self *Plane) loadTextures() (int32, int32) {
	if self.CslAircraft.ObjInfo == nil {
		return -1, -1
	}
	//erstmal Standardtextur nehmen
	textureFile := self.CslAircraft.ObjInfo.DefaultTexture
	if !strings.HasSuffix(textureFile, ".png") {
		textureFile += ".png"
	}
	if len(self.CslAircraft.TextureFile) != 0 {
		//es gibt eine Textur aus der CSL-Definition --> diese nehmen
		textureFile = self.CslAircraft.TextureFile
	}
	textureNum, litTextureNum, err := texture.TextureManagerInstance.LoadTexture(textureFile, false)

	if err != nil {
		logging.Errorf("aircraft (icao=%v, airline=%v, livery=%v): %v", self.CslAircraft.Icao, self.CslAircraft.Airline, self.CslAircraft.Livery, err)
		return -1, -1
	}
	//normale und LIT-Textur existieren --> beide Nummern zurückgeben
	return textureNum, litTextureNum
}