Advertisement
Guest User

Problem with OpenTK in VB

a guest
Jun 11th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.12 KB | None | 0 0
  1. Imports OpenTK
  2. Imports OpenTK.Graphics
  3. Imports OpenTK.Graphics.OpenGL
  4. Public Class Form1
  5.  
  6.     Private Sub GL_Load(sender As Object, e As System.EventArgs) Handles GlControl1.Load
  7.         GL.ClearColor(Color.Black)
  8.  
  9.         GL.MatrixMode(MatrixMode.Projection)
  10.         GL.LoadIdentity()
  11.         GL.Ortho(0, GlControl1.Width, GlControl1.Height, 0, 1, -1)
  12.         GL.MatrixMode(MatrixMode.Modelview)
  13.  
  14.     End Sub
  15.  
  16.     Private Sub GlControl1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles GlControl1.Paint
  17.         GL.Clear(ClearBufferMask.ColorBufferBit)
  18.         GL.LoadIdentity()
  19.  
  20.         GL.Begin(BeginMode.Polygon)
  21.         GL.Color3(255, 0, 0)
  22.         GL.Vertex2(0, 5)
  23.         GL.Vertex2(5, -5)
  24.         GL.Vertex2(-5, -5)
  25.         GL.End()
  26.  
  27.         GL.Begin(BeginMode.Lines)
  28.         GL.Color3(0, 255, 0)
  29.         GL.Vertex2(50, 50)
  30.         GL.Vertex2(100, 100)
  31.         GL.End()
  32.  
  33.         GL.Flush()
  34.         GraphicsContext.CurrentContext.VSync = True 'Caps frame rate as to not over run GPU
  35.         GlControl1.SwapBuffers() 'Takes from the 'GL' and puts into control
  36.     End Sub
  37. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement