Mungkin kita tahu tentang piramida itu terdiri dari 4 segitiga tapi saya akan membuat dengan 3 segitiga.Walapun hasil yang kurang memuaskan tapi lumayan ga jelek-jelek bangat si..heeee
dim angle#
dim tex1,tex2,tex3,tex4
tex1 = LoadMipmapTexture ("1.jpg") 'untuk mengambil foto biar segitiga da gambarnya
tex2 = LoadMipmapTexture ("2.jpg")
tex3 = LoadMipmapTexture ("3.jpg")
'glactivetexture(gl_texture0)
glEnable (GL_TEXTURE_2D)
'Turn lighting on with this command:
glEnable(GL_LIGHTING)
'Turn on Light #0 with this command
glEnable(GL_LIGHT0)
'Set position of Light #0 with this command
glLightfv(GL_LIGHT0, GL_POSITION, Vec3(0, 0, 1))
'Set the ambience of the light with this
glLightfv(GL_LIGHT0, GL_AMBIENT, vec4(.2,.2,.2,1))
'Set the diffuse of the light with this
glLightfv(GL_LIGHT0, GL_DIFFUSE, vec4(1, 1, 1, 1))
glbindtexture(gl_texture_2d, tex1)
'glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
'glactivetexture(gl_texture1)
'glEnable (GL_TEXTURE_2D)
'glbindtexture(gl_texture_2d, tex2)
'glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
'glactivetexture(gl_texture2)
'glEnable (GL_TEXTURE_2D)
'glbindtexture(gl_texture_2d, tex3)
'glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
'glactivetexture(gl_texture3)
'glEnable (GL_TEXTURE_2D)
while true
glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glLoadIdentity ()
glTranslatef (0, 0, -4) 'ukuran besar kecilnya segitiga
glRotatef (angle#, 0, 1, 0) 'mengatur gerakan dari segitiga
glBindTexture(GL_TEXTURE_2D, tex1) 'segitiga depan
glBegin(GL_QUADS)
' Front face
glTexCoord2f(0.0, 0.0): glVertex3f ( 0, 1, 0)
glTexCoord2f(3.0, 0.0): glVertex3f (1, -1, -1)
glTexCoord2f(1.0, 1.0): glVertex3f ( -1,-1, -1)
glTexCoord2f(0.0, 1.0): glVertex3f ( 0, 1, 0)
glend()
glBindTexture(GL_TEXTURE_2D, tex2) 'segitiga kanan
glBegin(GL_QUADS)
' Front face
glTexCoord2f(1.0, 0.0): glVertex3f ( 0, 1, 0)
glTexCoord2f(1.0, 1.0): glVertex3f (0, -1, 1)
glTexCoord2f(0.0, 1.0): glVertex3f (1, -1, -1)
glTexCoord2f(0.0, 0.0): glVertex3f ( 0, 1, 0)
glend()
glBindTexture(GL_TEXTURE_2D, tex3) 'segitiga kiri
glBegin(GL_QUADS)
' Front face
glTexCoord2f(0.0, 1.0): glVertex3f ( 0, 1, 0)
glTexCoord2f(0.0, 0.0): glVertex3f ( -1,-1, -1)
glTexCoord2f(1.0, 0.0): glVertex3f (0, -1, 1)
glTexCoord2f(1.0, 1.0): glVertex3f ( 0, 1, 0)
glend()
SwapBuffers ()
angle# = angle# + -0.8 'kecepatan dari rotasi yang di hasilkan
wend
Selasa, 22 Januari 2013
Langganan:
Posting Komentar (Atom)
1 komentar:
kita juga punya nih artikel mengenai 'OpenGL', silahkan dikunjungi dan dibaca , berikut linknya
http://repository.gunadarma.ac.id/bitstream/123456789/2293/1/Differences%20Of%20Cube%20Mapping%20and%20Dynamic%20Cube%20Mapping.pdf
terimakasih
Posting Komentar