Post by GuppyB on Jul 8, 2004 22:19:24 GMT -5
After the Cylinder demo, I proceeded on to the Sphere Demo and what better way to do a sphere than to texture map with the world.
In order for this to work with the texture map you will need to download the "Earth Textures Natural Colors" image from here:
www.oera.net/How2/TextureMaps.htm
You will then need to resize it in a photo program like Photoshop to 1024x512, and save in the Textures folder of Basic4gl with the name "EarthMap_1024x512.jpg"
I know it's a lot to go through be the result is great
And it works for other textures from that page like Mars and the Moon just as well.
Enjoy ... G
Code is here:
In order for this to work with the texture map you will need to download the "Earth Textures Natural Colors" image from here:
www.oera.net/How2/TextureMaps.htm
You will then need to resize it in a photo program like Photoshop to 1024x512, and save in the Textures folder of Basic4gl with the name "EarthMap_1024x512.jpg"
I know it's a lot to go through be the result is great
And it works for other textures from that page like Mars and the Moon just as well.
Enjoy ... G
Code is here:
dim xrot#, yrot#, zrot#
dim spherecircum
dim i , j
dim OldTick, CurrentTick , TimeTick, Frames , FramesSecond#
dim texture
dim one36th# , one18th#
texture = LoadMipmapTexture ("Textures/EarthMap_1024x512.jpg")
if texture = 0 then print "Failed to load texture": end: endif
one36th# = 1.0 / 36
one18th# = 1.0 / 18
glEnable (GL_TEXTURE_2D)
glEnable (GL_CULL_FACE)
TextMode (TEXT_OVERLAID)
OldTick = TickCount ()
while true
gosub FPSroutine
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(0.0,0.0,-5.0)
glRotatef(xrot#,1.0,0.0,0.0)
glRotatef(yrot#,0.0,1.0,0.0)
glRotatef(zrot#,0.0,0.0,1.0)
spherecircum = 2
gosub drawsphere
DrawText ()
SwapBuffers ()
xrot# = xrot# + 0.1
yrot# = yrot# + 0.2
zrot# = zrot# + 0.15
wend
'********************sphere routine****************************
drawsphere:
glBindTexture(GL_TEXTURE_2D, texture)
for j = 0 to 17
glbegin (GL_Quad_strip)
For i = 0 to 36
glTexCoord2f ( ((36 - i) * one36th#),(j * one18th#))
glVertex3f (spherecircum * sind (j*10) * cosd(i*10), spherecircum * sind (j*10) * sind (i*10), spherecircum * cosd (j*10)) ' draw top vertex
glTexCoord2f ( ((36 - i) * one36th#) ,((j + 1.0) * one18th#))
glVertex3f (spherecircum * sind ((j*10)+10) * cosd(i*10), spherecircum * sind ((j*10)+10) * sind (i*10), spherecircum * cosd ((j*10)+10)) 'draw bottom vertex
next
glend ()
next
return
'*******************FPS routine****************************
FPSroutine:
CurrentTick = TickCount()
TimeTick = CurrentTick - OldTick
if TimeTick >= 1000 then FramesSecond# = Frames * (TimeTick/1000) : Locate 0,0: Print FramesSecond#: Frames = 0: OldTick = CurrentTick: endif
Frames = Frames + 1
Return