Simple renderer in .net with SharpGL (openGL)


Re: Simple renderer in .net with openTK (openGL)
#28
For example:

Code:
Private Sub GlControl1_Load(sender As Object, e As System.EventArgs) Handles GlControl1.Load
        glLoaded = True
        GL.ClearColor(Color.SkyBlue) ' .NET Colors can be used directly!
        SetupViewport()
End Sub
Private Sub SetupViewport()
        Dim w As Integer = GlControl1.Width
        Dim h As Integer = GlControl1.Height
        GL.MatrixMode(MatrixMode.Projection)
        GL.LoadIdentity()
        GL.Ortho(0, w, 0, h, -1, 1) ' // Bottom-left corner pixel has coordinate (0, 0)
        GL.Viewport(0, 0, w, h) ' // Use all of the glControl painting area
End Sub
Public Sub GlControl1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles GlControl1.Paint
        If Not glLoaded Then Exit Sub

        GL.Clear(ClearBufferMask.ColorBufferBit Or ClearBufferMask.DepthBufferBit)

        GL.MatrixMode(MatrixMode.Modelview)
        GL.LoadIdentity()
        GL.Color3(Color.Brown)

        GL.Begin(BeginMode.Triangles)
        GL.Vertex2(10, 20)
        GL.Vertex2(100, 20)
        GL.Vertex2(100, 50)
        GL.End()

        GlControl1.SwapBuffers()
End Sub

This is the code that currently works.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: Simple renderer in .net with openTK (openGL) - by Michael Heidemann - 2013-11-30, 15:48

Forum Jump:


Users browsing this thread: 10 Guest(s)