Giter VIP home page Giter VIP logo

Comments (15)

totallyevil avatar totallyevil commented on May 19, 2024

Do we have a test case here that exercises this issue?

from monogame.

Nezz avatar Nezz commented on May 19, 2024

As far as I know WP7 only allows one scissor per spritebatch begin/end.

from monogame.

totallyeviljake avatar totallyeviljake commented on May 19, 2024

how about desktop XNA? I wonder what it allows....

from monogame.

Nezz avatar Nezz commented on May 19, 2024

I tested it and it works in a simple way:
You enable ScissorTest in rasterizer state.
If you use something like deferred (draw only happens once when the end is called) you can use one scissor rectangle, the one you last set before calling end.
On the other hand, if you use immediate, the textures will draw immediately, so every single draw can use a seperate scissor rectangle.

Note that using deferred has a lot better performance than immediate. For example if you draw lots of sprites from a spritesheet, XNA will draw all those textures in a single pass instead of one pass per object drawn.

from monogame.

tomspilman avatar tomspilman commented on May 19, 2024

We need to get a test case here of the code they think should work.

I suspect it is user error, but it is always possible it is something different or that has been change in our draw process.

from monogame.

totallyeviljake avatar totallyeviljake commented on May 19, 2024

Does MG support immediate mode rendering? Yeah, those Xamarin guys need to get us a test case that precipitated this bug report. ahem @CartBlanche ??

from monogame.

tomspilman avatar tomspilman commented on May 19, 2024

He means immediate vs deferred as passed into SpriteBatch.Begin(). Yes it does.

from monogame.

Nezz avatar Nezz commented on May 19, 2024

If someone takes the time to test the following code on the platforms, we will see if it works correctly:

            RasterizerState rasterizerState = new RasterizerState() { MultiSampleAntiAlias = false, ScissorTestEnable = true };
            Texture2D whitePixel = new Texture2D(GraphicsDevice, 1, 1);
            whitePixel.SetData<Color>(new Color[] { Color.White });

            Rectangle scissorRectangle = new Rectangle(0, 0, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
            Rectangle scissorRectangle2 = new Rectangle(0, 0, GraphicsDevice.PresentationParameters.BackBufferWidth / 2, GraphicsDevice.PresentationParameters.BackBufferHeight / 2);

            this.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, rasterizerState);
            this.GraphicsDevice.ScissorRectangle = scissorRectangle;
            this.SpriteBatch.Draw(whitePixel, new Rectangle(0, 0, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight), Color.White);
            this.GraphicsDevice.ScissorRectangle = scissorRectangle2;
            this.SpriteBatch.End();

If this draws to the full screen, we're good.
Change it to SpriteSortMode.Deferred. If it draws to the top left corner only, we're double good.

from monogame.

bonesoul avatar bonesoul commented on May 19, 2024

I've started testing the platforms;

XNA for reference (left immediate - right deferred)
xna

MonoGame/WP8 (left immediate - right deferred)
wp8

MonoGame/Windows-Metro (left immediate - right deferred)
metro

I'll test more platforms later.

from monogame.

Nezz avatar Nezz commented on May 19, 2024

Seems fine to me considering that WP8 is in portrait.

from monogame.

bonesoul avatar bonesoul commented on May 19, 2024

Yea for WP8, i guess I used the wrong arrow button in emulator.

from monogame.

CartBlanche avatar CartBlanche commented on May 19, 2024

Has anyone checked if this is working correctly in desktop platforms too?

from monogame.

tomspilman avatar tomspilman commented on May 19, 2024

If it works for any SharpDX platform it works for all of them most likely. So WP8, Win8, and WinDesktop should all work. @raistlinthewiz just had the orientation of the wp8 emulator wrong.

The question is if this is a bug on any of the GL platforms. If it fails on WinDesktop GL then most likely it is broken for the others as well.

from monogame.

bonesoul avatar bonesoul commented on May 19, 2024

Will also test it for WinDesktopGL.

from monogame.

tomspilman avatar tomspilman commented on May 19, 2024

This is most likely working from all our tests.

from monogame.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.