'OpenGL Lights & Material By Ashish
_TITLE "OpenGL Lights & Material"
'Used by GLH RGB/etc helper functions
'Used to manage textures
TYPE DONT_USE_GLH_Handle_TYPE
'Used by GLH RGB/etc helper functions
REDIM SHARED DONT_USE_GLH_Handle
(1000) AS DONT_USE_GLH_Handle_TYPE
glAllow = -1
_glEnable _GL_LIGHT0
'we need three lights, each for red, green & blue.
_glLightfv _GL_LIGHT0
, _GL_AMBIENT
, GLH_RGB
(0, 0, 0) _glLightfv _GL_LIGHT0
, _GL_DIFFUSE
, GLH_RGB
(.5, 0, 0) _glLightfv _GL_LIGHT0
, _GL_SPECULAR
, GLH_RGB
(1, 0, 0) _glLightfv _GL_LIGHT0
, _GL_POSITION
, GLH_RGBA
(redLight.x
, redLight.y
, redLight.z
, 0)
_glLightfv _GL_LIGHT1
, _GL_AMBIENT
, GLH_RGB
(0, 0, 0) _glLightfv _GL_LIGHT1
, _GL_DIFFUSE
, GLH_RGB
(0, .5, 0) _glLightfv _GL_LIGHT1
, _GL_SPECULAR
, GLH_RGB
(0, 1, 0) _glLightfv _GL_LIGHT1
, _GL_POSITION
, GLH_RGBA
(greenLight.x
, greenLight.y
, greenLight.z
, 0)
_glLightfv _GL_LIGHT2
, _GL_AMBIENT
, GLH_RGB
(0, 0, 0) _glLightfv _GL_LIGHT2
, _GL_DIFFUSE
, GLH_RGB
(0, 0, .5) _glLightfv _GL_LIGHT2
, _GL_SPECULAR
, GLH_RGB
(0, 0, 1) _glLightfv _GL_LIGHT2
, _GL_POSITION
, GLH_RGBA
(blueLight.x
, blueLight.y
, blueLight.z
, 0)
glSetup = -1
gluLookAt 0, 0, 5, 0, 0, 0, 0, 1, 0
_glMaterialfv _GL_FRONT_AND_BACK
, _GL_DIFFUSE
, GLH_RGB
(0.8, 0.8, 0.8) _glMaterialfv _GL_FRONT_AND_BACK
, _GL_SPECULAR
, GLH_RGB
(.86, .86, .86) _glMaterialfv _GL_FRONT_AND_BACK
, _GL_SHININESS
, GLH_RGB
(128 * .566, 0, 0)
glutSolidSphere 1, 100, 100
glutSolidSphere .05, 20, 20
glutSolidSphere .05, 20, 20
glutSolidSphere .05, 20, 20
clock# = clock# + .01
redLight.x
= SIN(clock#
* 1.5) * 1.5 redLight.z
= COS(clock#
* 1.5) * 1.5
greenLight.y
= COS(clock#
* .8) * 1.5 greenLight.z
= SIN(clock#
* .8) * 1.5
blueLight.x
= SIN(clock#
) * 1.5 blueLight.y
= COS(clock#
) * 1.5
FUNCTION map!
(value!
, minRange!
, maxRange!
, newMinRange!
, newMaxRange!
) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
'below, all functions are coded by Galleon
FUNCTION GLH_Image_to_Texture
(image_handle
AS LONG) 'turn an image handle into a texture handle h = DONT_USE_GLH_New_Texture_Handle
GLH_Image_to_Texture = h
FUNCTION DONT_USE_GLH_New_Texture_Handle
handle&& = 0
DONT_USE_GLH_New_Texture_Handle = handle&&
IF DONT_USE_GLH_Handle
(h
).in_use
= 0 THEN DONT_USE_GLH_Handle(h).in_use = 1
DONT_USE_GLH_Handle(h).handle = handle&&
DONT_USE_GLH_New_Texture_Handle = h
DONT_USE_GLH_Handle(h).in_use = 1
DONT_USE_GLH_Handle(h).handle = handle&&
DONT_USE_GLH_New_Texture_Handle = h
SUB GLH_Select_Texture
(texture_handle
AS LONG) 'turn an image handle into a texture handle _glBindTexture _GL_TEXTURE_2D
, DONT_USE_GLH_Handle
(texture_handle
).handle
DONT_USE_GLH_COL_RGBA(1) = r
DONT_USE_GLH_COL_RGBA(2) = g
DONT_USE_GLH_COL_RGBA(3) = b
DONT_USE_GLH_COL_RGBA(4) = 1
GLH_RGB
= _OFFSET(DONT_USE_GLH_COL_RGBA
())
DONT_USE_GLH_COL_RGBA(1) = r
DONT_USE_GLH_COL_RGBA(2) = g
DONT_USE_GLH_COL_RGBA(3) = b
DONT_USE_GLH_COL_RGBA(4) = a
GLH_RGBA
= _OFFSET(DONT_USE_GLH_COL_RGBA
())