Jump to content
  • Advertisement
Sign in to follow this  
Knight Chat X

OpenGL How do I use Multiple Textures in OpenGL in VB.NET???

This topic is 3922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Anyone know how to do multiple textures in OpenGL using VB.Net and get this to work? All I can find right now on using multiple textures is in C++. I'm trying to apply multiple textures to geometry and while setting active texture it gives me error: EntryPointNotFoundException was unhandled. Unable to find an entry point named 'glActiveTextureARB' in DLL 'opengl32.dll'. I'm using NEHE Lesson 22 as an example: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=22 I looked into the OpenGL32.dll and OpenGL.dll in C:\Windows\System32 and it doesn't show glActiveTexture at anywhere in the DLL as a callable function. [Edited by - Knight Chat X on September 25, 2007 4:02:17 AM]

Share this post


Link to post
Share on other sites
Advertisement
On Windows, you have to access everything beyond OpenGL 1.1 as an extension (multitexturing was added to core in 1.3). Read this article if you don't know about extensions, then use either GLee or GLEW to load them.

EDIT: I'm not sure of what you can use to load extensions in VB.NET, there's gotta be something out there though.

Share this post


Link to post
Share on other sites
The TAO framework comes to mind. You should be able to use it from all .NET languages.
http://www.taoframework.com/

Share this post


Link to post
Share on other sites
Quote:
Original post by Kalidor
On Windows, you have to access everything beyond OpenGL 1.1 as an extension (multitexturing was added to core in 1.3). Read this article if you don't know about extensions, then use either GLee or GLEW to load them.

EDIT: I'm not sure of what you can use to load extensions in VB.NET, there's gotta be something out there though.


Thanks, I'll try looking into these and do some more research, I'm trying to do this without using a 3rd party DLL library solution, I can only find C++ and C# source code samples when converted to VB.NET just isn't working, the function pointers are variables and seem like Delegates, I found this and tried it and not working:
http://www.codeproject.com/vb/net/Delegate.asp

The delegate (function pointer) is supposed to have the function address passed off to the variable using AddressOf, in which you can then call the function/method using the variables name and passing any parameters, optionally using Invoke.

C++ TYPE DEFINITION:
typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum target);

Is said to be equivilant to VB.NET's, which defines a type safe, method or function:
Public Delegate Sub PFNGLACTIVETEXTUREARBPROC(ByVal target As Int32)

C++ VARIABLE:
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;

Is said to be equal to VB.NET's variable declaration like so:
Public Shared glActiveTextureARB As PFNGLACTIVETEXTUREARBPROC = Nothing

C++ Assigning Reference to Function/Passing Function Pointer/Function Address to Invokable Variable:

glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");

VB.NET Assign Addresses/References to the Function Pointers:
glActiveTextureARB = wglGetProcAddress("glActiveTextureARB")

-OR-

glActiveTextureARB = AddressOf <FUNCTION POINTER>

See if Multi-Texturing is supported...
If IsNothing(glActiveTextureARB) = True Then MsgBox("Your version of OpenGL does not support multitexturing...", , "Error")

VB.NET's Function Usage would be:
glActiveTextureARB(GL_TEXTURE0_ARB)

-OR-

glActiveTextureARB.Invoke(GL_TEXTURE0_ARB)

2 Other ways to declare the function are:

<Runtime.InteropServices.DllImport("opengl.dll", EntryPoint:="glActiveTextureARB", SetLastError:=True, CharSet:=System.Runtime.InteropServices.CharSet.Unicode, ExactSpelling:=True, CallingConvention:=System.Runtime.InteropServices.CallingConvention.StdCall)> Public Shared Function glActiveTextureARB(ByVal target As Int32) As Long
End Function

-OR-

Declare Auto Function glActiveTextureARB Lib "opengl.dll" (ByVal texture As Int32) As Long

Share this post


Link to post
Share on other sites
Hi,
Anyone knows how to create multitexture in C++.

i am facing a problem to create compressed texture using OpenGL function with only SIS Mirage3 Graphics card, more details regarding the problem is given below:

1) I am using the following opengl funtion to create compressed texture :

glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_ARB,
TextureImage[0]->sizeX,
TextureImage[0]->sizeY, 0,
GL_RGB, GL_BYTE,
TextureImage[0]->data);

2) This function is working fine with graphics cards other than SIS Mirage 3; With SIS Mirage 3 on Vista machine, this function returns GL_INVALID_ENUM value.
3) There is no problem on Vista machine with Intel Graphics card.

I am not getting why is this getting failed? please help me someone, and let me know the architecture to create compressed texture.

--------------------------------------------------------------------------------


Share this post


Link to post
Share on other sites
Quote:
Original post by vandana123
Hi,
Anyone knows how to create multitexture in C++.

i am facing a problem to create compressed texture using OpenGL function with only SIS Mirage3 Graphics card, more details regarding the problem is given below:

1) I am using the following opengl funtion to create compressed texture :

glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_ARB,
TextureImage[0]->sizeX,
TextureImage[0]->sizeY, 0,
GL_RGB, GL_BYTE,
TextureImage[0]->data);

2) This function is working fine with graphics cards other than SIS Mirage 3; With SIS Mirage 3 on Vista machine, this function returns GL_INVALID_ENUM value.
3) There is no problem on Vista machine with Intel Graphics card.

I am not getting why is this getting failed? please help me someone, and let me know the architecture to create compressed texture.

--------------------------------------------------------------------------------


It may be easier to just try to load an already compressed texture into memory that's stored on file on computer already compressed instead of trying to compress it during load, it might be faster and lower your texture load time doing it that way as texture size seems to be slower with larger textures while loading...

Here's something on using compressed textures on OpenGL dunno if will help:
http://www.starcoder.com/wordpress/2007/09/10/using-compressed-textures-in-opengl

If you want to convert image to another format and/or change image settings could use Bitmap, and/or GDI+, etc...

If you want to create multiple size versions automatically in memory use glbuildmipmaps during load instead.

Share this post


Link to post
Share on other sites
Substitute this line: glActiveTextureARB = wglGetProcAddress("glActiveTextureARB")
with glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glActiveTextureARB"), typeof(PFNGLACTIVETEXTUREARBPROC));

This should do the trick, although it requires .Net 2.0.

In any case, I strongly suggest you follow the advise and use a library for this job, like Tao or OpenTK. Do not underestimate the amount of work needed to write such bindings, these libraries have been in development for *years* .

If you still insist, at least consider using a script to automate this job: OpenTK (see sig) contains a tool called 'Bind' which generates OpenGL bindings. Set the parameters you want (like output namespace, class etc) and compile its output into a dll which you can insert into your code. You'll still need to write a small function in VB.Net (about 5-10 lines) that uses reflection to load all extensions, but this will allow you to spend your time in more productive ways (like using OpenGL :) ). I can help if you encounter any problems.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!