Slow progress - progress nonetheless:
// Probe testing
// Credit to original code provided by the following:
// Bengismo
// https://forum.thegamecreators.com/thread/221459
//Edited on 6 Jan 2020
// show all errors
SetErrorMode(2)
// Window size
local sizex# = 800
local sizey# = 800
// Initielise the window
gosub _init
// Load the shader
LoadFullScreenShader(1, "s_plot.ps")
LoadFullScreenShader(2, "s_show.ps")
LoadFullScreenShader(3, "s_show.ps")
// create the rendertextures
CreateRenderImage( 1, sizex#, sizey#, 0, 0 )
CreateRenderImage( 2, sizex#, sizey#, 0, 0 )
CreateRenderImage( 3, sizex#, sizey#, 0, 0 ) // is this necessary ?
// suspect can just render to image 2?
SetImageMagFilter( 1, 0 )
SetImageMinFilter( 1, 0 )
SetImageMagFilter( 2, 0 )
SetImageMinFilter( 2, 0 )
SetImageMagFilter( 3, 0 )
SetImageMinFilter( 3, 0 )
SetShaderConstantByName(1, "size", sizex#, sizey#, 0, 0)
SetShaderConstantByName(3, "size", sizex#, sizey#, 0, 0) // will this resolve not plotting
// to screen ?
// create drawing helpers
CreateObjectQuad(1)
SetObjectImage(1, 1, 0)
SetObjectShader(1, 1)
CreateObjectQuad(2)
SetObjectImage(2, 2, 0)
SetObjectShader(2, 2)
// create additional plotting object - Hmm, I'm missing something - or is this becoming the default
// drawing target ?
CreateObjectQuad(3)
SetObjectImage(3, 3, 0)
SetObjectShader(3, 3)
SetCameraPosition( 1, 0.0, 0.0, -2.5 )
SetCameraLookAt( 1, 0.0, 0.0, 0.0, 0 )
local sn# = 0.0
local rr# = 0.0
local gg# = 0.0
local bb# = 0.0
local xx# = 100
local yy# = 100
local slowdown=1
local gscale=255
do
loco = ScreenFPS()
sn# = sn# + 0.01
// draw a colorful Lissajous curve
rr# = rr# + 0.01
if rr# >= 256 then rr# = rr# - 256.0
gg# = gg# + 0.022
if gg# >= 256 then gg# = gg# - 256.0
bb# = bb# + 0.38
if bb# >= 256 then bb# = bb# - 256.0
//plot(floor(sin(sn#*1.2)*sizex#*0.45+sizex#*0.5), floor(cos(sn#)*sizey#*0.45+sizey#*0.5), rr#, gg#, bb#)
// move a red pixel across the screen
//plot2(xx#,yy#,gscale,gscale,gscale) // vain attempt at plotting 5 horizontal lines adjacent too each other
//plot2(xx#,yy#+1,gscale,gscale,gscale)
plot2(xx#,yy#+2,gscale,gscale,gscale)
//plot2(xx#,yy#+3,gscale,gscale,gscale)
//plot2(xx#,yy#+4,gscale,gscale,gscale)
//plot2(xx#,yy#,250,1,1)
slowdown=slowdown+1
if slowdown>100
if xx#<100
xx#=xx#+1
else
xx#=1
yy#=yy#+40
endif
slowdown=0
gscale=gscale-1
if gscale<2
gscale=255
endif
endif
if (GetRawKeyPressed( 27 ))
end
endif
SetRenderToImage( 1, -1)
DrawObject( 2 ) // Why is object 2 just up here
// And not after RenderToScreen ?
SetRenderToImage( 2, -1)
DrawObject( 1 )
// attempt at adding pixel (Object 3) marching to the right 100 pixels down
SetRenderToScreen()
// screen text
Print( "FPS: " + str(loco,2) )
Print( "xx: " + str(xx#,2) + "yy: " + str(yy#,2) + " gscale: " + str(gscale,2) )
DrawObject( 3 ) // This simply fails when uncommented
DrawObject( 1 ) // Uncommenting this line allows for red line to be drawn
// OR for the multi-coloured line to be drawn - dependent upon
// whether line 81 or 85 is commented out.....
Render2DFront()
//DrawObject( 3 )
//Render2DFront()
Swap()
//sync()
loop
function plot(x, y, r, g, b)
SetShaderConstantByName(1, "pos", x, y, 0, 0)
SetShaderConstantByName(1, "color", r, g, b, 0)
endfunction
// edited object 3 to object 1.....
function plot2(x, y, r, g, b)
SetShaderConstantByName(1, "pos", x, y, 0, 0) //
SetShaderConstantByName(1, "color", r, g, b, 0)
//SetShaderConstantByName(3, "pos", x, y, 0, 0) // trying 3 in here....
//SetShaderConstantByName(3, "color", r, g, b, 0) // 3 fails - suggesting something is not set up propelry.
endfunction
_init:
// set window properties
SetAntialiasMode( 0 )
SetWindowTitle( "Grayscale Plotter" )
SetWindowSize( sizex#, sizey#, 0 )
SetWindowAllowResize( 0 )
SetScissor( 0,0,0,0 )
setcamerarange(1, 0.05, 25)
SetGenerateMipmaps( 0 )
// set display properties
//SetVirtualResolution( 800, 800 )
//SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetClearColor( 0,0,0 )
return