I was doing some functions to generate textures.
I made a function where u can initialize a memblock to store imagedata. Another function plots colordata into the memblock according to x,y position.
There is also some other functions here that i did not use in the example.
Anyway i generated a simple texture and i got a nice glenzvector.
backdrop on : color backdrop 100: sync on: sync rate 60
HIDE MOUSE : SYNC ON
CreateImageMemblock(1, 256, 32)
CreateImageMemblock(2, 256, 32)
` Create texture
FOR tempx = 0 TO 255
FOR tempy = 0 TO 255
color = color + tempx*tempy
PlotXY(1, tempx,tempy, RGB(tempx, tempx-tempy,tempx+tempy), 256)
NEXT tempy
NEXT tempx
FOR tempx = 0 TO 255
FOR tempy = 0 TO 255
color = color + tempx
PlotXY(2, tempx,tempy, RGB(color, tempx,color ), 256)
NEXT tempy
NEXT tempx
REM MergeMemblocks(1,2,256)
MAKE IMAGE FROM MEMBLOCK 2,1
MAKE OBJECT CUBE 1, 10
MAKE OBJECT CUBE 2, 10
SCALE OBJECT 1, 200, 200, 200
SCALE OBJECT 2, 15, 450, 150
POSITION OBJECT 1, 0, 0, -22
POSITION OBJECT 2, 0, 0, 4
SET OBJECT CULL 1, 0
SET OBJECT CULL 2, 0
TEXTURE OBJECT 1, 2
TEXTURE OBJECT 2, 2
GHOST OBJECT ON 1, 3
GHOST OBJECT ON 2, 4
MAKE LIGHT 1
SET LIGHT TO OBJECT POSITION 0, 1
SET LIGHT TO OBJECT ORIENTATION 1, 2
SET NORMALIZATION ON
DO
YROTATE OBJECT 1,OBJECT ANGLE Y(1)+0.8
XROTATE OBJECT 1,OBJECT ANGLE Y(1)+0.2
ZROTATE OBJECT 1,OBJECT ANGLE Z(1)+0.4
YROTATE OBJECT 2,OBJECT ANGLE Y(2)+0.8
XROTATE OBJECT 2,OBJECT ANGLE Y(2)-0.2
ZROTATE OBJECT 2,OBJECT ANGLE Z(2)-0.4
SCROLL OBJECT TEXTURE 2, 1.01, 1.02
SYNC
LOOP
`Plots a color to the specific x,y position.
FUNCTION PlotXY(memblocknumber as integer , x as integer, y as integer, color as DWORD, size as integer)
write memblock DWORD memblocknumber, (y*size+x)*4+12, color
ENDFUNCTION 0
`Reads a DWORD related to the x,y position in the image.
FUNCTION ReadXY(memblocknumber as integer, x as integer, y as integer, color as DWORD, size as integer)
Value = MEMBLOCK DWORD(memblocknumber,(y*size+x)*4+12)
ENDFUNCTION Value
`Merge 2 memblocks that holds imagedata.
FUNCTION MergeMemblocks(destination as integer, source as integer, size as integer)
FOR tempx = 0 TO 255
FOR tempy = 0 TO 255
tempdest = MEMBLOCK DWORD(destination, (tempy*size+tempx)*4+12)
tempsource = MEMBLOCK DWORD(source, (tempy*size+tempx)*4+12)
write memblock DWORD destination,(tempy*size+tempx)*4+12, tempdest + tempsource / 2
NEXT tempy
NEXT tempx
ENDFUNCTION 0
`Create a Memblock that gonna store Image data
FUNCTION CreateImageMemblock(memblocknumber as integer, size as integer, bitdepth as integer)
MAKE MEMBLOCK memblocknumber, (size*size*(bitdepth/8))+12
write memblock dword memblocknumber,0,size
write memblock dword memblocknumber,4,size
write memblock dword memblocknumber,8,bitdepth
ENDFUNCTION 0