
Visual Basic .NET
Posted Friday, 7 January, 2011 - 04:45 by vmelkon inI downloaded and checked the instructions, I looked into the documentation and did a few web searches. I'm still not clear on what I'm suppose to do.
I'm using what MS called the Development Environment 2003.
So where do I put the files so that it will recognize code like OpenGL.GL.glEnable(GL_xxxxxx).
Also, I'm getting the impression that OpenTK is for C# only.
Do I have to use Tao. Isn't Tao old?


Comments
Re: Visual Basic .NET
I'm using what MS called the Development Environment 2003.
You are using .Net 1.1 but OpenTK requires .Net 2.0, as documented here. This translates into Visual Studio 2005 or higher.
You can download the free edition of Visual Studio 2010 from http://www.microsoft.com/express/. Once you have that, OpenTK will be listed as a .Net reference that you can add to your VB.Net project.
Note that Tao also requires .Net 2.0.
Re: Visual Basic .NET
Not to sound rude but.. there is a real lack of Examples of working with OpenTK.
There needs to be a site created by the Authors of OpenTK .. where people can contribute Examples.
It took me hours of messing with with code to switch back and forth from Perspective and Ortho. All the examples are done in Ortho and useless for actual 3D work.
I'll post some stuff I use below.
I'm using OpenTK with VS 2008... VB.NET
You need to at least get the new express version of VB to use OpenTK.
In order to use anything in OpenTK, you need to add a reference to the .DLLs that are needed.
OpenTK.DLL and OpenTK.GLControl and the Platform. (Windows XP Pro is my OS)
When you install OpenTK.. these files are place in your 'My Documents' folder under OpenTK.
Navigate to the Sub folder named 'Bin' and in there you will find the DLLs you need.
You will need to add the 'Import" directive to the top of each .VB file thats going to use OpenTK.
Also, to use the OpenTK.Control on a form, you will need to add this control to the list of controls that you can drop in to a form window. Just right click on the list of controls in some blank area and pick 'Choose Items...'.
After, browse to the location I described above and add the OpenTK.GLControl. It should now show up on the list of controls you can add to a form.
Once this GLControl is added, you can use any of the events it fires. The most important is the Resize.. Why is explained below.
I still cant figure out how to change any parameters in the GLControl. Z Depth-- Colors... WHERE ARE THE EXAMPLES ON THIS!!!????
So.. heres the steps.
1. Add the DLL references.
2. Add the OpenTK.GLControl to your list of Controls
3. Drag the OpenTK.GLControl on to your form and set its Size and Anchor..... I usually just dock it to fill the entire window.
4. Add the Imports to your program's head.
5. Write the code.
You must NEVER use the GLControl before it is actually created!
I use a Global variable named _STARTED as Boolean = False
In any sub/function thats going to use the GLControl, add this at the top.
If Not _STARTED Then ReturnIn the GLControls Paint Event it needs to look like this
Heres the code for the ResizeGL
If you want to auto update the screen, us a timer or create a thread that loops for ever (I have not tried this yet). This can get very tricky.
From my experience, Every thing has to be created in this same thread. VBOs CallLists.. all of that.
If you just want to Update the GLGLControl... Use: OpenTK.GLControl.Invalidate. This will force it to redraw.
OK.. the general rule of 3D is, anytime you switch to Perspective.. You MUST set the Camera and LookAt locations.
These NOT Modal and are lost when the Identity is loaded!
Heres the code to switch to Ortho:
Heres my code to set the cam position. Not that the variables are the rotations in the axis of Z and X.
ROT_X is the x,y or rotating around the Z axis and ROT_Y is rotating around the X axis. A bit confusing I'm sure.
Oh and look_radius is how far from the eye position you are.
This transform will keep the camera looking at the same point, regardless of rotation angles or the distance of look_radius.
You must note here that I have the lookup vector set to Z. NOT Y!!!!
So your draw sub might look like this:
So.. you might be wondering why I use Z as the UP vector. This is how I work in the real world. Z is always up/down.
I hope this helps.. if not you.. maybe some one :)
--Mike O
P.S.
About your comment that VB Sucks...
To make things clear... There is NO difference between the speed of a C# or VB.NET app. They both are complied at 'Run TIme' and produce exactly the same code. They run at the exact same speed.
I actually prefer VB.NET over C#... Its way easier to create forms and such.
This does NOT include C or C++.. they are a different animal all together. Here again tho, from what I have read on line, you will see only around a 2% drop in speed using .NET. There is also Assembly Code... It don't get any faster then this but is also, a real pain in the butt to master!
Re: Visual Basic .NET
All the examples are done in Ortho and useless for actual 3D work.
How is this related to OpenTK? There are tons of OpenGL (note the L) tutorials, forums, books out there that deal with these topics.
If you feel something is missing, be it specific to OpenTK or not, just post it on the forums or some wiki and everybody will appreciate it.
Re: Visual Basic .NET
All the examples are done in Ortho and useless for actual 3D work.
How is this related to OpenTK? There are tons of OpenGL (note the L) tutorials, forums, books out there that deal with these topics.
If you feel something is missing, be it specific to OpenTK or not, just post it on the forums or some wiki and everybody will appreciate it.
too funny... And here I was thinking I was being helpful.
Re: Visual Basic .NET
I think you were helpful, yes. But the "there's not enough tutorials about non-ortho rendering" is not true.
Re: Visual Basic .NET
Im sorry if I upset you.. Im not dizzing this site. I just know that I cant find what I need here usually.
My idea is to get an actual place setup just to list tuts at. Can this be done?
Maybe break it in to a few catagories like the GLControl and the GameWindow tools.
Maybe combine this in to the documents area?
These are just ideas and I have lots of them.
Re: Visual Basic .NET
Have you checked the Example Browser that is installed along with OpenTK? It has tutorials on OpenTK (GameWindow, GLControl), OpenGL and OpenAL. It has examples for ortho and 3d projections, shaders, vertex buffer objects, texture compression, complete with (C#) source code.
Re: Visual Basic .NET
Thanks Mike for the help.
I was able to add GLControl to the toolbox and I added the GLControl onto my window.
I also added
Imports OpenTK
Imports OpenTK.GLControl
Imports OpenTK.Platform
I added a handle for Resize just like you have done but it can't recognize some stuff.
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
Error 1 'GL' is not declared. It may be inaccessible due to its protection level. C:\Users\vrej\documents\visual studio 2010\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 16 9 WindowsApplication1
and there are other similar errors.
I assume I have to allocate a GL?
This is what I need information on. How to setup for VB .NET.
Do I have to choose a pixel format? Do I have to SetPixelFormat, and create a context?
Where to destroy the context.
I will try to get some feedback from people over at www.opengl.org and if they agree, I'll add it to the Wiki (www.opengl.org/wiki).
Re: Visual Basic .NET
You are missing an import:
Re: Visual Basic .NET
Thanks Fiddler.
Now for rendering a triangle. I added a little bit of code but it doesn't recognize
SwapBuffers()
I guess I need to import it with that "Imports" thing?
I tried "Imports System" but that's not it.
I'm also checking out those .cs examples but it has
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;