XANAX:
This code will create a consistence look and with no errors on Mac/iPad2/iPad Air.
// Project: tmptmp
// Created: 2017-06-19
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "tmptmp" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
//CreateImageColor(1,255,0,0,0)
global mysprite
global spriteimg
global LAG_Border = 2
spriteimg = LoadImage("icon.png")
mysprite = CreateSprite(spriteimg)
ri = CreateRenderImage(512, 256, 0, 0)
mp = CreateSprite(ri)
SetSpriteSize(mp,256,256)
SetSpritePosition(mp,0,0)
SetClearColor(128,128,128)
LAG_Set_i_Texture(ri, 2,2 , 2, 2, 2)
SetClearColor(128,0,128)
do
Print( ScreenFPS() )
Sync()
loop
Function LAG_Set_i_Texture(rimg, btop, bright, bbottom, bleft, bsize)
w = GetImageWidth(rimg)
h = GetImageHeight(rimg)
img2 = GetSpriteImageID(mysprite)
w2 = GetImageWidth(img2)
h2 = GetImageHeight(img2)
SetSpriteSize(mysprite, w2, h2)
SetSpriteVisible(mysprite,1)
SetVirtualResolution(w, h)
SetRenderToImage(rimg, 0)
ClearScreen()
for y = 0 to h-1 step h2
for x = 0 to w-1 step w2
SetSpritePosition(mysprite, x, y)
DrawSprite(mysprite)
next
next
if btop = LAG_Border
DrawBox(0, 0, w, bsize, MakeColor(255, 255, 255), MakeColor(255, 255, 255), MakeColor(255, 255, 255), MakeColor(255, 255, 255), 1)
endif
if bbottom = LAG_Border
DrawBox(0, h - bsize, w, h, MakeColor(0, 0, 0), MakeColor(0, 0, 0), MakeColor(0, 0, 0), MakeColor(0, 0, 0), 1)
endif
if bleft = LAG_Border
DrawBox(0, 0, bsize, h, MakeColor(0, 0, 0), MakeColor(0, 0, 0), MakeColor(0, 0, 0), MakeColor(0, 0, 0), 1)
endif
if bright = LAG_Border
DrawBox(w - bsize, 0, w, h, MakeColor(255, 255, 255), MakeColor(255, 255, 255), MakeColor(255, 255, 255), MakeColor(255, 255, 255), 1)
endif
SetRenderToScreen()
SetSpriteVisible(mysprite,0)
SetVirtualResolution( 1024, 768 )
Endfunction
SetVirtualResolution , need to go before SetRenderToImage or iPad2 will display it wrong.
Your sprite need to be created like this or GetSpriteImageID will not work:
spriteimg = LoadImage("icon.png")
mysprite = CreateSprite(spriteimg) // AppGameKit createsprite must return the ID or it will not work.
I did not get any "gl_framebuffer_unsupported" on any of the devices , how many CreateRenderImage are you using ?
Hope it helps
best regards Preben Eriksen,