Sign in to follow this  

[.net] [MDX] 2D image filters

This topic is 4212 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, it seems that MDX automatically preforms AntiAliasing on my pixel art. Is there a way to turn this off?
        /// <summary>
        /// Initializes Direct3D
        /// </summary>
        /// <returns>True if succeded</returns>
        private bool initDirect3D()
        {
            // Setup Parameters
            PresentParameters presentParams = new PresentParameters();
            presentParams.IsWindowed = true;
            presentParams.SwapEffect = SwapEffect.Discard;
            presentParams.PresentationInterval = PresentInterval.Immediate;

            try
            {
                _d3dDevice = new Device(0, DeviceType.Hardware, _window.Handle, CreateFlags.SoftwareVertexProcessing, presentParams);

            }
            catch (DirectXException)
            {
                MessageBox.Show("Error initializing Direct3D", "Renderer");
                return false;
            }
            return true;
        }
Also, is there a way to check to see if a number is even?

Share this post


Link to post
Share on other sites
You want to set the MinFilter and MagFilter members of the presentation params to "None", I think. By default MDX resamples magnified or zoomed-out textures. Unless your problem is that anti-aliasing really is on - but that is not the case by default.

Share this post


Link to post
Share on other sites
Also, I have found that setting the filters between the Sprite.Begin() and Sprite.End() calls is the only way to maintain the aliasing of my pixel art.

So, my sprite/tile rendering goes something like this:
Sprite.Begin()
Device.SamplerState[0].MinFilter = TextureFilter.None;
Device.SamplerState[0].MagFilter = TextureFilter.None;

// Draw tiles...
// Draw sprites...
// Draw anything else...

Sprite.End()

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mr_Fhqwhgads
Also, is there a way to check to see if a number is even?



int number;

//Do something to init 'number' to a non-constant value

if (number % 2 == 0)
//Number is even



That basically checks the remainder of the operation (number / 2) and if it's 0, number is obviously even.

Hope that helps.

-AJ

Share this post


Link to post
Share on other sites

This topic is 4212 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this