CASE %BBP_RENDER
'
// Draw the scene using BBP.LeftPeak and BBP.RightPeak
LOCAL nLValue, nRValue, RGBColor AS LONG
LOCAL pulse AS DOUBLE, R1, G1, B1, R2, G2, B2 AS BYTE
nLValue = (BBP.Lpeak / 700)
nRValue = (BBP.Rpeak / 768)
rXangle = rXangle + 0.3 '
// grDXangle
rYangle = rYangle + 0.5 '
// grDYangle
rZangle = rZangle + 0.7 '
// grDZangle
pulse = Max(nLValue, nRValue) / 7
'
// Pulsating section
CALL glMatrixMode(%GL_PROJECTION)
Call glLoadIdentity
Call gluPerspective(35# - pulse, 1.25, 0.1, 150#)
CALL glMatrixMode(%GL_MODELVIEW)
'
// Velocity section
pulse = Abs(pulse / 4)
rXangle = rXangle + pulse '
// grDXangle
rYangle = rYangle + pulse '
// grDYangle
rZangle = rZangle + pulse '
// grDZangle
'
// Very important we must reassign BBP.RC to the new BBP.DC
'
// Note: don't use permanent
DC, this produce better
and smoother display
Call wglMakeCurrent(BBP.DC, BBP.rc)
CALL glClear(%GL_COLOR_BUFFER_BIT
OR %GL_DEPTH_BUFFER_BIT)
Call glLoadIdentity
Call gluLookAt(0#, 0#, 5#, 0#, 0#, 0#, 0#, 1#, 0#)
Call glRotated(rXangle, 1#, 0#, 0#)
Call glRotated(rYangle, 0#, 1#, 0#)
Call glRotated(rZangle, 0#, 0#, 1#)
'
// Draw Diamond
RGBColor = LevelColr(nLValue)
R2 = BBP_GetRValue(RGBColor)
G2 = BBP_GetGValue(RGBColor)
B2 = BBP_GetBValue(RGBColor)
RGBColor = LevelColr(nRValue)
R1 = BBP_GetRValue(RGBColor)
G1 = BBP_GetGValue(RGBColor)
B1 = BBP_GetBValue(RGBColor)
'
// Up
CALL glBegin(%GL_TRIANGLE_FAN)
Call glColor3ub(R2, G2, B2): Call glVertex3d(0#, 1.414, 0#)
Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#)
Call glColor3ub(0, 0, 0): Call glVertex3d(1#, 0#, -1#)
Call glColor3ub(R1, G1, B1): Call glVertex3d(-1#, 0#, -1#)
Call glColor3ub(0, 0, 0): Call glVertex3d(-1#, 0#, 1#)
Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#)
Call glEnd
'
// Down
CALL glBegin( %GL_TRIANGLE_FAN)
Call glColor3ub(R2, G2, B2): Call glVertex3d(0#, -1.414, 0#)
Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#)
Call glColor3ub(64, 64, 64): Call glVertex3d(-1#, 0#, 1#)
Call glColor3ub(R1, G1, B1): Call glVertex3d(-1#, 0#, -1#)
Call glColor3ub(64, 64, 64): Call glVertex3d(1#, 0#, -1#)
Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#)
Call glEnd