LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-28-2012, 06:15 AM   #1
King_DuckZ
Member
 
Registered: Nov 2009
Location: Rome, IT
Distribution: Sabayon
Posts: 61

Rep: Reputation: 2
Question 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...
 
Old 11-29-2012, 12:00 AM   #2
prushik
Member
 
Registered: Mar 2009
Location: South Korea
Distribution: Lubuntu, BetterLinux
Posts: 364

Rep: Reputation: 28
Quote:
Originally Posted by King_DuckZ View Post
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?
 
Old 11-29-2012, 08:00 AM   #3
King_DuckZ
Member
 
Registered: Nov 2009
Location: Rome, IT
Distribution: Sabayon
Posts: 61

Original Poster
Rep: Reputation: 2
Lightbulb

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

Last edited by King_DuckZ; 11-29-2012 at 08:17 AM.
 
  


Reply

Tags
c++, opengl


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphic card device file? fhleung Linux - Hardware 1 03-22-2006 03:59 AM
Graphic card device file? fhleung Linux - Hardware 4 03-21-2006 06:32 PM
Detecting 3D acceleration support for Graphic Device kushalkoolwal Debian 5 10-08-2005 01:20 PM
Package to read graphic file - wb satimis *BSD 0 05-07-2004 02:54 AM
graphic file manager crashmeister Linux - Software 0 09-03-2002 08:54 AM


All times are GMT -5. The time now is 10:04 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration