#include once "FBTinyGL.bi" ' test of glDrawArrays dim as integer scr_w = 640 dim as integer scr_h = 480 dim as integer scr_b = 16 screenres scr_w,scr_h,scr_b ' if we are in palette mode 224 is white if scr_b<15 then color 224 var ctx = CreateRenderContext() ' minimal OpenGL init glViewport(0,0, scr_w, scr_h) glMatrixMode(GL_PROJECTION) gluPerspective(45.0, scr_w/scr_h, 0.1, 100.0) glMatrixMode(GL_MODELVIEW) glClearColor(0,.5,.5) glEnable(GL_CULL_FACE) glEnable(GL_DEPTH_TEST) ' cube ' v6----- v5 ' /| /| ' v1------v0| ' | | | | ' | |v7---|-|v4 ' |/ |/ ' v2------v3 dim as single vertices(...) => { _ 1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1, _ ' front 1, 1, 1, 1,-1, 1, 1,-1,-1, 1, 1,-1, _ ' right 1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1, _ ' top -1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1, _ ' left -1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1, _ ' bottom 1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1} ' back ' color array dim as single colors(...) => { _ 1,1,1, .75,.75,.75, .5,.5,.5, .75,.75,.75, _ 1,1,0, .75,.75,0 , .5,.5, 0, .75,.75, 0, _ 1,0,0, .75,0 ,0 , .5, 0, 0, .75, 0, 0, _ 0,1,0, 0 ,.75,0 , 0 ,.5, 0, 0,.75, 0, _ 0,0,1, 0 ,0 ,.75, 0 ,0 ,.5, 0, 0,.75, _ 0,1,1, 0 ,.75,.75, 0 ,.5,.5, 0,.75,.75} dim as single normals(...) => { _ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, _ 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, _ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, _ -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, _ 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, _ 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1} glVertexPointer (3, GL_FLOAT, 0, @vertices(0)) glColorPointer (3, GL_FLOAT, 0, @colors(0) ) glNormalPointer ( GL_FLOAT, 0, @normals(0) ) glEnableClientState(GL_VERTEX_ARRAY) glEnableClientState(GL_COLOR_ARRAY) glEnableClientState(GL_NORMAL_ARRAY) dim as single rot dim as integer frames,fps=60 dim as double tLast=Timer() glTranslatef(0,0,-10) while inkey()="" glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glPushMatrix() glRotatef(rot,1,1,1) glDrawArrays(GL_QUADS,0,24) glPopMatrix() screenlock SwapBuffers(ctx) draw string (0,0),"fps: " & fps screenunlock if frames mod 10=0 then dim as double tNow=timer() fps = 10/(tNow-tLast) tLast=tNow end if frames+=1 rot+=60*iif(fps>0,1/fps,0) 'sleep 10 wend DestroyRenderContext(ctx)