So I have started on making some functions to add some basic buttons, slider etc to projects, started off easy with the BUTTON but already hitting a snag creating the images=>sprites for it, the below code should create a sprite that is half as high and half as wide as the window but it doesn't, I can provide any value to width and height and it's always spits out a sprite that is wildly wrong dimension wise, the sprite also looks blurred so is it being scaled?
SetSyncRate( 60, 1 )
SetWindowTitle( "test proj" )
SetWindowSize( 1024, 768, 0)
Type TWidget
sprite as Integer
width as Float
height as Float
x as Float
y as Float
EndType
Function rkWidgetMakeButton(a ref as TWidget, iWidth as Float, iHeight as Float)
a.width = iWidth
a.height = iHeight
local col as integer
col = MakeColor(255,55,255)
local img as integer
img = CreateRenderImage(iWidth,iHeight,0,0)
SetRenderToImage(img,0)
DrawBox(0,0,iWidth,iHeight,col,col,col,col,1)
SetRenderToScreen()
a.sprite=createsprite(img)
EndFunction
Function rkWidgetSetPosition(a ref as TWidget,iX as Float, iY as Float)
a.x = iX
a.y = iY
SetSpritePosition(a.sprite,a.x,a.y)
EndFunction
Global button as TWidget
rkWidgetMakeButton(button,512,366)
rkWidgetSetPosition(button,0,0)
do
sync()
loop