DrawImageRect how it used to work

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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.