Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8392325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:29:21+00:00 2026-06-09T19:29:21+00:00

I’ve been working on a cross-platform framework/abstraction-layer for a number of months now, based

  • 0

I’ve been working on a cross-platform framework/abstraction-layer for a number of months now, based on the XNA framework for WP7 and Mono for Android and iOS. Having got the majority of functionality working for Android, I have recently returned to WP7 in order to get a simple game working on both platforms.

The trouble is, I’ve encountered a very strange graphical error. The error does not occur in a Windows-based XNA game, and only occurs on WP7 when the orientation is Landscape (either by default or specified). The glitch appears on the emulator, but not the physical device. For testing purposes, I am displaying a single image on a red background.

Windows XNA

Windows http://www.genius-i.com/images/Windows.png

Windows Phone 7 (Portrait)

Portait http://www.genius-i.com/images/Portrait.png

Windows Phone 7 (Landscape)

Landscape http://www.genius-i.com/images/Landscape.png

Obviously the landscape image is not coming out as expected. While it’s all handled through an abstraction layer, the XNA platform files are identical, the only difference between the Windows and WP7 versions being the target platform/framework.

Similarly, the calls to the graphics device and renderer are identical.

During Construction ( Extracted from various classes and functions )

device = new Microsoft.Xna.Framework.GraphicsDeviceManager(game);
device.PreferredBackBufferHeight = 480;
device.PreferredBackBufferWidth = 800;
Backend.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
// Whether or not I set the orientation, the glitchoccurs.

During Initialisation ( Extracted from various classes and functions )

renderer = new SpriteBatch(device.GraphicsDevice);

During Drawing

device.Clear(Color.Red);
renderer.Begin();
renderer.Draw(ZNGTexture, new Rectangle(10, 400, 145, 66), null, Color.White, 0f, Vector.Zero, SpriteEffects.none, 0f);
renderer.End()

Does anyone have any insight into what might cause a graphical glitch such as the one I’ve described?

Thanks for any help you might offer, and sorry to intrude with a second question over the course of a few days.

Full Code

To help in identifying the issue, I’m presenting a good deal of the actual code. I originally excluded it because it’s a bit long, and the classes are simple wrappers for most of XNA’s functionality.

Game Class

public class Game : Microsoft.Xna.Framework.Game, IGame
{
    #region Data: Fields

    private GraphicsBackendXNA graphics;
    private Renderer2DXNA renderer;
    ContentLoaderXNA content;

    #endregion

    #region Data: Properties

    public GraphicsBackend Backend { get { return graphics; } }
    public Renderer2D Renderer { get { return renderer; } }
    public ContentLoader Loader { get { return content; } }

    #endregion

    #region Methods: Construction

    public Game()
    {
        graphics = new GraphicsBackendXNA(this);
        content = new ContentLoaderXNA(this.Services, "Content");
        FinaliseConstruction();
    }

    protected virtual void FinaliseConstruction() { }

    #endregion

    #region Methods: Initialisation

    protected override void Initialize()
    {
        Core.Console.Initialise(); // Initialised once for error logging.
        base.Initialize();
        renderer = new RendererXNA(graphics);
        Core.Console.Initialise(renderer); // Initialised a second time for graphics services.

        Transform.ScreenSize = new Vector2(Backend.ScreenWidth, Backend.ScreenHeight);

        Core.Audio.MediaPlayer.Initialise(new Audio.MediaHandler());
        Core.Audio.SoundEffect.Initialise(Audio.SoundEffectXNA.SetVolume);

        Core.Input.Input.Set(new KeyboardReaderXNA(), new MouseReaderXNA(), new GamePadReaderXNA(), new Input.Touch.TouchPanelXNA(), new GamePadOutputXNA());
        Core.Input.InputManager.Initialise();
    }

    #endregion

    #region Methods: Loading and Unloading Content

    protected override void UnloadContent()
    {
        content.Unload();
        base.UnloadContent();
    }

    #endregion

    #region Methods: Drawing

    protected override void EndDraw()
    {
        Camera2D.AllOff();
        base.EndDraw();
    }

    #endregion

Graphics Backend Class

The graphics backend (XNA) class is a simple wrapper class. It extends the GraphicsBackend class, which is abstract and contains no functionality.

public class GraphicsBackendXNA : GraphicsBackend
{
    #region Data: Fields

    private Microsoft.Xna.Framework.GraphicsDeviceManager device;

    #endregion

    #region Data: Properties

    public override Display Display { get { return device.GraphicsDevice.PresentationParameters.ToHeron(); } }
    public override Core.Graphics.Viewport Viewport { get { return device.GraphicsDevice.Viewport.ToHeron(); } }

