DrawImageRect how it used to work

BlitzMax Forums/BlitzMax Programming/DrawImageRect how it used to work

RetroRusty(Posted 2005) [#1]
Is there a way of getting DrawImageRect to do what it used to do and not what it now does in BlitzMax?

I have tried the mod from Noel Cower called DrawImageBlock but it doesn't work properly.

Thanks


Dreamora(Posted 2005) [#2]
You have to "hack" the standard structure

just set

image.frame[0].u1 /.v1 according the coord you want it to have (did that as well for my energy bar)


N(Posted 2005) [#3]
Private

Global ix#
Global iy#
Global jx#
Global jy#
c_setupTrans(0)

Public

Function c_setupTrans(theta#)
	Local c#,s#
	c=Cos(theta)
	s=Sin(theta)
	ix=c
	iy=-s
	jx=s
	jy=c
End Function

Function DrawImageBlock(Img:TImage,X#,Y#,Width#,Height#,TX#,TY#,TWidth#,THeight#,Frame%=0,Rotation#=0,MX#=0,MY#=0)
	Local texEnabled:Int = glIsEnabled(GL_TEXTURE_2D)
	If texEnabled=0 Then glEnable(GL_TEXTURE_2D)
	
	c_setupTrans(rotation)
	
	Local UF:Float = TX / Img.Width
	Local VF:Float = TY / Img.Height
	Local UT:Float = (TX+TWidth) / Img.Width
	Local VT:Float = (TY+THeight) / Img.Height
	
	Local frm:TGLImageFrame = TGLImageFrame(Img.frames[frame])
	
	glBindTexture(GL_TEXTURE_2D,frm.name)
	
	glBegin GL_QUADS
	
	glTexCoord2f(UF,VF)
	glVertex2f(mx+x*ix+y*iy,my+x*jx+y*jy)
	
	glTexCoord2f(UT,VF)
	glVertex2f(mx+(x+width)*ix+y*iy,my+(x+width)*jx+y*jy)
	
	glTexCoord2f(UT,VT)
	glVertex2f(mx+(x+width)*ix+(y+height)*iy,my+(x+width)*jx+(y+height)*jy)
	
	glTexCoord2f(UF,VT)
	glVertex2f(mx+x*ix+(y+height)*iy,my+x*jx+(y+height)*jy)
	
	glEnd
	
	If texEnabled=0 Then glDisable(GL_TEXTURE_2D)
End Function


I wouldn't recommend un-private-ing the globals there.


gman(Posted 2005) [#4]
also, there is one from teammonkey. i used it for the mappy mod. you can see it here.