prgmGCORE
Data(40r,-40r,40r)->GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r
GNewCam(pointer to camera)
.Destroys r1
GNewCam(°GMODELVIEW)
Glib also need a special structure, allowing easy vertex processing/clipping. It's called a VBO : vertex buffer object. Basically, it's just a ram area.GGenVBO(size,data_to_match)
.destroy r1,r2
your size is the number of vertices you want to have.GGenVBO(8,GDB1)->G
.I used G, but you can used any way to save this value
While 1
GUpdateVBO(G,0,7)
GVBOPoint(id_vertex)
.destroy r1
function to retrieve a point from VBO. It's store the x-coord and y-coord on screen to GScreenX and GSreenY var (alias OP1 and OP1+2)For(M,0,7)
GVBOPoint(M)
!If
Rect(GScreenX,GScreenY,2,2
End
End
GGetkey()
GGetkey()
DispgraphClrdraw // we want to have something on screen !
EndIf getkey(15) // stop the While loop if [clear] is pressed
GClipLine(ID_vertex1,ID_vertex2)
.destroy r1 to r6
This is assuming that a VBO has been set.Data(40r,-40r,40r)→GDB1 .vertex ID 0
Data(40r,40r,40r .vertex ID 1
Data(-40r,-40r,40r .vertex ID 2
Data(-40r,40r,40r ...
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r
Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1
For(M,0,11) .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End
GVertexShader(adress_of_function,sub_adress_projection)
.destroy r1,r2
you can of course get the adresse with the L operator.Lbl Shader
GRestoreHL
Return
Lbl Shader
GRestoreHL
GRotate()
Lbl SubShader .the famous sub_adress
Goto GProject
GRotate(x,z,y)
.destroy r1-r3
.write to OP
You will then have the vertex rotated coordinate to these variable :GVertexX
GVertexY
GVertexZ
GProject()
.need the 3D coordinate Inside OP1+6 (°GVertex+6)
GScreenX
GScreenY
GVertexShader(°GLIBFUNC)
yep it's the same function :P pretty easy isn't it ?Lbl TEST
GRestoreHL
GRotate()
Lbl TESTSUB
GProject()
!If T
signed{Z^256+°GCos}//32+GScreenY+2->GScreenY
End
Return
0->T
!f A-GCPosX .GCPosX is the X coordinate of the camera
!f B-GCPosY
+1->T .hl abuse...
End
End
GCPosX->A
GCPosY->B
If T
96->Z
Else
Z+8->Z .increase the angle, so we can have the mouvement
End
0->A->B->T
prgmGPOLYGON
GDrawArray(adr_array,nb_of_poly)
.destroy r1 to r6
GPrimitive(start_adr)
.destroy r1 to r6
GSetColor(flag)
.destroy r1
Data(Type_polygon,Color
Data(idVertex1,idVertex2,...
.all of this is one byte value
Data(type,color)
Data(centerVertexId,radius
GSetColor(°GBLACK)
°GTRI->Gpolygon
GPrimitive(Data(0,1,2))
.TEST
prgmGCORE
prgmGPOLYGON
Data(40r,-40r,40r)→GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r
Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1
Buff(8*6)→GDB2
GNewCam(°GMODELVIEW)
GDB1→GVAdr
GDB2→GVStr
While 1
GDB1→r5
GDB2→r6
For(8)
GVertex({r5}r,{r5+2}r,{r5+4}r
copy(°GVertex,r6,6
r6+6→r6
r5+6→r5
End
For(M,0,11) .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End
°GQUAD->GPolygon
GPrimitive(Data(0,1,3,2))
.warning ! vertex must be clockwise or anticlockwise!
GGetkey(°GMODEL)
DispgraphClrdraw
EndIf getkey(15)
GSetCurVBO(L3)
.destroy r1
.1 bytes -- reserved field for GLib's, used for delete VBO (you don't really need this)
.2 bytes --number of vertices the VBO should handle at max
.2 bytes --raw vertices adress
.5*number of vertices bytes --the vertex on screen position, with their respective cliping code
.6*number of vertices bytes --the rotated vertices coordinates.
.2 bytes X coordinate
.2 bytes Y coordinate
.1 byte clipping code
GInFrustrum()/256
.destroy nothing
and return vertex status in hl :Ui, a tutorial for this, that helps understand how it works a lot :)/me hops people will start using it now
This is a good and easy to follow tutorial, and I was amazed at the speed of this thing: 55fps on 6MHz and 75fps on 15MHz!If you read closer, this is an HL abuse, no mistake here. ;) Just that it's a bit less clear for a tutorial.
/me is deffinately going to use this in some programs.
I did notice a small mistake in the full code, though: you did
rect(,{°GVertex+2}r,2,2
instead of
Rect({°GVertex}r,{°GVertex+2}r,2,2
It is correct in the tutorial itself, but I thougth it would be best to report this.
This is a good and easy to follow tutorial, and I was amazed at the speed of this thing: 55fps on 6MHz and 75fps on 15MHz!
/me is deffinately going to use this in some programs.
I did notice a small mistake in the full code, though: you did
rect(,{°GVertex+2}r,2,2
instead of
Rect({°GVertex}r,{°GVertex+2}r,2,2
It is correct in the tutorial itself, but I thougth it would be best to report this.
If i can critique one thing :pno you can't
I like this tutorial but i thinks that the name of your routine is a lot of big example : GNewCam(pointer to camera) can be Camera(pointer to camera) this is more clear when we read the code :)
This is a good and easy to follow tutorial, and I was amazed at the speed of this thing: 55fps on 6MHz and 75fps on 15MHz!
It would definitively be nice if you could expand the tutorial further so that it also teaches how to make programs where the dots are connected with lines or maybe even textures. :)
prgmGCORE
Data(40r,-40r,40r)->GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r
GNewCam(pointer to camera)
.Destroys r1
GNewCam(°GMODELVIEW)
Glib also need a special structure, allowing easy vertex processing/clipping. It's called a VBO : vertex buffer object. Basically, it's just a ram area.GGenVBO(size,data_to_match)
.destroy r1,r2
your size is the number of vertices you want to have.GGenVBO(8,GDB1)->G
.I used G, but you can used any way to save this value
While 1
GUpdateVBO(G,0,7)
GVBOPoint(id_vertex)
.destroy r1
function to retrieve a point from VBO. It's store the x-coord and y-coord on screen to GScreenX and GSreenY var (alias OP1 and OP1+2)For(M,0,7)
GVBOPoint(M)
!If
Rect(GScreenX,GScreenY,2,2
End
End
GGetkey()
GGetkey()
DispgraphClrdraw // we want to have something on screen !
EndIf getkey(15) // stop the While loop if [clear] is pressed
Where are those "extra functions' you talk about ? :P
EDIT : also, it would be worth noting that r4 to r6 can't be used in a vertex shader due to GUpdateVBO using them in the For loop. Took me some time to understand why my program wasn't working.