LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Getting the graphic device file name (https://www.linuxquestions.org/questions/programming-9/getting-the-graphic-device-file-name-4175439114/)

King_DuckZ 11-28-2012 06:15 AM

Getting the graphic device file name
 
Hello, I'm using glXCreateNewContext() in my c++ program to create a new openGL context. On my system ls -l on the device file /dev/nvidiactl gives:

crw-rw---- 1 root video 195, 255 27 nov 15.36 /dev/nvidiactl

I don't belong to the video group, so I'd like to add some nice error message to the user when they don't have access to the video device. If I run my program, I see the string "NVIDIA: could not open the device file /dev/nvidiactl (Permission denied)." on the standard output but in the code everything goes well up to the call to glDrawElements(), where I get a segmentation fault. That is, I can't find a way to catch the problem and stop the program before it tries to draw.

Getting the path /dev/nvidiactl programmatically would be nice, so that I could manually check for permissions, so if you know how to do that it would help me a lot. Or if you know of any better solution as well...

prushik 11-29-2012 12:00 AM

Quote:

Originally Posted by King_DuckZ (Post 4838701)
Hello, I'm using glXCreateNewContext() in my c++ program to create a new openGL context. On my system ls -l on the device file /dev/nvidiactl gives:

crw-rw---- 1 root video 195, 255 27 nov 15.36 /dev/nvidiactl

I don't belong to the video group, so I'd like to add some nice error message to the user when they don't have access to the video device. If I run my program, I see the string "NVIDIA: could not open the device file /dev/nvidiactl (Permission denied)." on the standard output but in the code everything goes well up to the call to glDrawElements(), where I get a segmentation fault. That is, I can't find a way to catch the problem and stop the program before it tries to draw.

Getting the path /dev/nvidiactl programmatically would be nice, so that I could manually check for permissions, so if you know how to do that it would help me a lot. Or if you know of any better solution as well...

glXCreateNewContext() should return NULL if it fails. So all you have to do is check to see if your context equals NULL, and if it does, then you know there is some problem. Right? or am I not understanding your question?

King_DuckZ 11-29-2012 08:00 AM

It returns a valid pointer, unfortunately. I think it tries to fall back to non direct mode (in fact glXIsDirect(parDisplay, *context) gives false), but then it crashes on some draw call. Someone told me there might be an error in some index buffer that gets skipped by the video card but that causes my game to crash in non direct mode. I'm still not convinced since Amnesia the game crashes as well if I don't belong to the video group. However, glxgears works just fine.
I've found this page: http://src.chromium.org/viewvc/chrom...evision=129314 where they specifically check the hardcoded path "/dev/nvidiactl" if the vendor id is nvidia's one. Right now I'm going down that path. So, I kinda found the answer, but I'm still wondering if this is a driver's bug or what.

Edit: I also checked Psychonauts, which triggers an assert:
ERROR: Assert in /home/icculus/projects/psychonauts/Source/CommonLibs/DFGraphics/OpenGLGraphics.cpp, line 2042


All times are GMT -5. The time now is 06:14 PM.