C
C#

object reference not set to instance of object on a static method call

object reference not set to instance of object on a static method call

Nnut11/21/2023
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
TTheRanger11/21/2023
$details
MMODiX11/21/2023
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)
Nnut11/21/2023
public void Run()
{


GL.Initialize();
Glfw.Init();

window = new Window(800, 600, "W");

GL.ClearColor(255, 255, 255, 255);

while (!window.ShouldClose())
{
window.Clear();

window.SwapBuffers();
Glfw.PollEvents();
}
}
public void Run()
{


GL.Initialize();
Glfw.Init();

window = new Window(800, 600, "W");

GL.ClearColor(255, 255, 255, 255);

while (!window.ShouldClose())
{
window.Clear();

window.SwapBuffers();
Glfw.PollEvents();
}
}
I tried switching to OpenGL.NET and same issue GL.ClearColor throws this error
Nnut11/21/2023
No description
TTheRanger11/21/2023
are you in release mode? also we usually use silk.NET(Most Recommended) or OpenTK
Nnut11/21/2023
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
TTheRanger11/21/2023
lock you into their windowing system ?
Nnut11/21/2023
you know, extend IWindow, all your code goes in OnUpdateFrame, OnRenderFrame, etc
TTheRanger11/21/2023
ah
Nnut11/21/2023
i just wanted a more c style glfw setup
TTheRanger11/21/2023
never used OpenGL.NET so no idea
Nnut11/21/2023
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
TTheRanger11/21/2023
did you follow the tutorial exactly? perhaps you missed something
Nnut11/21/2023
yeah, ithink
TTheRanger11/21/2023
found some code in so
Glfw.Init();
GLFWwindow window = Glfw.CreateWindow(1080, 720, "Yeet", null, null);
Glfw.MakeContextCurrent(window);
Gl.Initialize();
Glfw.Init();
GLFWwindow window = Glfw.CreateWindow(1080, 720, "Yeet", null, null);
Glfw.MakeContextCurrent(window);
Gl.Initialize();
perhaps you need to initialize it this way
Nnut11/21/2023
where did you find that?
TTheRanger11/21/2023
stack overflow
Nnut11/21/2023
could you link it my glfw might be the problem (somehow?? idk)
TTheRanger11/21/2023
https://stackoverflow.com/questions/61318104/how-do-i-initialize-opengl-net-with-glfw-net ur issue probably is, it doesnt know which window to use ClearColor on
Nnut11/21/2023
Glfw.Init();
Window window = Glfw.CreateWindow(1080, 720, "Yeet", GLFW.Monitor.None, Window.None);
GL.Initialize();
Glfw.MakeContextCurrent(window);
GL.ClearColor(255, 255, 255, 255);

while (true)
{
Glfw.PollEvents();
}
Glfw.Init();
Window window = Glfw.CreateWindow(1080, 720, "Yeet", GLFW.Monitor.None, Window.None);
GL.Initialize();
Glfw.MakeContextCurrent(window);
GL.ClearColor(255, 255, 255, 255);

while (true)
{
Glfw.PollEvents();
}
this is what ive got now same crash
TTheRanger11/21/2023
GL.Initialize(); Glfw.MakeContextCurrent(window); but the code calls Glfw.MakeContextCurrent(window); before GL.Initialize(); in the stack overflow page
Nnut11/21/2023
the 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
TTheRanger11/21/2023
nint or int?
Nnut11/21/2023
nint dont know exactly what that is
TTheRanger11/21/2023
thats unsafe, the overload is probably meant for something else nint is IntPtr
Nnut11/21/2023
i figured
TTheRanger11/21/2023
or simply a pointer like in C
Nnut11/21/2023
thats why i tried the different overload
TTheRanger11/21/2023
yeah the color values are normalized 0 to 1 instead of 0 to 255
Ttannergooding11/21/2023
IntPtr is not a pointer it is a pointer sized integer Int32 is 32-bits, Int64 is 64-bits IntPtr is ptr-bits
PPerksey11/21/2023
Why not? Silk doesn’t lock you into any windowing system.
Nnut11/21/2023
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
PPerksey11/21/2023
no it doesn’t, you can use silk without the windowing class what trouble are you having?
Nnut11/21/2023
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
PPerksey11/21/2023
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.
Nnut11/22/2023
how can i get this ref to the first member? nvm i just bit my tongue and used pointers

Looking for more? Join the community!

C
C#

object reference not set to instance of object on a static method call

Join Server
Want results from more Discord servers?
Add your server
Recommended Posts
Web API model classesI'm coding a webshop using ASP.NET Core Web API for the backend and Next.js for the frontend. I'm deInvalidate JWT-Tokens on logout and password change.I have an ASP.net Web api that handles user interaction. For authentification I use JWT Tokens. I reDynamically enable/disable a route in ASP.NET 7?Is there a way to dynamically enable/disable a route in ASP.NET 7? I'd like to be able to enable/dis✅ I keep getting Error CS5001 and CS0028, how do i get rid of themin CS5001 it says Program does not contain a static "Main" method suitable for an entry point and inStruct with explicit layoutHi, I am using Wintab and I am trying to make packet struct, but I have some problem. In some situatExtending custom WPF controlWhat are my options to extend this TimePicker list element to full height that shows all items? I'm Discord.Net + MagicOnion, hehehHey! So I am working on a discord bot that I want to intergrate into a server using websockets, I fA question for my c# winforms projecthello guys, i have a question about my c# winforms project. So : I have 2 Projects the first ProjecYO I NEED HELP writing a code need advice not for u to write it for mewrite me a c# program that get 3 latters and tell if they are by the order like abc if they are backBlazor ServicesI dont know too much blazor, but I have a .cs file in a /Settings folder, in which I would like to aHow to optimize this?I have following: ```cs using System; namespace SquareCalculus { internal class FigureTriangle In VSCode, SDK not Recognized on ChromeOSHi. I just installed the .NET SDK and the Runtime by following the instructions for Ubuntu on the MiNito.AsyncEx vs DotNext.ThreadingWe're currently searching for a nice AsyncAutoResetEvent implementation. We found two suitable impleSequential BlinkersHello everyone! I bought these sequential blinkers that run off an stm32 blue pill board. the only pTrying to use Microsoft.Kiota namespace but not found when importingI am trying to use this method from the Microsoft.Kiota.Abstractions.Extensions namespace: ToFirstChWinUI3 Scheduler CalendarViewhello im trying to make a winui3 calendarview interactive calendar where I can predefine dates in myThe call is ambiguous between the following methods or properties: 'Thread.Thread(ThreadStart)' andi have to upload by filesHelp a noobie out with a simple hangmanHi! New to coding and I need some help to solve this problem. Shall I save the words to a list? AnyC# Image Resizing on Visual Studio CodeI've tried both ``newPic.SizeMode = PictureBoxSizeMode.StretchImage;`` and ``newPic.SizeMode = PictuI'm stuck,visual studio 22, I need help making my invaders/enemies move left to right then downI’m trying to get my invaders/enemies to move left to right then down like in the game space invader