Is it possible to retrieve an opengl context from *nix the command line?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.)
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
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.