Page 1 of 1

Optional Width and Height parameter for DisplaySprite

Posted: Thu Sep 03, 2009 8:43 am
by Deeem2031
I doubt adding optional Width and Height parameter for DisplaySprite() is a big problem in any of the subsystems (I'm not sure for SDL but at least in OpenGL, DX7 and DX9 it should be possible) even though it would help alot for many cases of 2D graphic programming.



Until now I helped me out with this when using DX7:

Code: Select all

Procedure DisplaySpriteEx(Sprite, x, y, width, height)
    Protected *Sprite.PB_Sprite = IsSprite(Sprite)
    If *Sprite
      Protected *BackBuffer.IDirectDrawSurface7
      !extrn _PB_DirectX_BackBuffer
      !MOV Eax, [_PB_DirectX_BackBuffer]
      !MOV [p.p_BackBuffer], Eax
      Protected rect.RECT 
      rect\left = x
      rect\right = x + width
      rect\top = y
      rect\bottom = y + height
      *BackBuffer\Blt(rect, *Sprite\Sprite, 0, 0, 0)
    EndIf
EndProcedure

Posted: Thu Sep 03, 2009 8:57 am
by Kaeru Gaman
1. wouldn't you need TWO pairs of X/Y, one for the display point and one for the clipstart?

2. istn't that exactly the use what the native command ClipSprite() is for?


PS:
or is it about stretching?

then ZoomSprite3D() is the native Command you're looking for.

Posted: Thu Sep 03, 2009 9:09 am
by Deeem2031
Kaeru Gaman wrote:1. wouldn't you need TWO pairs of X/Y, one for the display point and one for the clipstart?

2. istn't that exactly the use what the native command ClipSprite() is for?


PS:
or is it about stretching?

then ZoomSprite3D() is the native Command you're looking for.
Yea sure it's about stretching the Sprite. And ZoomSprite3D is not a good solution because first you need to create a Sprite3D and second you need to resize it to a power of 2 size and then resize it again. Thats neither speed nor resource efficient, and might be even impossible for bigger sprites.

Posted: Thu Sep 03, 2009 9:16 am
by Kaeru Gaman
so this what you posted is a sole 2D effekt?

... then it's already overdue, there is no real 2D in >= DX9 and on 'modern' grafix hardware anymore.


btw...
a texture doesn't need (2^n)², but (2^x * 2^y), and on most modern cards it's no longer really needed, but just much faster.
and you don't want to stretch the information to put it on a texture, but add some free frame to make it fit.
if you have an 1000x800 Image, you would put it topleft aligned on a 1024x1024 texture.