sdchown's picture

VB .NET Help. Can't get OpenTK to do anything.

Hi

I have installed it all and followed the VB .NET example, but all I get is a blank window. No colour, no nothing.

Any help? Any ideas?

Code below:

Imports System.Drawing
Imports System
Imports OpenTK
Imports OpenTK.Graphics.OpenGL
 
Public Class Mainform
 
 
    Dim loaded As Boolean = False
 
 
    Private Sub Mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        InitializeComponent()
 
    End Sub
 
    Private Sub GlControl1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GlControl1.KeyDown
        If e.KeyValue = Keys.Escape Then
            Application.Exit()
        Else
            GlControl1.Invalidate()
        End If
 
    End Sub
 
 
 
 
    Private Sub GlControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GlControl1.Load
        loaded = True
        GlControl1_Resize(sender, EventArgs.Empty)
 
        GL.ClearColor(Color.ForestGreen)
 
    End Sub
 
    Private Sub GlControl1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GlControl1.Paint
        If Not loaded Then Exit Sub
        GL.Clear(ClearBufferMask.ColorBufferBit)
        GlControl1.MakeCurrent()
 
        GlControl1.SwapBuffers()
 
    End Sub
 
    Private Sub GlControl1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles GlControl1.Resize
        If Not loaded Then Exit Sub
        If GlControl1.ClientSize.Height = 0 Then GlControl1.ClientSize = New System.Drawing.Size(GlControl1.ClientSize.Width, 1)
 
        GL.Viewport(0, 0, GlControl1.ClientSize.Width, GlControl1.ClientSize.Height)
 
    End Sub
End Class

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
devintelo's picture

I think you should update your Glcontrol1_Paint with a timer or review your Glcontrol1_Resize sub .
I'm not sure but its free to try ^^

In all my apps , my resize sub is

 
    Private Sub GLControl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles GlControl1.Resize
        Dim aspect As Single = GlControl1.Width / GlControl1.Height
        Dim matProj As Matrix4 = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect, 0.1, 100.0)
        GL.Viewport(0, 0, GlControl1.Width, GlControl1.Height)
        GL.MatrixMode(MatrixMode.Projection)
        GL.LoadMatrix(matProj)
        GL.MatrixMode(MatrixMode.Modelview)
        GL.LoadIdentity()
    End Sub

Edit : Did you reference opentk.dll ? Is your form window opening ?

AftPeakTank's picture

Try to check my example...

It will also give you an empty window but you will see how you can change the color of the background for example.

I havent tested yours to see the result yet.

Try to take a look at my example:

VB.net - GLControl - Implementation - 01

maniscbe's picture

Disable 'InitializeComponent() @ load

Try this

Imports System.Drawing
Imports System
Imports OpenTK
Imports OpenTK.Graphics.OpenGL
 
Public Class Mainform
 
 
    Dim loaded As Boolean = False
 
 
    Private Sub Mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' InitializeComponent()
 
    End Sub
 
    Private Sub GlControl1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GlControl1.KeyDown
        If e.KeyValue = Keys.Escape Then
            Application.Exit()
        Else
            GlControl1.Invalidate()
        End If
 
    End Sub
 
 
 
 
    Private Sub GlControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GlControl1.Load
        loaded = True
        GlControl1_Resize(sender, EventArgs.Empty)
 
        GL.ClearColor(Color.ForestGreen)
 
    End Sub
 
    Private Sub GlControl1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GlControl1.Paint
        If Not loaded Then Exit Sub
        GL.Clear(ClearBufferMask.ColorBufferBit)
        GlControl1.MakeCurrent()
 
 
        GlControl1.SwapBuffers()
 
    End Sub
 
    Private Sub GlControl1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles GlControl1.Resize
        If Not loaded Then Exit Sub
        If GlControl1.ClientSize.Height = 0 Then GlControl1.ClientSize = New System.Drawing.Size(GlControl1.ClientSize.Width, 1)
 
        GL.Viewport(0, 0, GlControl1.ClientSize.Width, GlControl1.ClientSize.Height)
 
    End Sub
End Class

Thx,
Mani

darkdave's picture

I was sure I posted something related in this thread, what happened to my message? This is why i prefer D3D, at least i wont get any bullshit when i ask for support from Microsoft.

All i wanted to know was how to convert some tao code to opentk regarding GLUT.

darkdave's picture

Anyone know how to convert TAO to OpenTK in the following VB.NET code:

Public sphere As Tao.OpenGl.Glu.GLUquadric = New Tao.OpenGl.Glu.GLUquadric

Inertia's picture

I have deleted all those triple-posts and old bumped threads you started. You also c&p the same question to opengl.org and god knows probably other places too. You don't even read or try the solutions from the posts, the answer to your question is actually in one of the threads you bumped. You are just wasting peoples time with this attention-whoring style of posting.

(This is the one and only warning, all this together is reason enough for a ban since you are worse than kitchen-sale spam)

darkdave's picture

Hey I didnt even ralize i was tripple posting, it seems as if each time i posted it gets deleted!!

U seriously want to ban some one who is genuinely just trying to get support regarding OpenTK!??! Seriously?

In fact I got so frustrated from the lack of support in both openGL and openTK forums that i have already reverted my VB project back to TAO, which still doesnt work!!

I feel like jumping out my apartment window im so frustrated!!

darkdave's picture
Inertia wrote:

I have deleted all those triple-posts and old bumped threads you started. You also c&p the same question to opengl.org and god knows probably other places too. You don't even read or try the solutions from the posts, the answer to your question is actually in one of the threads you bumped. You are just wasting peoples time with this attention-whoring style of posting.

(This is the one and only warning, all this together is reason enough for a ban since you are worse than kitchen-sale spam)

AND WHICH THREAD THAT I "BUMPED" ??

It's easy to say i use attention grabbing whoring style when its the only proven way of getting some help!

Inertia's picture

Killing 1 (spamming) user to protect the others from spam is what I do every day.

Most people use C#, the only dev with some VB experience is Fiddler afaik. You will likely get better results at the Microsoft forums, or a dedicated VB forum.

darkdave's picture

YOU SAID THAT THE ANSWER IS IN ONE OF THE THREADS I BUMPED... WHICH ONE??? PLEASE GIVE ME THE LINK!!

PLEEEEEEEEEEEEEEAAAAAASEE !!!!

I BEG YOU !!!!

I HAVE BEEN WAITING DAYS TO GET AN ANSWER!! AND ALL YOU CARE ABOUT IS SHOWING OFF YOUR POWER TO STOP PEOPLE SELLING KITCHEN KNIVES!!!!

WHERE IS MY S U P P O R T ?