Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've been using XNA for a while to tinker with 2D game development, but I can't help but feel constrained by the content pipeline when targeting PC only. Things like no vector fonts or direct use of graphics files make it a pain while other frameworks do these things with no problem. I like XNA because it's robust and has a lot of support, but what are the specific benefits that I'd get developing exclusively for PC, if there are any at all?

share|improve this question
2  
Well content pipeline is actualy big benefit, since most of data are not in right format to put directly into your game, so you would need to write converters or exporters (which content pipeline is). And you dont need to use it. Texture2D can be loaded from stream, effect can be constructed from byte array... –  Kikaimaru Oct 12 '12 at 14:27
    
You might actually be better off switching away from XNA. Read this question and its answers. Please let me know if this fully answers your question and I'll mark it as a duplicate. –  Ricket Oct 12 '12 at 14:29
6  
Are you asking a question or complaining? XNA is a large library that does a ton of work for you. That's the benefit. –  Cypher Oct 12 '12 at 23:57
    
And the fact that you are not limited to PC , XBox or Windows Phone, Check out Monogame and run your games on Linux, iOS, MacOS, Android, WinRT and a few other systems –  TimothyP Jan 29 '13 at 13:13
add comment

1 Answer

up vote 3 down vote accepted

Everything you are complaining about has been solved by the XNA community or is actually supported by the library.

Vector Fonts thanks to the Nuclex Framework

Also loading Texture2Ds from a stream is built into the library. If you want to use premultiplied alpha (the default XNA blend mode) with stream loaded textures use the below function.

static public void PreMultiplyAlpha(this Texture2D texture) {            

    //Setup a render target to hold our final texture which will have premulitplied color values
    var result = new RenderTarget2D(texture.GraphicsDevice, texture.Width, texture.Height);

    texture.GraphicsDevice.SetRenderTarget(result);
    texture.GraphicsDevice.Clear(Color.Black);

    // Using default blending function
    // (source × Blend.SourceAlpha) + (destination × Blend.InvSourceAlpha)
    // Destination is zero so the reduces to
    // (source × Blend.SourceAlpha)
    // So this multiplies our color values by the alpha value and draws it to the RenderTarget
    var blendColor = new BlendState {
        ColorWriteChannels = ColorWriteChannels.Red | ColorWriteChannels.Green | ColorWriteChannels.Blue,
        AlphaDestinationBlend = Blend.Zero,
        ColorDestinationBlend = Blend.Zero,
        AlphaSourceBlend = Blend.SourceAlpha,
        ColorSourceBlend = Blend.SourceAlpha
    };

    var spriteBatch = new SpriteBatch(texture.GraphicsDevice);
    spriteBatch.Begin(SpriteSortMode.Immediate, blendColor);
    spriteBatch.Draw(texture, texture.Bounds, Color.White);
    spriteBatch.End();

    // Simply copy over the alpha channel
    var blendAlpha = new BlendState {
        ColorWriteChannels = ColorWriteChannels.Alpha,
        AlphaDestinationBlend = Blend.Zero,
        ColorDestinationBlend = Blend.Zero,
        AlphaSourceBlend = Blend.One,
        ColorSourceBlend = Blend.One
    };

    spriteBatch.Begin(SpriteSortMode.Immediate, blendAlpha);
    spriteBatch.Draw(texture, texture.Bounds, Color.White);
    spriteBatch.End();

    texture.GraphicsDevice.SetRenderTarget(null);

    var t = new Color[result.Width * result.Height];
    result.GetData(t);
    texture.SetData(t);
}

Are there specific benefits to using XNA for 2D development if you don't plan on releasing on xbox/windows phone?

Anyways your main question makes no sense. Why are "specific benefits" for PC developers a desired trait? The library makes 2D graphics very easy on all supported platforms. So no, there are no benefits to being a PC exclusive developer.

share|improve this answer
    
By 'specific benefits' I meant something that would make it preferable over other 2D libraries available. I admit I'm not the most knowledgeable about the subject but a lot of the features of XNA seemed aimed to me at making the code usable on Xbox and Windows Phone. If I am totally wrong then that's what I want to know. –  ssb Oct 13 '12 at 2:49
3  
This is all very subjective but personally I find the XNA library pretty intuitive. Every time I have been unable to understand something there have been plenty of people eager to help. There are also nice libraries that help with the tricky stuff persoanlly I use (Spriter, Farseer Physics, tIDE, and Krypton XNA) for the little 2D platformer I'm working on. –  ClassicThunder Oct 13 '12 at 18:02
    
Didn't realize edits bumped topics. Was replacing a link to my currently down blog with useful content. –  ClassicThunder Jul 24 '13 at 19:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.