//this method gets called, when Reinitialize() was called in evaluate, //or a graphics device asks for its data protected override CustomDeviceData CreateDeviceData(Device device) { FLogger.Log(LogType.Message, "Creating resource..."); //create a vertex buffer with desired size //note: when using /dx9ex set Pool from .Managed to .Default var vb = new VertexBuffer(device, FSpreadCount * Marshal.SizeOf(typeof(VertexType)), Usage.WriteOnly, VertexFormat.None, Pool.Managed); //try to load the texture Texture tex; try { tex = Texture.FromFile(device, FTexFileName[0]); } catch { //set 1 pixel white texture if image load fails tex = TextureUtils.CreateColoredTexture(device, 1, 1, 0xffffffffu); } //return a new device data return(new CustomDeviceData(tex, vb)); }