Hello there,
here's a small experimental openGl for your own trying.
lesson1
include "gl.inc"
window 640,480,1
tex = LoadImage "gfx/pumpa.bmp"
while KeyDown(27)=0
cls 0,0,1
glLoadIdentity
glTranslatef 0.0,0.0,-5.0
glEnable GL_TEXTURE_2D
glBindTexture GL_TEXTURE_2D,TEX
glBegin GL_QUADS
gltexcoord2f 0.0,1.0 : glvertex2f -1.0, 1.0
gltexcoord2f 1.0,1.0 : glvertex2f 1.0, 1.0
gltexcoord2f 1.0,0.0 : glvertex2f 1.0,-1.0
gltexcoord2f 0.0,0.0 : glvertex2f -1.0,-1.0
glEnd
SwapBuffer
wend
WinEnd
lesson2
include "gl.inc"
window 640,480,1
float angle
while KeyDown(27)=0
cls 0,0,0
glLoadIdentity
glTranslatef 0.0, 0.0,-4.0
glRotatef angle, 0.0,1.0,0.0
glBegin GL_TRIANGLE_FAN
glcolor3ub (0, 128, 255): glvertex3f ( 0.0, 1.0, 0.0)
glcolor3ub (255, 0, 0) : glvertex3f (-1.0,-1.0, 1.0)
glcolor3ub (255,255,255): glvertex3f ( 1.0,-1.0, 1.0)
glcolor3ub (0, 0, 255) : glvertex3f ( 1.0,-1.0,-1.0)
glcolor3ub (0, 255, 0) : glvertex3f (-1.0,-1.0,-1.0)
glcolor3ub (255, 0, 0) : glvertex3f (-1.0,-1.0, 1.0)
glEnd
angle +=1
swapbuffer
wend
winEnd
lesson3
include "gl.inc"
window 640,480,1
SetFrames 80
float ro,rq
while KeyDown(27)=0
glClear(GL_COLOR_BUFFER_BIT)
glClear(GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(-1.5,0.0,-6.0)
glRotatef(ro,0.0,1.0,0.0)
glBegin(GL_TRIANGLES)
glcolor3f 1.0, 0.0, 0.0
glVertex3f 0.0, 1.0, 0.0
glcolor3f 0.0, 1.0, 0.0
glVertex3f -1.0,-1.0, 0.0
glcolor3f 0.0, 0.0, 1.0
glVertex3f 1.0,-1.0, 0.0
glEnd
glLoadIdentity()
glTranslatef(1.5,0.0,-6.0)
glRotatef(rq,1.0,0.0,0.0)
glcolor3f(0.5,0.5,1.0)
glBegin(GL_QUADS)
glVertex3f(-1.0, 1.0,0.0)
glVertex3f( 1.0, 1.0,0.0)
glVertex3f( 1.0,-1.0,0.0)
glVertex3f(-1.0,-1.0,0.0)
glEnd
ro +=1
rq -=1
SwapBuffer
wend
WinEnd
lesson4
include "gl.inc"
Window 640,480,1
SetFrames (60)
Loadfont "glfonts/font16.bmp"
float ro
while KeyDown(27)=0
cls 0,0,1.0
glLoadIdentity
glTranslatef 0.0, 0.0, -5.0
glRotatef ro,1.0, 0.0, 1.0
glBegin GL_TRIANGLES
glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0, 1.0,-1.0
glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.87,-0.5,-1.0
glColor3f 0.0, 0.0, 1.0 : glVertex3f-0.87,-0.5,-1.0
glEnd
ro +=1
if ro >359 then ro=0
glColor3ub 255,255,255
Text 1,-0.38,0.35, "STAR FIGHTER", 0.064,0.064
SwapBuffer
wend
WinEnd
lesson5
include "gl.inc"
window 640,480,1
SetFrames 100
f = LoadFont "glfonts/font16.bmp"
t = LoadImage "gfx/emboss.bmp"
single r4x,r4y,r4z
single Mt_Diffuse [3] = {0.8, 0.8, 0.8, 1.0}
single Mt_Ambient [3] = {0.3, 0.3, 0.3, 1.0}
single Mt_Specular[3] = {1.0, 1.0, 1.0, 1.0}
single Mt_Shiness [0] = {50.0}
single Lt_Position[3] = {0.0, 0.0, 10.0, 1.0}
single Lt_Diffuse [3] = {0.5, 0.5, 0.5, 0.5 }
single Lt_Ambient [3] = {0.2, 0.2, 0.2, 1.0 }
single Lt_Specular[3] = {1.0, 1.0, 1.0, 1.0 }
glMaterialfv GL_FRONT, GL_SPECULAR, &Mt_Specular
glMaterialfv GL_FRONT, GL_SHININESS,&Mt_Shiness
glMaterialfv GL_FRONT, GL_DIFFUSE, &Mt_Diffuse
glMaterialfv GL_FRONT, GL_AMBIENT, &Mt_Ambient
glLightfv GL_LIGHT1,GL_DIFFUSE, &Lt_Diffuse
glLightfv GL_LIGHT1,GL_AMBIENT, &Lt_Ambient
glLightfv GL_LIGHT1,GL_SPECULAR, &Lt_Specular
glLightfv GL_LIGHT1,GL_POSITION, &Lt_Position
while KeyDown(VK_ESCAPE)=0
Cls 0.3,0.3,0.3
glLoadIdentity
glTranslatef 0.0,0.0,-6.0
glRotatef r4x,1.0,0.0,0.0
glRotatef r4y,0.0,1.0,0.0
glRotatef r4z,0.0,0.0,1.0
glEnable GL_LIGHT1
glEnable GL_LIGHTING
glEnable GL_TEXTURE_2D
glBindTexture GL_TEXTURE_2D,t
glBegin GL_QUADS
glColor3f 1.0, 1.0, 0.0
glNormal3f 0.0, 1.0, 0.0
glTexCoord2f 1.0, 1.0 : glVertex3f 1.0, 1.0,-1.0
glTexCoord2f 0.0, 1.0 : glVertex3f -1.0, 1.0,-1.0
glTexCoord2f 0.0, 0.0 : glVertex3f -1.0, 1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f 1.0, 1.0, 1.0
glColor3f 1.0, 0.0, 1.0
glNormal3f 0.0,-1.0, 0.0
glTexCoord2f 1.0, 1.0 : glVertex3f 1.0, -1.0, 1.0
glTexCoord2f 0.0, 1.0 : glVertex3f -1.0, -1.0, 1.0
glTexCoord2f 0.0, 0.0 : glVertex3f -1.0, -1.0,-1.0
glTexCoord2f 1.0, 0.0 : glVertex3f 1.0, -1.0,-1.0
glColor3f 0.0, 0.0, 1.0
glNormal3f 0.0, 0.0, 1.0
glTexCoord2f 1.0, 1.0 : glVertex3f 1.0, 1.0, 1.0
glTexCoord2f 0.0, 1.0 : glVertex3f -1.0, 1.0, 1.0
glTexCoord2f 0.0, 0.0 : glVertex3f -1.0,-1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f 1.0,-1.0, 1.0
glColor3f 0.0, 1.0, 1.0
glNormal3f 0.0, 0.0,-1.0
glTexCoord2f 0.0, 0.0 : glVertex3f 1.0,-1.0,-1.0
glTexCoord2f 1.0, 0.0 : glVertex3f -1.0,-1.0,-1.0
glTexCoord2f 1.0, 1.0 : glVertex3f -1.0, 1.0,-1.0
glTexCoord2f 0.0, 1.0 : glVertex3f 1.0, 1.0,-1.0
glColor3f 0.0, 1.0, 0.0
glNormal3f -1.0, 0.0, 0.0
glTexCoord2f 1.0, 1.0 : glVertex3f -1.0, 1.0, 1.0
glTexCoord2f 0.0, 1.0 : glVertex3f -1.0, 1.0,-1.0
glTexCoord2f 0.0, 0.0 : glVertex3f -1.0,-1.0,-1.0
glTexCoord2f 1.0, 0.0 : glVertex3f -1.0,-1.0, 1.0
glColor3f 1.0, 0.0, 0.0
glNormal3f 1.0, 0.0, 0.0
glTexCoord2f 1.0, 1.0 : glVertex3f 1.0, 1.0,-1.0
glTexCoord2f 0.0, 1.0 : glVertex3f 1.0, 1.0, 1.0
glTexCoord2f 0.0, 0.0 : glVertex3f 1.0,-1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f 1.0,-1.0,-1.0
glEnd
glDisable GL_LIGHTING
Text f,-0.28,0.37, "LIGHT QUAD", 0.048,0.048
r4x +=0.5
r4y +=0.4
r4z +=0.3
SwapBuffer
wend
WinEnd
lesson6
include "gl.inc"
window 640,480,1
glMatrixMode(GL_PROJECTION)
glLoadidentity
glortho (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0)
glDisable(GL_DEPTH_TEST)
glDrawBuffer(GL_FRONT_AND_BACK)
glMatrixMode(GL_MODELVIEW)
float xRot,yRot,zRot
int list = glGenLists(1)
glLineWidth 2.0
glEnable GL_LINE_SMOOTH
glNewList list,GL_COMPILE
glBegin(GL_LINE_LOOP)
glVertex3f(0.0, 0.5, 0.0)
glVertex3f(0.1, 0.1, 0.0)
glVertex3f(0.5, 0.05,0.0)
glVertex3f(0.1, 0.0, 0.0)
glVertex3f(0.25,-0.5,0.0)
glVertex3f(0.0,-0.05,0.0)
glVertex3f(-0.25,-0.5,0.0)
glVertex3f(-0.1, 0.0, 0.0)
glVertex3f(-0.5, 0.05,0.0)
glVertex3f(-0.1, 0.1, 0.0)
glEnd
glEndList
while KeyDown(27)=0
glClearColor(0.0, 0.0, 0.0, 0.0)
glclear(GL_COLOR_BUFFER_BIT)
glloadidentity()
glRotatef(xRot, 1.0, 0.0, 0.0)
glRotatef(yRot, 0.0, 1.0, 0.0)
glRotatef(zRot, 0.0, 0.0, 1.0)
glCallList(list)
swapbuffer
wait 10
xRot += 1.0
yRot += 0.5
zRot += 0.02
wend
winEnd
lesson7
include "gl.inc"
Window 640,480,1
SetFrames 80
LoadFont "glfonts/font16.bmp"
LoadFont "glfonts/font25.bmp"
t1=LoadImage "gfx/titan.bmp"
t2=LoadImage "gfx/knot.bmp"
t3=LoadImage "gfx/rock.bmp"
float xrot,yrot
Sub Quad2D(single x,y,z)
glPushMatrix
glTranslatef x,y,z
glBegin(GL_QUADS)
glTexCoord2f 0.0,0.0: glVertex3f -1.0,-1.0, 0.0
glTexCoord2f 1.0,0.0: glVertex3f 1.0,-1.0, 0.0
glTexCoord2f 1.0,1.0: glVertex3f 1.0, 1.0, 0.0
glTexCoord2f 0.0,1.0: glVertex3f -1.0, 1.0, 0.0
glEnd
glPopMatrix
End Sub
Sub Quad3D(single x,y,z, an,rx,ry,rz)
glPushMatrix
glTranslatef x, y, z
glRotatef an,rx, ry, rz
glBegin(GL_QUADS)
glTexCoord2f 0.0, 0.0 : glVertex3f -1.0,-1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f 1.0,-1.0, 1.0
glTexCoord2f 1.0, 1.0 : glVertex3f 1.0, 1.0, 1.0
glTexCoord2f 0.0, 1.0 : glVertex3f -1.0, 1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f -1.0,-1.0,-1.0
glTexCoord2f 1.0, 1.0 : glVertex3f -1.0, 1.0,-1.0
glTexCoord2f 0.0, 1.0 : glVertex3f 1.0, 1.0,-1.0
glTexCoord2f 0.0, 0.0 : glVertex3f 1.0,-1.0,-1.0
glTexCoord2f 0.0, 1.0 : glVertex3f -1.0, 1.0,-1.0
glTexCoord2f 0.0, 0.0 : glVertex3f -1.0, 1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f 1.0, 1.0, 1.0
glTexCoord2f 1.0, 1.0 : glVertex3f 1.0, 1.0,-1.0
glTexCoord2f 1.0, 1.0 : glVertex3f -1.0,-1.0,-1.0
glTexCoord2f 0.0, 1.0 : glVertex3f 1.0,-1.0,-1.0
glTexCoord2f 0.0, 0.0 : glVertex3f 1.0,-1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f -1.0,-1.0, 1.0
glTexCoord2f 1.0, 0.0 : glVertex3f 1.0,-1.0,-1.0
glTexCoord2f 1.0, 1.0 : glVertex3f 1.0, 1.0,-1.0
glTexCoord2f 0.0, 1.0 : glVertex3f 1.0, 1.0, 1.0
glTexCoord2f 0.0, 0.0 : glVertex3f 1.0,-1.0, 1.0
glTexCoord2f 0.0, 0.0 : glVertex3f -1.0,-1.0,-1.0
glTexCoord2f 1.0, 0.0 : glVertex3f -1.0,-1.0, 1.0
glTexCoord2f 1.0, 1.0 : glVertex3f -1.0, 1.0, 1.0
glTexCoord2f 0.0, 1.0 : glVertex3f -1.0, 1.0,-1.0
glEnd
glPopMatrix
End Sub
while KeyDown(VK_ESCAPE)=0
Cls 0,0,0
glLoadIdentity
glTranslatef 0.0,0.0,-10.0
glBegin(GL_QUADS)
glColor3f 1.0, 0.0, 1.0
glVertex3f -1.0,-1.0, 0.0
glColor3f 1.0, 1.0, 1.0
glVertex3f 1.0,-1.0, 0.0
glVertex3f 1.0, 1.0, 0.0
glColor3f 1.0, 1.0, 1.0
glVertex3f -1.0, 1.0, 0.0
glEnd
glEnable GL_TEXTURE_2D
glBindTexture GL_TEXTURE_2D, t2
Quad2D -3, 0, -1
glBindTexture GL_TEXTURE_2D, t3
Quad2D 3, 0, -1
glBindTexture GL_TEXTURE_2D, t1
Quad3D(-6, 4,-6, xrot,1,0,1)
Quad3D( 6,-4,-6, yrot,0,1,0)
glColor3ub 255,128,0
Text 1, -0.064,0.34, "HELLO ", 0.032,0.064
glColor3ub 255,255,0
Text 1, -0.064,0.29, " EAT ", 0.032,0.064
glColor3ub 255,255,255
Text 1, -0.064, 0.24, "SPINACH ", 0.032,0.064
Text 2, -0.284,-0.40, "OPENGL3D ", 0.064,0.064
xrot +=1.0
yrot +=1.0
SwapBuffer
wend
WinEnd
lesson8
include "gl.inc"
window 640,480,1
#lookahead
while keydown(27)=0
glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
glLoadIdentity
glTranslatef -12.0, -7.0, -6.0
glRotatef -68.0, 1.0, 0.0, 0.0
for a=1 to 100
for c=1 to 10
DrawCube()
glTranslatef 3.0, 0.0, 0.0
next
glTranslatef -30.0, 4.0, 0.0
next
SwapBuffer
Wait (10)
wend
WinEnd
Sub DrawCube()
glBegin GL_QUADS
glColor3f 0.0, 1.0, 0.0
glVertex3f 1.0, 1.0,-1.0
glVertex3f -1.0, 1.0,-1.0
glVertex3f -1.0, 1.0, 1.0
glVertex3f 1.0, 1.0, 1.0
glColor3f 1.0, 0.5, 0.0
glVertex3f 1.0,-1.0, 1.0
glVertex3f -1.0,-1.0, 1.0
glVertex3f -1.0,-1.0,-1.0
glVertex3f 1.0,-1.0,-1.0
glColor3f 1.0, 0.0, 0.0
glVertex3f 1.0, 1.0, 1.0
glVertex3f -1.0, 1.0, 1.0
glVertex3f -1.0,-1.0, 1.0
glVertex3f 1.0,-1.0, 1.0
glColor3f 1.0, 1.0, 0.0
glVertex3f 1.0,-1.0,-1.0
glVertex3f -1.0,-1.0,-1.0
glVertex3f -1.0, 1.0,-1.0
glVertex3f 1.0, 1.0,-1.0
glColor3f 0.0, 0.0, 1.0
glVertex3f -1.0, 1.0, 1.0
glVertex3f -1.0, 1.0,-1.0
glVertex3f -1.0,-1.0,-1.0
glVertex3f -1.0,-1.0, 1.0
glColor3f 1.0, 0.0, 1.0
glVertex3f 1.0, 1.0,-1.0
glVertex3f 1.0, 1.0, 1.0
glVertex3f 1.0,-1.0, 1.0
glVertex3f 1.0,-1.0,-1.0
glEnd
End Sub
lesson9
include "gl.inc"
window 640,480,1
SetFrames (60)
f1=LoadFont "glfonts/font15.bmp"
t1=Loadimage "gfx/texture8.bmp"
t2=LoadImage "gfx/texture6.bmp"
t3=LoadImage "gfx/texture3.bmp"
t4=LoadImage "gfx/texture9.bmp"
int abc=t1
glEnable (GL_TEXTURE_2D)
single xrot, yrot, zrot
Sub Texture2D(single x,y,z)
glPushMatrix
glLoadIdentity
glTranslatef x, y, z
glBegin GL_QUADS
glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, -1.0, 1.0)
glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, -1.0, 1.0)
glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, 1.0)
glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, 1.0)
glEnd
glPopMatrix
End Sub
while KeyDown(27)=0
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glLoadIdentity
glTranslatef 0.0,0.0,-5.5
glRotatef xrot,1.0,0.0,0.0
glRotatef yrot,0.0,1.0,0.0
glRotatef zrot,0.0,0.0,1.0
mx = xMouse
my = yMouse
if mousebutton()=1 and mx >=0 and mx <=108 and my >=0 and my <=104
abc=t3
elseif mousebutton()=1 and mx >=0 and mx <=108 and my >=109 and my <=212
abc=t4
elseif mousebutton()=1 and mx >=0 and mx <=108 and my >=219 and my <=315
abc=t1
elseif mousebutton()=1 and mx >=0 and mx <=108 and my >=320 and my <=420
abc=t2
endif
glColor3ub 255,255,255
Text 1,0.01,0.38, "CLICK ON TEXTURE", 0.032,0.032
glEnable GL_TEXTURE_2D
glBindTexture GL_TEXTURE_2D, t3
Texture2D -5.0,3.5,-12.0
glBindTexture GL_TEXTURE_2D, t4
Texture2D -5.0,1.5,-12.0
glBindTexture GL_TEXTURE_2D, t1
Texture2D -5.0,-0.5,-12.0
glBindTexture GL_TEXTURE_2D, t2
Texture2D -5.0,-2.5,-12.0
glBindTexture GL_TEXTURE_2D, abc
glBegin GL_QUADS
glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, -1.0, 1.0)
glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, -1.0, 1.0)
glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, 1.0)
glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, 1.0)
glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, -1.0)
glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, 1.0, -1.0)
glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, 1.0, -1.0)
glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, -1.0)
glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, -1.0)
glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, 1.0, 1.0)
glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, 1.0, 1.0)
glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, -1.0)
glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, -1.0, -1.0)
glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, -1.0, -1.0)
glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, 1.0)
glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, 1.0)
glTexCoord2f(1.0, 0.0): glVertex3f( 1.0, -1.0, -1.0)
glTexCoord2f(1.0, 1.0): glVertex3f( 1.0, 1.0, -1.0)
glTexCoord2f(0.0, 1.0): glVertex3f( 1.0, 1.0, 1.0)
glTexCoord2f(0.0, 0.0): glVertex3f( 1.0, -1.0, 1.0)
glTexCoord2f(0.0, 0.0): glVertex3f(-1.0, -1.0, -1.0)
glTexCoord2f(1.0, 0.0): glVertex3f(-1.0, -1.0, 1.0)
glTexCoord2f(1.0, 1.0): glVertex3f(-1.0, 1.0, 1.0)
glTexCoord2f(0.0, 1.0): glVertex3f(-1.0, 1.0, -1.0)
glEnd()
SwapBuffer
wait (10)
xrot +=0.6
yrot +=0.4
zrot +=0.8
wend
WinEnd
lessonA
include "gl.inc"
window 640,480,1
sys texture[20]
glGenTextures 20, &texture[]
Function LoadRaw(sys id,string rawFile,int size)
hnd = OpenFile rawFile
big = GetFileSize hnd
mem = GetMemory big
ReadByte hnd, *mem,big
CloseFile hnd
glBindTexture GL_Texture_2D, texture[id]
glTexImage2D GL_Texture_2D,0,GL_RGB,SIZE,SIZE,0,GL_RGB,GL_UNSIGNED_BYTE,MEM
glTexParameteri GL_Texture_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
glTexParameteri GL_Texture_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
FreeMemory mem
End Function
Sub Quad2D(float x,y,z)
glPushMatrix
glTranslatef x,y,z
glBegin(GL_QUADS)
glTexCoord2f 0.0, 0.0: glVertex3f -1.0, 1.0,-1.0
glTexCoord2f 1.0, 0.0: glVertex3f 1.0, 1.0,-1.0
glTexCoord2f 1.0, 1.0: glVertex3f 1.0,-1.0,-1.0
glTexCoord2f 0.0, 1.0: glVertex3f -1.0,-1.0,-1.0
glEnd
glPopMatrix
End Sub
loadraw 1,"raw/texture04_256.raw",256
loadraw 2,"raw/texture09_256.raw",256
loadraw 3,"raw/texture06_256.raw",256
loadraw 4,"raw/texture07_256.raw",256
glEnable GL_TEXTURE_2D
while KeyDown(27)=0
cls 0,0,0
glLoadIdentity
glBindTexture GL_TEXTURE_2D,texture[1]
Quad2D -1, 1,-3.8
glBindTexture GL_TEXTURE_2D,texture[2]
Quad2D 1, 1, -3.8
glBindTexture GL_TEXTURE_2D,texture[3]
Quad2D -1,-1,-3.8
glBindTexture GL_TEXTURE_2D,texture[4]
Quad2D 1,-1, -3.8
SwapBuffer
wend
glDeleteTextures 20, &texture
WinEnd