SOLVED by matchy Is there any "sharp" Polyvector equivalent?

Previous topic - Next topic


I would like to use something like PolyVector to resize/reshape sprites without getting the blur effect that otherwise smoothes the sprite/bitmap out on my machine. As a crude example, take this code to resize a sprite "Checker.Png":

Code (glbasic) Select
LOADSPRITE "Checker.png", 1
ResizeSprite(1, 2, 512, 512)
SAVESPRITE "Blurry.png",2

// ------------------------------------------------------------- //
// ---  RESIZESPRITE  ---
// ------------------------------------------------------------- //
FUNCTION ResizeSprite: SourceSprite%, TargetSprite%, destWidth%, destHeight%
// Uses "virtual screen" 0
// These values are defined LOCAL:
// SourceSprite%,  TargetSprite%,  Width%,  Height%

LOCAL spritewidth%, spriteheight%
GETSPRITESIZE SourceSprite%, spritewidth%, spriteheight%

CREATESCREEN 0, TargetSprite%, destWidth%, destHeight% // create temporary workscreen of desired resolution


//Copy sprite #0 to target sprite and stretch to fit
STARTPOLY SourceSprite% // Bitmap = No.SourceSprite%
  POLYVECTOR  0,   0,  0,  0, RGB(255, 255, 255) // top left
  POLYVECTOR   0, destHeight%-1,  0, spriteheight%-1, RGB (255, 255, 255) // bottom left
  POLYVECTOR destWidth%-1, destHeight%-1, spritewidth%-1, spriteheight%-1, RGB(255, 255, 255) // bottom right
  POLYVECTOR destWidth%-1,  0, spritewidth%-1,  0, RGB(  255, 255,   255) // top right

USESCREEN -1 // switch back to main screen
LOADSPRITE "", SourceSprite% // empty source sprite/release memory/resources

As you can see from the attached images, the result is slightly blurry - scaling up by more increases the blur factor quite a lot. I beleive this is the cause of some tiling issues in other posts lately.

I'm pretty confident that for just resizing a rectangular area there must be a simple solution, but I'd really like to use PolyVector simply because I relaly REALLY want to be able to resize/reshape random triangles. Any bright ideas? Is there a "set sharpness" function I can use somewhere to effectively turn blurring off?

[attachment deleted by admin]

Ian Price

I came. I saw. I played.


Yup! That's the fix that matchy pointed out to me (beating MrTAToad and also you).

I love a helpful community :) as not being able to find that switch was making me unhappy in a fairly big way this morning :(


SMOOTHSHADING FALSE is worthy of be subject of.  :blink: I had the same issue with my Minecraft clone using small textures and Kitty suggested it in IRC just before the issue was posted.


I've updated the Wikki to put SMOOTHSHADING as a reference in both PolyVector and ZOOMSPRITE commands (I wish I rememberd to do this more often, but I do TRY to do it so that it's easiler to dins related stuff in future).


Is it a simple on/off toggle for everything, or can you set it to false, draw some stuff, set it true draw some more stuff, and have some sprites smooth, and some not?


You can set it to false, draw some crisp/sharp stuff, then smooth and draw some smoothed stuff :D

You could resize a whole sprite up using smoothing off for sharp edges, then turn smoothing back on and resize up 1 pixel smaller all around to get a smooth interior.


Quote from: matchy on 2010-Sep-24I had the same issue with my Minecraft clone using small textures...

And here it is: Minecraft clone  :coke: :coke:

Kitty Hello

looking good so far. The collision is a bit jerky. For the vertical stuff I'd put the player always on the rounded value of the block height (if not jumping/falling). You have the advantage of knowing the block positions. Also, don't use X_COLLISION, but do it manually on the lpayer coordinates and the grid array.


It certainly looks interesting (and nice and crisp!) but I feel rather a dunce, not knowing what Minecraft is or what I should be doing :(


Thanks for checking it out! I figured half way through that I can just use grid calcs for many of the layout and movement and keep the X_3D stuff minimal. Note that is was for fun so I'm not too concerned about finish it but at least fix the bugs and present a iPhone version. Hopefully someone may design glb mc clone terrain builder as discussed on the main Minecraft thread. :zzz: