'Written in FreeBasic.023 for windows
'
'to get latest version:
'http://www.freebasic.net/forum/viewtopic.php?t=18320
'
'For a real easy to use Integrated Development Enviroment. FBIDE
'http://fbide.freebasic.net/index.php?menuID=56
'
'=================================
'Begin code
'=================================
#include once "GL/gl.bi"
#include once "GL/glu.bi"
'console printed instructioins.
screen 0
cls
print "Press Esc to EXIT"
print "-----------------------------------------"
print
print "Press Space-bar to stop all motion "
print
print "-----------------------------------------"
print "Left , Right Arrows to rotate on X - Axis"
print
print " Up , Down Arrows to rotate on Y - Axis"
print
print " R_Shft to reset U/D , L/R rotate values "
print "-----------------------------------------"
print
print " (+) , (-) , (Enter) to control spin "
print
print " (Q) , (W) , (E) to control zoom level "
print
print " (A) , (S) , (D) to control U/D shift "
print
print " (Z) , (X) , (C) to control L/R shift "
print
print " (R) , (T) to control RED LEVEL "
print " (F) , (G) to control GREEN LEVEL "
print " (V) , (B) to control BLUE LEVEL "
print "-----------------------------------------";
'for general trig looping and values
'======================================
dim as double r1 = atn(1)/90
dim as double d1
dim as double deg1_start = 0
dim as double deg1_end = 360
dim as double deg1_inc = 1
'======================================
dim as double r2 = atn(1)/45
dim as double d2
dim as double deg2_start = 0
dim as double deg2_end = 360
dim as double deg2_inc = .5
'======================================
dim as double c1
dim as double c2
dim as double s1
dim as double s2
dim as double out_x
dim as double out_y
dim as double out_z
dim as integer xres,yres
windowtitle "Abstract-147"
screen 19
screeninfo xres,yres
Screenres xres,yres,32,1,2
' create and compile a OpenGL list
dim as integer glList = glGenLists(1)
glNewList(glList, GL_COMPILE)
glBegin GL_POINTS
For d1 = deg1_start To deg1_end Step deg1_inc
c1=cos(d1*r1)
s1=sin(d1*r1)
For d2 = deg2_start To deg2_end Step deg2_inc
c2=cos(d2*r2)
s2=sin(d2*r2)
dim as single x : x =(c1*cos(cos(d2*r2)*s2/c1))*2
dim as single y : y =(s1*sin(sin(d2*r2)*c2/s1))*2
dim as single z : z = c2+s2
glvertex3f x , y , z
Next d2
Next d1
glEnd
glEndList()
'===============================================================================
'===============================================================================
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 18 , xres/yres , .1, 500
glMatrixMode GL_MODELVIEW
glLoadIdentity
glBlendfunc GL_SRC_ALPHA, GL_ONE
glPointsize 1
glEnable gl_blend
'for OpenGl transition,rotation
dim as single xt, yt, zt=-15 'transition variables
dim as single xr, yr, zr 'rotation variables
dim as single xrs=.5,yrs=.5,zrs=.5' transitions of camera
dim as ubyte red= 150, green=75, blue=25
dim as ubyte status=1
DO WHILE status=1
glclear GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT
glloadidentity
gltranslatef xt, yt, zt
glrotatef xr, 1, 0, 0
glrotatef yr, 0, 1, 0
glrotatef zr, 0, 0, 1
' draw the list
glColor3ub red,green,blue
glCallList glList
'screensync
glFlush
flip
'check for keys being pressed
if multikey(&h01) then status = 0 ' esc key to quit
xrs = xrs + (multikey(&h50)/10) - (multikey(&h48)/10) 'left & right arrows
yrs = yrs + (multikey(&h4D)/10) - (multikey(&h4B)/10) 'up & down arrows
zrs = zrs + (multikey(&h0C)/10) - (multikey(&h4E)/10) 'plus & minus on the keypad
xr = xr - xrs
yr = yr - yrs
zr = zr - zrs
zt = zt + ((multikey(&h10)/2) - (multikey(&h11)/2)) ' q , w zoom in out
yt = yt + ((multikey(&h1E)/2) - (multikey(&h1F)/2)) ' a , s shift left,right
xt = xt + ((multikey(&h2C)/2) - (multikey(&h2D)/2)) ' z , x shift up,down
red = red +((multikey(&h13)) - (multikey(&h14))) ' r , t adjust red level
green = green +((multikey(&h21)) - (multikey(&h22))) ' f , g adjust green level
blue = blue +((multikey(&h2f)) - (multikey(&h30))) ' v , b adjust blue level
if multikey(&h39) then xrs=0 : yrs=0 : zrs=0 ' SPACE-BAR = stop all transitions
if multikey(&h1C) then xr=0 : yr=0 : zr=0 ' "Enter Key" reset spin to zero
if multikey(&h36) then 'right_shift key, to reset GL_X,GL_Y rotation values
xrs=0:yrs=0
xr =0:yr =0
end if
if multikey(&h12) then zt=-15 ' "E key" reset zoom level
if multikey(&h20) then yt= 0 ' "D key" reset UP/DOWN position to center
if multikey(&h2E) then xt =0 ' "C key" reset Left/Right position to center
Loop
END