Help me with "RenderToImage", do not understand how it works !?
See my faltering attempts!
first method
works: here I set the "Virtual Resolution" to the size of the newly created "image"
- I use DrawBox, DrawLine or whatever..............
- Then i setting back the "Virtual resolution" to the original size
function create_SpriteImage()
local imgID as integer, color as integer
local virtSizeX as integer, virtSizeY as integer
virtSizeX = GetVirtualWidth() : virtSizeY = GetVirtualHeight()
color = MakeColor(255,0,0)
imgID = CreateRenderImage(16, 16, 0, 0)
SetVirtualResolution(16,16)
SetRenderToImage(imgID, 0)
DrawBox(0, 0, 15, 15, 0x00ff00,0x00ff00,0x00ff00,0x00ff00,0)
drawline(0, 0, 15, 15,0x0000ff, 0x0000ff)
drawline(0, 15, 15, 0,0x0000ff, 0x0000ff)
SetRenderToScreen()
SetVirtualResolution(virtSizeX, virtSizeY)
SetClearColor(0,0,0)
endfunction imgID
second methods
works: I use "SetClearColor" and "Clear Screen", I do not change the resolution.
function create_Sprite_1()
local imgID as integer, color as integer
local sprID as integer
color = MakeColor(255,0,0)
imgID = CreateRenderImage(16, 16, 0, 0)
SetClearColor(255, 0, 0)
SetRenderToImage(imgID, 0)
ClearScreen()
SetRenderToScreen()
SetClearColor(0,0,0)
sprID = CreateSprite(imgID)
endfunction sprID
third method does not work: why not ?? I have tried all possible and impossible coordinates!
function create_Sprite_2()
local imgID as integer, color as integer
local sprID as integer
color = MakeColor(0, 255, 0)
imgID = CreateRenderImage(16, 16, 0, 0)
SetRenderToImage(imgID, 0)
DrawBox(512-8, 384-8, 512+8, 384+8, color, color, color, color,1) // what ?? dosen't work !?
DrawBox(0,0,15,15, color, color, color, color, 1) // what ?? dosen't work !?
SetRenderToScreen()
sprID = CreateSprite(imgID)
endfunction sprID
I would be very happy if someone has the time to show a working example,
preferably correcting my third example!