Created
August 1, 2014 05:37
-
-
Save zecl/e1b85ff0686b08b4071d to your computer and use it in GitHub Desktop.
MonoGame(F#) でウィンドウに好きなアイコンを設定する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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