object reference not set to instance of object on a static method call
so im trying to use an opengl binding package (Veldrid.OpenGLBinding) but, when i call any of the methods, it says "Object reference not set to an instance of an object". I'm guessing I'm not using it right but it has absolutely zero documentation so I'm lost
37 Replies
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
I tried switching to OpenGL.NET and same issue
GL.ClearColor throws this error
are you in release mode?
also we usually use
silk.NET
(Most Recommended) or OpenTK
i didnt wanna use either of those because they lock you into their windowing system that i dont like
i wanted to just use glfw windowing directly
and it doesnt work in debug nor release mode
lock you into their windowing system
?you know, extend IWindow, all your code goes in OnUpdateFrame, OnRenderFrame, etc
ah
i just wanted a more c style glfw setup
never used OpenGL.NET so no idea
do you know of anything that doesnt lock you into the windowing system
i thought silk would work since it had glfw bindings but it didnt have any opengl bindings i could use
did you follow the tutorial exactly? perhaps you missed something
yeah, ithink
found some code in so
perhaps you need to initialize it this way
where did you find that?
stack overflow
could you link it
my glfw might be the problem (somehow?? idk)
Stack Overflow
How Do I Initialize OpenGL.NET with GLFW.Net?
I am trying to use OpenGL and GLFW in C#. I Have Installed NuGet Packages for GLFW.Net and OpenGL.Net. What I cannot for my life figure out, is how do I setup the context for OpenGL.Net with GLFW.N...
ur issue probably is, it doesnt know which window to use ClearColor on
this is what ive got now
same crash
GL.Initialize();
Glfw.MakeContextCurrent(window);
but the code calls
Glfw.MakeContextCurrent(window);
before GL.Initialize();
in the stack overflow pagethe solution doesnt
also
somehow, a different overload of clearcolor fixes it
if i use float,float,float,float instead of nint, nint, nint, nint
it works
??
okayt then
nint or int?
nint
dont know exactly what that is
thats unsafe, the overload is probably meant for something else
nint is IntPtr
i figured
or simply a pointer like in C
thats why i tried the different overload
yeah the color values are normalized
0 to 1 instead of 0 to 255
IntPtr
is not a pointer
it is a pointer sized integer
Int32
is 32-bits
, Int64
is 64-bits
IntPtr
is ptr-bits
Why not? Silk doesn’t lock you into any windowing system.
silk makes you use its window class, and you can create a window andm ake your own event loop like you can with glfw
but i switched to silk anyways and im still having trouble
no it doesn’t, you can use silk without the windowing class
what trouble are you having?
why is it all unsafe? why arent there functions to upload uniform matices safely?
why do i have to make an unsafe context, get a pointer to the matrix struct, and use that
Any time you’re using anything that isn’t a C# function you are using unsafe, any library that tries to convince you otherwise is lying. Even if you don’t have to use the unsafe keyword, make no mistake it is unsafe. You shouldn’t try to hide from it just because it has a scary name. You are leaving the scary of the .NET runtime.
however, we do provide overloads for using refs, so you could for example take a ref to the first matrix member instead
The tutorials do not use these overloads tmk, they predate the overloads existence and we didn’t feel like it was a high priority to change them.
how can i get this ref to the first member?
nvm i just bit my tongue and used pointers