// Author: Drunkie
// Description: 3D Cube

Main();

#include <drivers\drv_gl.txt>

void Main()
{
    glClear( 0, 0, 0 ); // Clear screen

    glCoordPipe( GL_CPIPE_N1_1 ); // Set coordinate pipe to [-1 to 1] mode
    glVertexPipe( GL_VPIPE_XYZTRANSFORM ); // Set vertex pipe to xyz transformation

    glLightPos( 0, 0, -20 ); // Set the light position
    glLightColor( 255, 255, 255, 1 ); // Set the light color

    glLookAt(
        0, 0, -5, // Camera pos
        0, 0, 0, // Camera target
        0, 1, 0 // Camera up
    );

    // Create variable to hold curtime
    float time;
    timer time;

    // Create perspective and matrix transformations
    glPerspective( 30, 1, 1, 20 ); // FOV, ASPECT RATIO, ZNEAR, ZFAR
    glRotate( 1, 1, 0, time ); // AXIS X, Y, Z, ANGLE W
    glTranslate( 0, 0, 0 ); // TRANSLATION X, Y, Z
    glScale( 1, 1, 1 ); // SCALE X, Y, Z

    glEnable( GL_VERTEX_BUFFER ); // Enable vertex buffer
    glEnable( GL_VERTEX_ZSORT ); // Enable Z sorting

    // Solid 3D polygon
    glFillMode( GL_FILL_SOLID ); // Set fillmode as solid
    glColor4( 100, 149, 237, 180 ); // Set draw color with alpha
    glPoly3D( vertexBuffer, 12 ); // Draw 3D polygon
    glFlush(); // Flush the vertex buffer to the screen

    // Wireframe 3D polygon
    glLineWidth( 1 ); // Set line width
    glFillMode( GL_FILL_WIREFRAME ); // Set fillmode as solid
    glColor4( 255, 255, 255, 255 ); // Set draw color with alpha
    glPoly3D( vertexBuffer, 12 ); // Draw 3D polygon
    glFlush(); // Flush the vertex buffer to the screen

    glExit(); // Exit
}

// The vertex data for our model
vertexBuffer:
db -1,-1,-1; db 1,-1,-1; db 1,1,-1;
db -1,-1,-1; db 1,1,-1; db -1,1,-1;
db 1,-1,1; db -1,-1,1; db 1,1,1;
db -1,-1,1; db -1,1,1; db 1,1,1;
db 1,-1,-1; db -1,-1,-1; db 1,-1,1;
db -1,-1,-1; db -1,-1,1; db 1,-1,1;
db -1,1,-1; db 1,1,-1; db 1,1,1;
db -1,1,1; db -1,1,-1; db 1,1,1;
db -1,-1,-1; db -1,1,-1; db -1,1,1;
db -1,-1,1; db -1,-1,-1; db -1,1,1;
db 1,1,-1; db 1,-1,-1; db 1,1,1;
db 1,-1,-1; db 1,-1,1; db 1,1,1;
