luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

glGenVertexArrays() shows NullReferenceException

linstudionet opened this issue · comments

Hi,

When I run Gl.glGenVertexArrays() on my laptop and my laptop is connected with an extended monitor, this function doesn't report any error. However, if I unplug the monitor and run it again it pops up NullReferenceException 'Object Reference not set to an instance of an object'. I can repro this on your project https://github.com/luca-piccioni/OpenGL.Net/blob/5dad7512bebadfb128ffd388d1f84b42123443c7/Samples/HelloTriangle.WPF/MainWindow.xaml.cs . Just add Gl.GenVertexArray(); under Gl.Clear(ClearBufferMask.ColorBufferBit); and run the program with and without second monitor . Would you like to help me with this?
Capture

Are you running at least OpenGL 3? Which platform?

I am running opengl .net (c#).

Maybe I misunderstand your questions wrong, can you help to clarify that?

When I print Gl.CurrentVersion.ToString(), it shows me: Version=4.6 API=gl.

The way I repro that is by running the HelloTriangle.WPF from your repository and just add Gl.GenVertexArray(); under Gl.Clear(ClearBufferMask.ColorBufferBit).

Okay. This is because I have two graphic cards on my laptop, NVIDIA and INTEL. I disabled my INTEL graphic card so that the computer is forced to use NVIDIA one. This somehow cause error Gl.GenVertexArray(); , and I need to connect put to another monitor to enable opengl. If I enable my INTEL graphic card again everything is fine.