Optional Width and Height parameter for DisplaySprite

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Deeem2031
Enthusiast
Enthusiast
Posts: 216
Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:

Optional Width and Height parameter for DisplaySprite

Post 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
irc://irc.freenode.org/#purebasic
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
User avatar
Deeem2031
Enthusiast
Enthusiast
Posts: 216
Joined: Sat Sep 20, 2003 3:57 pm
Location: Germany
Contact:

Post 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.
irc://irc.freenode.org/#purebasic
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
Post Reply