gambas-source-code/app/examples/OpenGL/NeHeTutorial/.src/Example3.module
Benoît Minisini c6a9cd69c2 [EXAMPLES]
* NEW: Add examples again. I hope correctly this time.


git-svn-id: svn://localhost/gambas/trunk@6726 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-12-12 19:58:52 +00:00

76 lines
2.8 KiB
Text

' Gambas module file
'tutorial based on tutorial from NeHe Productions site at http://nehe.gamedev.net/
'visit the page for more info on OpenGL
'
'In this tutorial we add some color to our triangle and quad from tutorial 2
' Gambas module file
Private screen As New Window(True) As "Screen"
Public Sub Main()
With screen
.Width = 640
.Height = 480
.Text = MMain.Title
.Show()
End With
End
Public Sub Screen_Open()
Gl.ClearDepth(100.0) 'Enables Clearing Of The Depth Buffer
gl.ClearColor(0.0, 0.0, 0.0, 0.0) 'This Will Clear The Background Color To Black
gl.DepthFunc(gl.LESS) 'The Type Of Depth Test To Do
gl.Enable(gl.DEPTH_TEST) 'Enables Depth Testing
gl.ShadeModel(gl.SMOOTH) 'Enables Smooth Color Shading
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity() 'Reset The Projection Matrix
glu.Perspective(45.0, screen.Width / screen.Height, 0.1, 100.0) 'Calculate The Aspect Ratio Of The Window
gl.MatrixMode(gl.MODELVIEW)
End
Public Sub Screen_resize()
Gl.Viewport(0, 0, Screen.Width, Screen.Height)
Gl.MatrixMode(Gl.PROJECTION)
Gl.LoadIdentity() 'Reset The Projection Matrix
glu.Perspective(45.0, screen.Width / screen.Height, 0.1, 100.0) 'Calculate The Aspect Ratio Of The Window
Gl.MatrixMode(Gl.MODELVIEW)
End
Public Sub init()
End
Public Sub Screen_Draw()
gl.Clear(gl.COLOR_BUFFER_BIT Or gl.DEPTH_BUFFER_BIT) ' Clear The Screen And The Depth Buffer
gl.LoadIdentity() 'Reset The View
gl.translatef(-1.5, 0.0, -6.0) ' MOVE Left 1.5 Units AND Into The Screen 6.0
gl.Begin(gl.TRIANGLES) 'Drawing Using Triangles
gl.Color3f(1.0, 0.0, 0.0) 'Set The Color TO Red
gl.Vertex3f(0.0, 1.0, 0.0) 'Top
gl.Color3f(0.0, 1.0, 0.0) 'Set The Color TO Green
gl.Vertex3f(-1.0, -1.0, 0.0) 'Bottom Left
gl.Color3f(0.0, 0.0, 1.0) 'Set The Color TO Blue
gl.Vertex3f(1.0, -1.0, 0.0) 'Bottom Right
gl.End() 'Finished Drawing The Triangle
gl.Translatef(3.0, 0.0, 0.0) 'MOVE Right 3 Units
gl.Color3f(0.5, 0.5, 1.0) 'Set The Color TO Blue One Time Only
gl.Begin(gl.QUADS) 'Draw A Quad
gl.Vertex3f(-1.0, 1.0, 0.0) 'Top Left
gl.Vertex3f(1.0, 1.0, 0.0) 'Top Right
gl.Vertex3f(1.0, -1.0, 0.0) 'Bottom Right
gl.Vertex3f(-1.0, -1.0, 0.0) 'Bottom Left
gl.End() 'Done Drawing The Quad
End