-
Jun 15th, 2021, 09:48 AM
#1
Thread Starter
Addicted Member
[RESOLVED] XNA Form Resize iusse
Hello,
I'm using the code from https://www.vbforums.com/showthread....-XNA-in-VB-Net to draw a lines chart( I simply put a for cycle inside the backgroundworker to draw all the lines).
My problem is that when i resize the form(or I maximize it), the picturebox stretch the chart instad to redraw it correctly; If I correctly understand, I need to change the backbufferHeight and Widht, but all example that I've found are not "winform" ,and the have a different structure; any advice?
-
Jun 15th, 2021, 12:26 PM
#2
Re: XNA Form Resize iusse
Are you really using just XNA, or are you using MonoGame? The latter is an open source extension of XNA, which works more easily with newer versions of VS. If you are still using XNA, that kind of restricts you to FW 4.0 and VS 2010 (though you can get it working in later versions of VS). I moved over to MonoGame...and found it virtually painless. However, there are some slight differences, and more resources for MonoGame, which targets a newer version of DirectX, so it's important to make a distinction between plain vanilla XNA and MonoGame (which still uses the XNA libraries).
My usual boring signature: Nothing
-
Jun 15th, 2021, 12:38 PM
#3
Thread Starter
Addicted Member
Re: XNA Form Resize iusse
For now xna 4.0, but I'm thinking about to switch to monogame.
-
Jun 15th, 2021, 02:03 PM
#4
Re: XNA Form Resize iusse
I heard that the guy who wrote that thread is pretty cool
I personally haven't touched XNA since around the time that thread was written. However, assuming that you're using the Set2dLine method I wrote, then what you'll need to do is apply a little bit of math to adjust for the form resizing. Presumably, you're drawing on a PictureBox, in which case you can get the ClientSize to set the relative size of chart lines.
-
Jun 15th, 2021, 11:53 PM
#5
Thread Starter
Addicted Member
Re: XNA Form Resize iusse
Originally Posted by dday9
I heard that the guy who wrote that thread is pretty cool
I personally haven't touched XNA since around the time that thread was written. However, assuming that you're using the Set2dLine method I wrote, then what you'll need to do is apply a little bit of math to adjust for the form resizing. Presumably, you're drawing on a PictureBox, in which case you can get the ClientSize to set the relative size of chart lines.
yes, I'm using Set2dLine from your tutorial for drawing on a PictureBox, but I tryed also on a panel with same result. I anchored the PictureBox on the form, so when the form is maximized or resized, PictureBox change size according, problem is that it stretch all the chart(lines became so big that came over the border.. So i did some research and seem that what I should do is update the backbuffer size, I am not able to understand how, because all the example that I found use GraphicsDeviceManager(and use game template,not winform) that is missing in the tutorial.
-
Jun 16th, 2021, 11:26 AM
#6
Re: XNA Form Resize iusse
I don't think that is right. I think that you will need to adjust the BasicEffect's Projection (documentation) because right now it is only being set once when the Form loads, so once the Form resizes the projection is off.
-
Jun 16th, 2021, 11:53 AM
#7
Thread Starter
Addicted Member
Re: XNA Form Resize iusse
Originally Posted by dday9
I don't think that is right. I think that you will need to adjust the BasicEffect's Projection ( documentation) because right now it is only being set once when the Form loads, so once the Form resizes the projection is off.
Can you explain me how please?
-
Jun 16th, 2021, 12:03 PM
#8
Re: XNA Form Resize iusse
I imagine that this (untested) in the Resized event would work:
Code:
effect.Projection = Matrix.CreateOrthographicOffCenter(0, PictureBox1.ClientSize.Width, PictureBox1.ClientSize.Height, 0, 0, 1)
-
Jun 16th, 2021, 12:30 PM
#9
Thread Starter
Addicted Member
Re: XNA Form Resize iusse
Tested, and works. Thanks!!
Last edited by hannibal smith; Jun 16th, 2021 at 02:27 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|