    public override int ScreenWidth { get { return device.PreferredBackBufferWidth; } set { device.PreferredBackBufferWidth = value; } }
    public override int ScreenHeight { get { return device.PreferredBackBufferHeight; } set { device.PreferredBackBufferHeight = value; } }

    public override bool IsFullScreen { get { return device.IsFullScreen; } set { device.IsFullScreen = value; } }
    public override Core.DisplayOrientation SupportedOrientations
    {
        get { return ((Core.DisplayOrientation)((int)device.SupportedOrientations); }
        set { device.SupportedOrientations = (Microsoft.Xna.Framework.DisplayOrientation)((int)value); }
    }

    #endregion

    #region Methods: Construction

    public GraphicsBackendXNA(Microsoft.Xna.Framework.Game game)
    {
        device = new Microsoft.Xna.Framework.GraphicsDeviceManager(game);
    }

    #endregion

    #region Methods: Settings

    public override void ApplyChanges()
    {
        device.ApplyChanges();
    }

    #endregion

    #region Methods: Rendering

    public override void Clear(Colour colour)
    {
        device.GraphicsDevice.Clear(new Microsoft.Xna.Framework.Color(colour.R, colour.G, colour.B, colour.A));
    }

    #endregion

    #region Methods: Renderer

    public override Renderer2D CreateRenderer() { return new Renderer2DXNA(this); }

    #endregion

Renderer 2D XNA Class

The Renderer 2D XNA class is another simple wrapper. It inherits from the Renderer2D base class, which implements a great number of abstract methods for drawing content. it has some very basic functionality which I will details first, but I won’t bother including all the blank methods.

public class Renderer2D : IDisposable
{
    private GraphicsBackend backend;
    private Matrix currentMatrix;

    public virtual GraphicsBackend Backend { get { return backend; } protected set { backend = value; } }
    public Matrix CurrentMatrix { get { return currentMatrix; } set { currentMatrix = value; } }

    public Renderer2D(GraphicsBackend backend) { this.backend = backend; CurrentMatrix = Matrix.Identity; }
}

public class Renderer2DXNA : Renderer2D
{
    #region Static: 1 Pixel Texture

    private static Texture2D filler;
    private static bool Initialised { get { return filler != null; } }

    public static void Initialise(GraphicsBackendXNA backend)
    {
        filler = CreateFiller(backend)
    }

    private static Texture2D CreateFiller(GraphicsBackendXNA backend)
    {
        Texture2D rt = new Texture2D(backend.Device.GraphicsDevice, 1, 1);
        rt.SetData<Microsoft.Xna.Framework.Color>(new Microsoft.Xna.Framework.Color[] { Microsoft.Xna.Framework.Color.White });
        return rt;
    }

    #endregion

    #region Data: Fields

    private SpriteBatch renderer;

    #endregion

    #region Methods: Construction

    public Renderer2DXNA(GraphicsBackendXNA backend) : base(backend)
    {
        if (!Initialised)
            Initialise(backend);

        renderer = new SpriteBatch(backend.Device.GraphicsDevice);
    }

    #endregion

    #region Methods: Begin and End

    public override void Begin(Core.Graphics.SpriteSortMode sortMode, BlendMode blendMode, Core.Matrix transformMatrix)
    {
        renderer.Begin(); // Obviously not fully implemented, but simple for now.
    }

    public override void End() { renderer.End(); }

    #endregion

    #region Methods: Draw Image

    public override void Draw(Image Image, Core.Rectangle Boundary, Core.Rectangle? Source, Colour DrawColour, float RotationRadians, Core.Vector2 Origin, Core.SpriteEffects Effects, float Layer)
    {
        if (!(Image is ImageXNA))
            return;

        ImageXNA realImage = Image as ImageXNA;
        Microsoft.Xna.Framework.Rectangle finalSource = 
            Source.HasValue ? Source.Value.ToXNARectangle()
            : new Microsoft.Xna.Framework.Rectangle(0, 0, realImage.Width, realImage.Height);

        renderer.Draw(
            realImage.Texture,
            Boundary.ToXNARectangle(),
            finalSource,
            new Microsoft.Xna.Framework.Color(DrawColour.R, DrawColour.G, DrawColour.B, DrawColour.A),
            RotationRadians,
            Origin.ToXNAVector2(),
            (SpriteEffects)((int)Effects),
            Layer);
    }         

    #endregion

}
// I'll leave off string and shape drawing, considering they're not being used here.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:29:23+00:00Added an answer on June 9, 2026 at 7:29 pm

    adding device.IsFullScreen = true; in the constructor fixed similar problem for me. I would see the pattern of diagonal lines whenever I tried to draw anything.

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
    
            graphics.PreferredBackBufferWidth = 480;
            graphics.PreferredBackBufferHeight = 800;
            graphics.IsFullScreen = true;
    
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);
    
            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);
        }
    

    Here’s how my glitch looked like

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.