View Full Version : Using OpenGL extensions in Visual Basic
04-29-2001, 01:10 PM
Anyone know the equivalent of wglGetProcAddress in Visual Basic? How would you go about accessing OpenGL extensions in a Visual Basic program...?
04-30-2001, 09:48 AM
I'm not sure how to do exactly what you want, but I can give you some info you might not want to hear... http://www.opengl.org/discussion_boards/ubb/smile.gif
VB doesn't have any real sense of function pointers the way C/C++ do. wglGetAddressProc requires use of function pointers. VB has an AddressOf operator, but I don't think it's going to help you with this, but I could be wrong.
I do a lot of programming with both VB and C++. (VB programming isn't by choice, it's what I use at work.) There are a lot of ugly things with VB that make it a less than ideal environment for using OpenGL. (The wglGetProcAddress is one example.)
the person who provides you the dll must provide you a fonction for all the extension plus a fonction like IsExtensionSupported(string) which says if an extension is supported or not.
If the extension is supported, than it is safe to use the provided fonction, if it is not supported, then it is not safe.
The fonctions exported to VB encapsulate the fonction pointers which should be set during the dll loading.
I am sure someone have written such a dll an API. If you browse around the web(www.google.com) you'll probably find what you need. Or try asking on gamedev.net.
05-02-2001, 12:17 PM
You don't need your own DLL to use VB with OpenGL. There is a type-library available that uses OpenGL32.dll, and even if there wasn't it's easy enough to create your own (though time consuming.) An example of doing this with DescribePixelFormat would be this (pulled from API viewer). http://www.opengl.org/discussion_boards/ubb/smile.gif
Public Declare Function DescribePixelFormat Lib "gdi32" Alias "DescribePixelFormat" (ByVal hDC As Long, ByVal n As Long, ByVal un As Long, lpPixelFormatDescriptor As PIXELFORMATDESCRIPTOR) As Long
The problem is that extensions aren't exported in OpenGL32.dll, so you can't use that same mechanism to get them. I can't really suggest trying to get them from the vendor specific DLLs for the following reasons:
a) It might not even be possible.
b) You'd need to do this for each vendor's version, which is ugly, and since you can't conditionally do this, your app may try to bind the function to a dll that doesn't exist, which would probably result in your app crashing.
The AddressOf operator I mentioned before works for passing a function pointer for a callback function, but only if you are passing it as a parameter to the function, so it wouldn't work for wglGetProcAddress.
The only real solution might be to use what Gorg suggests, by creating your own dll in C/C++ for getting those, but not to the extent he proposes since that really wouldn't be necessary.
05-03-2001, 04:30 AM
Any chance of VB.Net (VB7) being able to provide the functionality we're looking for? From what I hear, it is now a truly OOP environment...
12-30-2005, 12:51 AM
Not sure what version of VB you use, so this may not help but you never know.
You may be interested in this
Download the C# OpenGL Framework for .NET 2.0:
Take a look at the OpenGL.cs file, I have not used the extensions but itís looks like the function ĎLoadExtensionsí may be of interest.
Of course its in C# but itís not difficult to convert.
In fact I have made this ĎOpenGL.csí into a Class library (dll) and I use it in my VB project. I works just as well as if it was in a C# project, there are couple of edits needed due to case issues, but thatís it. Within 1 hour I had the full OpenGL implimenation at my fingure tips!!
Of course you will need to move to VS 2005, but this is a free download from Microsoft
Hope this is of help
12-30-2005, 01:44 AM
Oh well, 4 years later is better than never I suppose...
12-30-2005, 09:27 AM
Hah, I didn't even realize this thread was that old until sqrt[-1] pointed that out. :)
Hmm, this thread was going on around april/may of 2001...I was just finishing (or just finshed) my second semester of college! :D
12-30-2005, 12:00 PM
How embarrassing!! I swear this thread was at the top of the list when I replied, but now Iím thinking I was looking at some search results!!
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.