//timer EAX;// div EAX,8;
//fsin EAX,EAX;
//mul EAX,512;
//fabs EAX,EAX;
//neg EAX;
//add EAX,512;

dcvxpipe 3; //-1..1 (opengl screen)
dvxpipe  5; //matrix projection

//Initialize transform
mperspective mProjectionMatrix,vPerspective;

//Render starts
dclrscr  bg_color;
mlookat mViewMatrix,vLookAt; //View matrix

timer eax;
mov #vRotate.w,eax;

//Rotate translate
mrotate mRotateMatrix,vRotate;
mtranslate mTranslateMatrix,vTranslate;

//Create model matrix
mmov mModelMatrix,mTranslateMatrix;
mmul mModelMatrix,mRotateMatrix;

//modelViewMatrix = ViewMatrix * modelMatrx
mmov mModelViewMatrix,mViewMatrix;
mmul mModelViewMatrix,mModelMatrix;

//load matrix
mload mModelViewMatrix;
mloadproj mProjectionMatrix;

//setup light
dsetlight 0,lightdata;

//setup buffer
denable 0; //Vertex buffer
denable 1; //ZSorting
denable 2; //Lighting
denable 3; //Face culling

//render cube
dcolor fg_color;
dvxdata_3f cube2,12;
dvxflush;

ddisable 0; //Disable everything!
ddisable 1;
ddisable 2;
ddisable 3;

dcvxpipe 0;
dvxpipe  0;

//You can write some text here now
//<right here>
dexit;

//========
cube2:
db -1,-1,-1;
db 1,-1,-1;
db 1,1,-1;
cube3:
db -1,-1,-1;
db 1,1,-1;
db -1,1,-1;
cube4:
db 1,-1,1;
db -1,-1,1;
db 1,1,1;
cube5:
db -1,-1,1;
db -1,1,1;
db 1,1,1;
cube6:
db 1,-1,-1;
db -1,-1,-1;
db 1,-1,1;
cube7:
db -1,-1,-1;
db -1,-1,1;
db 1,-1,1;
cube8:
db -1,1,-1;
db 1,1,-1;
db 1,1,1;
cube9:
db -1,1,1;
db -1,1,-1;
db 1,1,1;
cube10:
db -1,-1,-1;
db -1,1,-1;
db -1,1,1;
cube11:
db -1,-1,1;
db -1,-1,-1;
db -1,1,1;
cube12:
db 1,1,-1;
db 1,-1,-1;
db 1,1,1;
cube13:
db 1,-1,-1;
db 1,-1,1;
db 1,1,1;

lightdata:
vector4f lightpos,  0,50,-50,  0; //x y z <unused, will be falloff>
color    lightcol,255,255,255,  1; //R G B Brightness
//========

matrix mRotateMatrix;
matrix mTranslateMatrix;

matrix mProjectionMatrix;	//This defines our projection to screen
matrix mViewMatrix;		//This defines our camera transformations

matrix mModelMatrix;		//This is our model transformations
matrix mModelViewMatrix;	//This is our model relatively to camera transform


vector4f vRotate,      1,  1,  1,  0; //<AXIS X Y Z> <ANGLE W>
vector4f vTranslate,   0,  0,  0,  0; //<TRANLSATION X Y Z> <0>
vector4f vPerspective, 30, 1.6,  1,  20; //<FOV> <ASPECT RATIO> <ZNEAR> <ZFAR>

vLookAt:
vector3f vLookAt_Eye,    0, 0, -5; //Where our camera is
vector3f vLookAt_Center, 0, 0, 0;  //What we look at
vector3f vLookAt_Up,     0, 1, 0;  //Where our matt-hat is

color fg_color,255,255,25;
color bg_color,64,32,12;
