I just can't figure out what's going on here:
I want to make sure my drawing operations are not clipped, and are offset 224 pixels in the Y direction (I want to draw in the bottom 16px of the screen.
My code does seem to influence rectangles, circles and fonts, but not image drawing:
local function drawIcon(x, index)
hudIcons:draw(x,0,unFlipped,index*16,0,16,16)
end
function RenderHUD()
printf("cliprect 1", gfx.getClipRect())
gfx.setClipRect(0,0,400,240)
printf("cliprect 2", gfx.getClipRect())
gfx.setDrawOffset(0,hudY)
printf("cliprect 3", gfx.getClipRect())
printf("screenCliprect", gfx.getScreenClipRect())
gfx.setColor(hudBgClr)
gfx.fillRect(0,0,400,16)
gfx.setColor(hudFgClr)
local x = hudPadding
-- lives
drawIcon(x, 7)
x = x+16+hudGutter
font:drawText(extras[2], x, 0)
x = x+10+hudPadding
-- fuel
if fuel > 1500 or frameCounter % 20 > 10 then
drawIcon(x, 5)
end
x = x+16+hudGutter
gfx.drawRect(x, 1, 32, 14)
local fuelW = (fuel/6000)*28
hudIcons:draw(x+2, 2, gfx.kImageUnflipped,0,16,fuelW,10)
x = x+32+hudPadding
-- speed warning
drawIcon(x, 3)
x = x+16+hudGutter
gfx.drawCircleInRect(x+1,1, 14,14)
local speedPattern = gfx.image.kDitherTypeBayer4x4
local warnX = 1/(landingTolerance[1] / math.abs(vx))
local warnY = 1/(landingTolerance[2] / vy) -- only downwards movement is dangerous
local warnAlpha = math.max(warnX, warnY)
gfx.setDitherPattern(1-warnAlpha, speedPattern) -- invert alpha due to bug in SDK
gfx.fillCircleInRect(x+4,4, 8,8)
gfx.setDitherPattern(1, gfx.image.kDitherTypeNone)
x = x+16+hudPadding
[..]
Output:
cliprect 1 0 0 400 240
cliprect 2 0 0 400 240
cliprect 3 0 -224 400 240
screenCliprect 0 0 400 240
(notice missing icons in the HUD)
What am I missing here? I would expect the clipRect / screenClipRect to be 0,0,400,240 and drawOffset to be 0, +224