AutoFit (update)

44 replies to this topic
Posted 1+ years ago #26
Supertino

Well I was coming here to enquirer about using scissors on a scaled display and it seems that siread has come up with a solution. yippee.

As always a big THANKYOU to James Boyd for autofit and a hearty handshake to sired, though I am sure sired is too busy mixing with his new high end dev friends and driving around in one of his many sports cars to care :p

 
Posted 1+ years ago #27
DruggedBunny

I was actually going to update it with Si's scissor stuff a while ago... will do soon-ish!

 
Posted 10 months ago #28
Sammy

Just test out this module, looks great but I am having a little trouble.

Just for testing purposes I set up a virtual display of 1280x720 but noticed that the first line of the virtual display was intermittently not being displayed. I assumed that this was just due to the physical screen resolution not matching the virtual one. So I set the virtual screen to match the physical one, so it should not really be scaling and yet the first line is still missing?

This does not draw a rectangle:-

DrawLine(0, 0, 1279, 0)
DrawLine(0, 719, 1279, 719)
DrawLine(0, 0, 0, 719)
DrawLine(1279, 0, 1279, 719)

This does? :-

DrawLine(0, 1, 1279, 1)
DrawLine(0, 719, 1279, 719)
DrawLine(0, 0, 0, 719)
DrawLine(1279, 0, 1279, 719)

It's not a big deal but it may be indicative of a bug.

 
Posted 10 months ago #29
RENGAC

Hi! It's possible to "stretch" the virtual canvas to fill the screen, even if it means to lose the aspect ratio?

 
Posted 9 months ago #30
Sensei

Just wanted to say a huge thanks to @druggedbunny for this awesome piece of code. I initially tried doing my own thing, which worked, but it was nowhere near as elegant as this. Thank you for making my life easier :)
The screen rotate and scale changes are simply a godsend.

 
Posted 9 months ago #31
Snader

Yeah, autofit rocks! I would like to see a possibility to stretch the virtual canvas if, for example, the black border only takes 5% of the total deviceheight or devicewidth. It will lose the aspect ratio, but not much.

 
Posted 7 months ago #32
Loofadawg

How do I get rid of artifacts from Autofit?

If you look at the arrow - between the squares is a red line. It is as if the images bleed through.

The second image is with Autofit turned off, and voila.. no more artifacts.

The images are 64x64 and the horizontal / vertical parameter for Autofit is 512 / 768.

I am guessing it has a lot to do with the ratio. But where does the red come from? The neighboring image from the file contains red, but it shouldn't bleed into the other image should it? I changed the image to cyan and sure enough the red becomes cyan.

The image file itself is 28 64x64 going 7 across and 4 deep.

Again.. When I disable Autofit, it goes away.

 
Posted 7 months ago #34
Loofadawg

Not sure what DeFringe is but the the site is currently down. :(

I am going to write some code up in a bit to hopefully load up the "sprite sheet" image and cut it up into the 64x64 pieces and stick them in an array and see if that helps.

 
Posted 7 months ago #35
Loofadawg

We ( or maybe just *I* ) need a FAQ for Monkey. It appears this type of thing has been discussed many times.. just buried deep in the forums. :)

 
Posted 7 months ago #36
Nobuyuki

Be sure to pad the images, edge fringe is often the result of the bilinear filtering process grabbing pixels from beyond the borders of the texture being displayed and processing them into the end result you see on screen. AutoFit doesn't actually do this, the hardware does. There are multiple solutions to the problem, but probably the easiest (and with least impact on performance) is to simply pad the image.

Now, gaps in tiles is another matter, there are a bunch of problems/solutions for that, depending on whether you need alpha accuracy....

 
Posted 7 months ago #37
Loofadawg

Nobuyuki and therevills, Thank you both for your help.

 
Posted 7 months ago #38
Raul

question:
in the last 'autofit' file I observed the GetMultiratio it is missing. i needed that function for my calculations.

why did you delete that function?

 
Posted 7 months ago #39
DruggedBunny

@Raul: I think that might be in Nobuyuki's AutoScale -- it was never in AutoFit anyway!

 
Posted 7 months ago #40
Raul

@DruggedBunny: I have an old project with those 2 functions... The filename is AutoFit. I never used Nobuyuki's AutoScale :D

Function GetBlackWidth:Int()
	Return VirtualDisplay.Display.widthborder
End

Function GetMultiratio:Float()
	Return VirtualDisplay.Display.multi
End

Strange...

 
Posted 7 months ago #41
DruggedBunny

Someone else must have added those, then -- didn't have a GetBlackWidth either!

 
Posted 7 months ago #42
Arabia

Finally got around to downloading this and giving it a go. Took me all of 5 mins to update my code and get it working.

Thanks DruggedBunny, saved me a lot of work and most likely headaches trying to do this myself.

 
Posted 7 months ago #43
rIKmAN

I've got a bit of a weird one and was wondering if I could get some help?

I've been using autofit 2.0 in my project for a while now without issues - so much so that I had forgotten about it - and everything has been working great, but it's started playing silly buggers tonight and I have no idea why.

It is 'Imported' fine, and the SetVirtualDisplay and UpdateVirtualDisplay are tokenised normally in the editor (JungleIDE) so the keywords are recognised properly, everything compiles etc

However if I add VMouseX(), VMouseY(), VTouchX() or VTouchY() then I've noticed that they are tokenised in italic, and I get the following error when I actually click/touch:

Monkey Runtime Error : TypeError: Cannot call method 'p_TouchX' of null

The code I am running to get this is just a debug line:

If TouchHit(0)
    DebugLog "vx: " + VTouchX() + " , vy: " + VTouchY()
EndIf

I should note that I am also using iEngine from the Ignition Framework to swap between game states, and that autofit is working fine in one of the other states (and the commands are not italic in that source either) - just not in this particular one that I added tonight.

I have tried adding autofit, SetVirtualDisplay and UpdateVirtualDisplay to the files manually (as opposed to Importing them from another file) but the issue persists and I keep getting the null error.

Anyone got any ideas?

 
Posted 7 months ago #44
rIKmAN

OK I seem to have found the problem - I now have precede the VTouchX/VTouchY() etc commands like so...

DrawText "I'm scaled", autofit.VTouchX(), autofit.VTouchY()

I guess something changed since I first used the autofit stuff I coded, but I'll leave it here in case anyone else has the same issue in future.

 
Posted 7 months ago #45
DruggedBunny

Hmm, I can only imagine another module has similarly-named commands if that's what solved it.