LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Is it possible to retrieve an opengl context from *nix the command line? (https://www.linuxquestions.org/questions/programming-9/is-it-possible-to-retrieve-an-opengl-context-from-%2Anix-the-command-line-710061/)

FragBoog 03-08-2009 12:19 PM

Is it possible to retrieve an opengl context from *nix the command line?
 
Hi all,

I am struggling to find an answer or example on how opengl is linked into linux. In my past windows experience, 3d scenes are tied to pre-created win32 windows, but is this necessary on NIX platforms? Is it requiered to load an xwindow flavor in order to gain this render context?

Any links to examples or articles and the like will be much appreciated.

I realize this is a noobie question, but it felt like it fit more in the programming section than the newbie section. Thanks for your understanding.

Goal - Recently as a side project I have toyed with the notion of making a small, practically instant on computer whose sole purpose is to run one 3d graphics application. The speed and size portion seems to be a perfect fit for a flavor of linux, especially if you compile your own core and don't care about network sound, etc...

Background - New to *nix, but it seems like a worthwhile challenge. I have several years experience programming DirectX, a few years with OpenGl and a very strong C/C++ background. I am also the type who prefers to write as much from scratch as possible, and usually use graphics libraries as more pure interfaces (ex. gl rather than glut for windows.)

-FragBoog

ErV 03-09-2009 11:42 AM

Quote:

Originally Posted by FragBoog (Post 3468788)
Hi all,

I am struggling to find an answer or example on how opengl is linked into linux. In my past windows experience, 3d scenes are tied to pre-created win32 windows, but is this necessary on NIX platforms? Is it requiered to load an xwindow flavor in order to gain this render context?

You should search for something like "using OpenGL on X Window system".
Or just take xscreensaver package and tear apart one of OpenGL demos.
As far as I can tell contexts are created by glxCreateContext, and rest of operations are handed by other functions with "glx" prefixes (glxSwapBuffers, etc). See full reference here: http://www.opengl.org/sdk/docs/man/

Quote:

Originally Posted by FragBoog (Post 3468788)
Goal - Recently as a side project I have toyed with the notion of making a small, practically instant on computer whose sole purpose is to run one 3d graphics application.

I think the simplest way to do it will be to run X server with just one application. This is because (as far as I know) ATI/NVidia proprietary drivers for OpenGL are made to be used with X.

Another option is to use Mesa3D library, but there is a problem - library works on CPU only. Which means it will be 10..50 times slower than hardware-accelerated OpenGL. This library is useful, for example, when you want to render scene with GLSL shaders on machine that doesn't have OpenGL 2.0 support, but rendering will be seriously slow when compared to hardware-accelerated OpenGL. For example, with GLSL shader speed difference will be 0.5("half") FPS (Mesa3D) vs 20..30(Hardware accelerated OpenGL), and without using shaders(fixed-function opengl) difference will be 70 FPS(Mesa3D) versus 700 FPS(Hardware Accelerated OpenGL)- on VERY simple scenes. Another problem is that Mesa3D isn't OpenGL certified, so you might run into bugs.

Anyway, I recommend to avoid all platfrom-dependant stuff and use SDL library from beginning. This way you'll be able to use OpenGL on any platform where SDL supports it. Examples can be found found in SDL documentation directory (/usr/doc/SDL-1.2.13/html on my system) once SDL is installed.

FragBoog 03-10-2009 11:22 PM

That's just the type of direction I was looking for. Thank you very much. =)

-FragBoog

theNbomr 03-11-2009 09:39 AM

Not sure if I'm interpreting your question correctly, but it sounds like you are trying to use OpenGL without an existing 'real' X server. If so, you may be able to use Xvfb, which requires no physical graphics hardware, but provides a X server interface to support X-based applications. The resulting screen graphics are accessible as a pixmap for saving to files or display on real hardware.
--- rod.

FragBoog 03-14-2009 02:17 AM

Yes, I was also wondering if it was possible to use/obtain an opengl context without loading an XWin scheme. It sounds as though what I thought of or saw as XWin is actually an Xserver/Xclient architecture, but i will need to spend time looking into this.

To use a very poor analog, I was curious if an opengl context can be obtained from Dos, without having to load Windows. In an effort to speed boot times, and avoid loading the rest of the x* stuff, i was looking towards launching my graphics app from the command line.

Xvfb sound very interesting but i need to spend more time looking into it. With luck it will fit my needs.

Thanks for your time and advice. =)
-FragBoog

ErV 03-14-2009 05:20 AM

Quote:

Originally Posted by FragBoog (Post 3475064)
To use a very poor analog, I was curious if an opengl context can be obtained from Dos, without having to load Windows.

Well, as you probably know, OpenGL standard doesn't deal with context at all. They are platform-dependant extensions. So if there will be OpenGL implementation for "dos", you will be able to use OpenGL there. If you really want OpenGL under dos, you could try compiling Mesa3D using djgpp - this might or might not be possible: http://www.delorie.com/djgpp/v2faq/faq10_4.html
But you still won't get hardware acceleration.


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