Skip to content

Instantly share code, notes, and snippets.

@zecl
Created August 1, 2014 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zecl/e1b85ff0686b08b4071d to your computer and use it in GitHub Desktop.
Save zecl/e1b85ff0686b08b4071d to your computer and use it in GitHub Desktop.
MonoGame(F#) でウィンドウに好きなアイコンを設定する方法
namespace Sample
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
type SampleGame () as this =
inherit Game()
let gametitle, gmanager, sprite = "Sample", new GraphicsDeviceManager(this), lazy new SpriteBatch(this.GraphicsDevice)
do
gmanager.PreferredBackBufferWidth <- 800
gmanager.PreferredBackBufferHeight <- 480
override this.Initialize() =
base.Window.Title <-gametitle
base.Initialize()
override this.Draw(gameTime) =
gmanager.GraphicsDevice.Clear(Color.CornflowerBlue)
sprite.Force().Begin ()
sprite.Force().End ()
base.Draw (gameTime)
module main =
open System.Reflection
[<EntryPoint>]
let main args =
let icon = new System.Drawing.Icon(@"Icon.ico")
use game = new SampleGame()
let gameWindow = game.Window
let field = typeof<OpenTKGameWindow>.GetField("window", BindingFlags.NonPublic ||| System.Reflection.BindingFlags.Instance)
let window =
if (field <> null) then
field.GetValue(gameWindow) :?> OpenTK.GameWindow
else null
window.Icon <- icon
game.Run()
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment