Blurry textures after resize on certain computer? - c#

So here's the thing. I made a game in 192x108. Yes, that small. I also made it borderless windowed, and it also resizes and stretches itself to it fits the main screen.
HERE'S THE PROBLEM:
When I start the game on my home PC, it stretches out to 1920x1080 with nearest neighbor and it's not blurry at all, just a pixely beauty. BUT when I start the game on my school PC, it stretches out to 1366x768 and becomes BICUBIC? I even added PointClamp to the spriteBatch.Begin(...SamplerState.PointClamp), but there was NO difference.
So how come it's different depending on the PC I use?

Looks like you can do this for every frame outside of the sprite batch:
GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
https://gamedev.stackexchange.com/questions/6820/how-do-i-disable-texture-filtering-for-sprite-scaling-in-xna-4-0
However, I'm wondering if it isn't the sprites that are being scaled, but the device after the sprites are rendered. Hard to tell without more information. Make sure your DisplayMode, ClientBounds, ViewPort, and BackBuffer are all the same width and height as well.
http://msdn.microsoft.com/en-us/library/bb203889(v=xnagamestudio.31).aspx

Related

Problem with Fullscreen Resolution in Mono Game

a couple days ago I started game developing in MonoGame with Visual Studio 2017 and porting my code which i wrote in WinForms to MonoGame. Now I have a problem with the fullscreen mode. I searched the internet and the only thing I found out is that it depends on the resolution the monitor has.
In the default window mode of the application the screen looks like follows:
Now when I switch to fullscreen mode - this happens:
Now my problems are:
One can not see it on the picture because I used the print button and pasted in to paint but the image is largely strechted.
The right part of the screen is cut off
the sprites are moved to the top.
I'm using
graphics.ToggleFullScreen();
Is there a way to keep the original status like it is in window mode? Maybe to put flexible bars for a 4:3 mode and keep the sprite positions? My positions are fixed. So use something like
spriteBatch.Draw(Params.CUR_SPRITE_P1, new Rectangle(Convert.ToInt32(POSITION_P1.X), Convert.ToInt32(POSITION_P1.Y), 750, 476), Color.White); for the player position and the screen (to implement scrolling).
Or maybe adjust everything in full screen mode bu keep the positions of the sprites on different screen resolutions...
Thank you a lot!
Ok after searching and searching I finally found an answer:
var scaleX = (float)ActualWidth / VirtualWidth;
var scaleY = (float)ActualHeight / VirtualHeight;
var matrix = Matrix.CreateScale(scaleX, scaleY, 1.0f);
spriteBatch.Begin(transformMatrix: matrix);
This has to be put in the Draw()-Method.
My virtual screensize was 800x480. I tested it with my Monitor size 1920x1080 and this did the job.

Why my Canvas is not on same positions as on my device?

I hope I am not too boring because again I have one dumb question.
I have made my game near till end but now I have one big problem. My images , text etc in my Canvas panel are not display correctly on all devices.
I made the game and it looks perfect on unity. Then I build the same game to my Galaxy S8 Device and i realized that some images are out of the screen in other words I can not see some images in corners or some text .. That means my canvas settings are not correct ..
This is my canvas settings.
When I change UI scale mode to constant pixel or constant physical size It doesn't show properly even in unity or on phone seems like he zoom in automaticlly too much. I made the best settings for UI SCALE MODE - > Scale with screen size, but on some devices it doesn't show up correctly ( it shows with little errors like corner text is not shown because it looks like he is outside of screen)
I hope someone has solution for this.
Here is my general settings of canvas, which i always use and never got any issue in positioning.
Also when you put any object, RectTransform's value(marked in following image) is not set properly then it will go outside of screen.
For more details see : https://docs.unity3d.com/Manual/class-RectTransform.html
Also you can check different screen ratio from unity and even add new to it and test.

Scaling all images to console size XNA

The "game" I am trying to create has many buttons and images on the screen at once, and the buttons are designed for the base (what I believe to be 800x600) console size. The buttons and sprites are all in set positions.
The issue I am having is trying to get every image to scale when I do isfullscreen=true. The images stay in their relative position, but I need them to 'scale' based on the the actual size of the window.
While searching for an answer, I have found many that scale individual images or scale them based on the aspect ratio but what I am attempting to do is scale all images, no matter the aspect ratio, depending on the actual size of the XNA window. For example, If I have 3 100x60 sprites and 2 200x90 sprites placed on a 800x600 screen, how would I change the sprites to be the same relative size if the window size were to be changed to 1980x720 without having to manipulate each image?
Thanks
Edit: I've tried using a scale matrix, but that seems to require me setting the EXACT scale for that exact size, meaning I have to create a different scale matrix for each possible window size, which is not what I am trying to achieve.
I've fixed the issue i've been having using a ScaleMatrix, as I was using them incorrectly before.
Before, I was using a matrix of (800, 600) but now (I don't have access to the environment right now so it will have to be in pseudo) I have changed the code so its a variable scale:
(f)XScale = 800 / Viewport.Width
(f)Yscale = 600 / Viewport.Height
Matrix.createScale(XScale, YScale, 1 , 1)
I then passed this to the Spritebatch.Begin. The issue is, if you have something rendered to a triangle (Such as a background), then you may wish to render it in a different spritebatch.Begin as this scale will mess with the triangle.
I have a background rectangle and it applies the scale to it, which puts it off the screen. Its fine if it is something you wish to have scaled, such as a button rectangle.

How to stretch the video completely

I am using axWindowsMediaPlayer and when I make the screen full, video is being shown but the player put 2 black block near side of video. I don't want these blocks.
I tried
axWindowsMediaPlayer1.stretchToFit = true;
but that didn't work. Because my video is 800*600 and my screen 1920*1080, the problem might be. Any way to solve this problem programatically? I don't want to resize video.
Thanks in advance.
AxWMPlayer does not support nonuniform stretching. So, you have to either:
- make the WMPlayer of normal desired size, stretch uniformly (StretchToFit=true) and live with the black margins if they show up
- make the WMPlayer oversized in Height or Width (so that it sticks out of the target space), stretch uniformly (StretchToFit=true). Due to the oversized WMPlayer, some of the video will be trucated (displayed outside of the space) but also the black margins will be truncated
Those two ways will mantain aspect ratio.
If you don't need aspect ratio kept, you may apply some ScalingTransform (WPF) or another similar effect to stretch the view afterwards. You will need to calculate coordinates properly, but the fact that WMP always centers the video and that you can read the video dimensions from IWMPMedia helps much.

Camera Output in fullscreen - Windows Phone

I'm working on augmented reality and I wanted to know if it was possible to get the camera output in fullscreen with a normal scale. I'm currently able to get a deformed output (everything is larger than in the real world).
Edit:
I found in the PhotoCamera class on msdn that I have to use camera.AvailableResolutions. This returns an IEnumrable of Size, each one being a supported resolution.
Based on your comment:
I do not understand this. Do you mean to say that the aspect ratio is
wrong; squares becoming rectangular? Could it be that you are
displaying/stretching the picture incorrectly?
Yeah that's what I mean, the image is stretched because the camera is taking an image in 640x480 and the screen is in 800x480
In the UI where you display the image, set the Stretch to None, Uniform or UniformToFill. Do not use Fill that will distort the image.
<Image Source="..." Stretch="Uniform" />
See these examples on the MSDN
Each phone has different lens focal length and screen size. There is no API to scale camera output to physical dimensions of real world (to see the world on the screen like through transparent window). Also, the distance from user eyes to the phone is affected to what should be displayed. You could experimentally find average scale factor to best map camera output to phone screen.
EDIT:
From the beginning it was like the question was not about distortions on different screen orientations but like augmented reality problem.

Categories

Resources