Here's some code to draw a dot very fast. It's very useful if you're drawing a relatively small number of dots and don't want to be slowed by the 'dot' command.
//
// globals and initiation code {
global ptr__d as dword
global ptr__ as dword
global ppitch as dword
lock pixels
ptr__ = get pixels pointer()
ppitch = get pixels pitch()
unlock pixels
// } make sure you do this AFTER you use 'set display mode', change the resolution, and whatnot.
//this is the actual part that draws the dot.
// You have to substitute your your values with whatever I have
// in the square brackets. Make sure the dot is within the screen or your
// program will either crash, or draw the dot in a weird place.
ptr__d = ptr__+( [x integer] )*4+( [y integer] )*ppitch
*ptr__d = [color dword]
// alternately, you can use this function. It's about 6 times
// slower though (on my machine at least),
// but here it is just for the heck of it.
function dot_(xp,yp,color as dword)
ptr__d = ptr__+xp*4+yp*ppitch
*ptr__d = color
endfunction
I tested it, and it works better without using 'lock pixels'. It's way faster than dot on its own, and still faster when DOT is using lock pixels. However, if you start using DOT with lock pixels in bulk, at a certain point it becomes faster to use DOT with lock pixels than this code.
Heres the code I used to test it. Move the mouse up and down to modify the times each method of drawing a dot is used per second.
set display mode 1440,900,32
sync on
global ptr__d as dword
global ptr__ as dword
global ppitch as dword
lock pixels
ptr__ = get pixels pointer()
ppitch = get pixels pitch()
unlock pixels
h as double integer
z as double integer
do
cls 0
my = mousey()*mousey()*.5
text 0,400,"amount of dots drawn per second each = "+str$(my)
h = perftimer()
for i = 0 to my
next i
z = perftimer() - h
text 50,10,"control (aka the loop doing nothing at all): "+str$(z)
h = perftimer()
for i = 0 to my
ptr__d = ptr__+2*4+2*ppitch
*ptr__d = 0xFFFFFFFF
next i
z = perftimer() - h
text 50,20,"ptr dot: "+str$(z)
h = perftimer()
lock pixels
for i = 0 to my
dot 2,2,0xFFFFFFFF
next i
unlock pixels
z = perftimer() - h
text 50,30,"dot: "+str$(z)
sync
wait 100
loop
function dot_(xp,yp,color as dword)
ptr__d = ptr__+xp*4+yp*ppitch
*ptr__d = color
endfunction
On my machine, DOT and this code become about equal at about 4500 times (I'm too lazy to make it properly average the results though). Above that DOT with lock pixels is faster, and below that my code is. I'm interested as to other people's results.