Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Problem with OpenTK in VB

By: a guest on Jun 11th, 2013  |  syntax: VB.NET  |  size: 1.12 KB  |  views: 66  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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