Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GL_ARB_bindless_texture Object reference not set #168

Open
Rosux opened this issue Apr 18, 2024 · 1 comment
Open

GL_ARB_bindless_texture Object reference not set #168

Rosux opened this issue Apr 18, 2024 · 1 comment

Comments

@Rosux
Copy link

Rosux commented Apr 18, 2024

I want to use bindless textures but any attempt at calling a bindless_texture method results in this error and then just crashes the program:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at OpenGL.Gl.GetTextureHandleARB(UInt32 texture)

I cant find any reason as to why this happens since my extensions does include the GL_ARB_bindless_texture.

code i used:

uint textureId = Gl.GenTexture();`
Gl.BindTexture(TextureTarget.Texture2d, textureId);

Gl.TexImage2D(TextureTarget.Texture2d, 0, InternalFormat.Rgba, 2, 2, 0, PixelFormat.Rgba, PixelType.UnsignedByte, new byte[] {0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 255});

Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMagFilter, Gl.NEAREST);
Gl.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMinFilter, Gl.NEAREST);

Gl.GetTextureHandleARB(textureId);

GLFW initialization settings:

Glfw.WindowHint(Hint.ClientApi, ClientApi.OpenGL);
Glfw.WindowHint(Hint.ContextVersionMajor, 4);
Glfw.WindowHint(Hint.ContextVersionMinor, 6);
Glfw.WindowHint(Hint.OpenglProfile, Profile.Compatibility);
Glfw.WindowHint(Hint.Doublebuffer, true);

my question is, is this method implemented? am i missing something?

@luca-piccioni
Copy link
Owner

The method is simply is (as almost all public methods relative to GL calls) a wrapper for a function pointer to the underlying OpenGL driver.

If you get a NullReferenceException in these cases, it means that the driver is not offering a function pointer for that extension, for the current OpenGL context. This mean that different OpenGL context may return a different set of function pointers.

I bet that setting up a compatibility profile for the OpenGL context don"t allow you to use bindless textures. Try to initialize a core profile instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants