If you only have to draw on spheres you can use this:
Sync on
Sync rate 60
` Create the sphere
make object sphere 1, 10
` Create an image to draw to
// Use these lines if you don't have the Matrix1Utils
// ----------->
imageWidth = 128
imageHeight = 128
make memblock 1, imageWidth*imageHeight*4 + 12
write memblock dword 1, 0, imageWidth
write memblock dword 1, 4, imageHeight
write memblock dword 1, 8, 32
make image from memblock 1, 1
// <----------
// Use the next line if you have the Matrix1Utils
// ----------->
`make image 1, imageWidth, imageHeight
// <----------
` Apply the image to the sphere
texture object 1, 1
` Main loop
Do
` Rotate the object
rotate object 1, 0, object angle y(1)+1, 0
` Check if the mouse is on the sphere
if pick object(mousex(), mousey(), 1, 1)
` Get the position of the mouse on the sphere
x# = get pick vector x() + camera position x()
y# = get pick vector y() + camera position y()
z# = get pick vector z() + camera position z()
` Calculate the angle from the center
ay# = wrapvalue(-atanfull(x#, z#) + object angle y(1))
ax# = wrapvalue(atanfull(sqrt(x#*x# + z#*z#), y#))
` Make uv coordinates from the angle
u# = ay# / 360.0
v# = ax# / 180.0
` Transform the uv into pixel data
px = u# * image width(1)
py = v# * image height(1)
// Use these lines if you don't have the Matrix1Utils
// ----------->
` Draw to the image
if mouseclick()
` Get the position in the memblock of the pixel
pos = (py * image width(1) + px) * 4 + 12
` Change the color of the pixel in the memblock
write memblock dword 1, pos, rgb(255, 0, 0)
` Recreate the image
delete image 1
make image from memblock 1, 1
texture object 1, 1
endif
// <----------
// Use these lines if you have the Matrix1Utils
// ----------->
remstart
` Draw to the texture
draw to image 1
` Draw a box if the mouse is pressed
if mouseclick()
ink rgb(255, 0, 0)
box px - 4, py - 4, px + 4, py + 4
ink rgb(255, 255, 255)
endif
draw to bitmap 0
remend
// <----------
endif
` Print some debug info
set cursor 0, 0
print "ax: ", ax#
print "ay: ", ay#
print "u: ", u#
print "v: ", v#
` Sync the screen
Sync
Loop
