Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7559925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:45:51+00:00 2026-05-30T12:45:51+00:00

I was trying to learn how to do openGL within a VB .NET environment

  • 0

I was trying to learn how to do openGL within a VB .NET environment and it seems that the Tao framework or OpenTK is recommended with OpenTK having a higher recommendation so that is what I chose to try using.

Since I am brand new to this, I am trying to just draw a simple box, triangle, or anything really so that I can understand it all before making more complex things. I have been unsuccessful at this so far so I will list in order what I have done so far and hopefully someone here can help me correct it or provide a new example just so I can draw a simple shape.

1) I installed OpenTK using opentk-2010-10-06.exe

2) In a new project I added the references to OpenTK.dll and OpenTK.Compatibility.dll

3) I added the control (opentk.glcontrol.dll)

4) I added the actual control to my form.

Using some examples online I added the rest:

5) I wrote my references in:

Imports OpenTK
Imports OpenTK.GLControl
Imports OpenTK.Platform
Imports OpenTK.Graphics.OpenGL
Imports System.Math

6) My global variable:

 Dim _STARTED As Boolean = False

7) I wrote my events:

Private Sub GlControl1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles GlControl1.Resize
_STARTED = True
ResizeGL()
End Sub

Private Sub ResizeGL()
    GL.Viewport(0, 0, GlControl1.Width, GlControl1.Height)
    GL.MatrixMode(MatrixMode.Projection) ' Select The Projection Matrix
    GL.MatrixMode(MatrixMode.Modelview) ' Select The Modelview Matrix
    GL.LoadIdentity() ' Reset The Modelview Matrix
End Sub


Public Sub ViewPerspective() ' Set Up A Perspective View

    GL.MatrixMode(MatrixMode.Projection) ' Select Projection
    GL.LoadIdentity() ';    
    Dim perspective1 As Matrix4 = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, _
                                         CSng((GlControl1.Width) / (GlControl1.Height)), 0.1, 1000)
    GL.LoadMatrix(perspective1)
    GL.MatrixMode(MatrixMode.Modelview) ' Select The Modelview Matrix
    GL.LoadIdentity() ' Reset The Matrix
    GL.Enable(EnableCap.DepthTest) ' This doesnt need to be here but.. If your using the Z buffer.. It dont hurt.

End Sub


Public Sub ViewOrtho()
    GL.MatrixMode(MatrixMode.Projection) 'Select Projection
    GL.LoadIdentity() ' Reset The Matrix
    GL.Ortho(0, GlControl1.Width, -GlControl1.Height, 0, 0.1, 100.0) ' Select Ortho Mode
    GL.MatrixMode(MatrixMode.Modelview) ' Select Modelview Matrix
    GL.LoadIdentity() ' Reset The Matrix
End Sub

8) Lastly, I tried to call them:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ViewOrtho()
End Sub

The above results in no display, so any help would be greatly appreciated.

Even if you don’t know a full solution, any response wouldbe nice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:45:52+00:00Added an answer on May 30, 2026 at 12:45 pm

    I have solved my own question :p I have created a wrapper class so that I can draw some primatives based on inputs which should allow me to draw many things: a circle, polygon, triangle, and text.

    Private Sub GlControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GlControl1.Load
        GL.ClearColor(Color.Black)
        SetupViewport()
    End Sub
    
    Public 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)
        GL.Viewport(0, 0, w, h)
    End Sub
    
    
    Private Sub GlControl1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GlControl1.Resize
        SetupViewport()
        GlControl1.Invalidate()
    End Sub
    
    
    Private Sub GlControl1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GlControl1.Paint
        GL.Clear(ClearBufferMask.ColorBufferBit)
        GL.Clear(ClearBufferMask.DepthBufferBit)
    
        'go through list and draw shapes
        Dim i As Integer = 0
        Try
            Do Until i = objectsettings.GetUpperBound(1) + 1
                Select Case objectsettings(1, i)
                    Case "circle"
                        draw_circle(objectsettings(2, i), objectsettings(3, i), objectsettings(5, i), objectsettings(12, i))
                    Case "polygon"
                        draw_polygon(objectsettings(2, i), objectsettings(3, i), objectsettings(6, i), objectsettings(7, i), objectsettings(4, i), objectsettings(12, i))
                    Case "text"
                        draw_text(objectsettings(2, i), objectsettings(3, i), objectsettings(6, i), objectsettings(7, i), objectsettings(4, i), objectsettings(8, i), objectsettings(12, i))
                    Case "triangle"
                        draw_triangle(objectsettings(2, i), objectsettings(3, i), objectsettings(4, i), objectsettings(9, i), objectsettings(10, i), objectsettings(11, i), objectsettings(12, i))
                    Case Else
                        Exit Do
                End Select
    
    
                i = i + 1
            Loop
        Catch
        End Try
    
    
    
        GlControl1.SwapBuffers()
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to learn about OpenGL ES for the iPhone and following
I'm trying to learn to play with OpenGL GLSL shaders. I've written a very
I'm trying to learn OpenGL ES quickly (I know, I know, but these are
I'm trying to learn some OpenGL via this tutorial . My question is regarding
Trying to learn PL/SQL with multimedia data. Can anyone please point out that from
I'm trying to learn OpenGL and improve my C++ skills by going through the
Trying to learn jquery here so I took a regular javascript snippet that loops
I am trying to learn OpenGL on the iPhone using the Super Bible but
I am trying to learn to write OpenGL apps for the iPhone. How can
I'm trying to learn OpenGL with the redbook, and I'm now at the point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.