OpenGL on Linux without X11

Hi everyone!

I’m wondering what would be the best approach to code, say a trivial game, on Linux/BSD without relying on the X11 Windowing System?
Suppose I don’t want an X11 window, I will have my application take over the screen.
From what I’ve understood, the way things work now, is as such:

  1. I write code that uses some OpenGL functions.
  2. Thus, I need to include opengl headers
  3. I include the headers and now I want to compile my program.
  4. So then there must be a library that provides GL.h. I believe a popular choice would be Mesa 3D.
  5. I compile my program and link against Mesa3D.
  6. I run the program.

And point 6 is where I am a bit stuck. Will Mesa allow access to the graphics hardware? Does Mesa know about the hardware at all, or is it relying on some other library to deal with that, like for example DRI?
So far I’m thinking DRI takes care of the hardware and Mesa takes care of OpenGL. But how do they work together?
And is DRI usable without an X11 server?
What about SDL? Is it a replacement for Mesa 3D or DRI? Or is SDL using/can use Mesa to do its drawing?
I guess I need a brief explanation about what libraries to use in order to be able to draw graphics without X11.
This whole Mesa/DRI/SDL(?) seems complicated and overwhelming, because all I want is to run an application that will draw something on the screen.
I still remember the good old Pascal/C days where I would specify #include <graphics.h> or ‘uses graph;’ and then call initgraph() to initialize the graphics. And then I could draw on that screen to my heart’s content.
I am of course looking to use 3D acceleration and OpenGL, and if I could get (roughly) the same simplicity and low-level access, I’ll be more than happy.

If you have any suggestions or corrections to the way I’m looking at things, please do reply. Any links and explanations will be appreciated!

Thanks!

P.S.: Where does the NVidia / ATI driver fit? Are they dependant on the X Server? Does NVidia supply any header files for us to use their driver?

AFAIK, Mesa3D needs X11. DRI is a X11 concept anyway. I am not aware of any hardware-accelerated *nix GL implementation that won’t use X11 - for obvious reasons. So, do as everyone else, use a fullscreen X window :slight_smile:

Thanks for the answer!
But, unfortunately, X is not an option.
Surely X is not the only way to draw on the screen in Linux?

Hey, don’t scare the guy :slight_smile:

try this, it supports full hardware acceleration:
http://www.directfb.org

…and as a bonus, Isn’t fully related, but interesting anyway:
http://www.rocklyte.com/athene/index.html:

There would be no problem in hardware-accelerating the 2d graphics outside of X, but does DirectFB provide OpengL support with hardware acceleration?

There has been some work in Mesa/DRI to make OpenGL work without X. It uses EGL for initialization and context creation (I think it’s a Khronos standard initially created for use with OpenGL ES).
AFAIK the main goal is to make X work on top of OpenGL (so it automatically gets hardware acceleration from the OpenGL driver, no longer needing a separate 2D driver).

I don’t think it’s production ready, but you might want to see for yourself. AFAIR it was working at some point with some drivers including the radeon driver.

Philipp

http://linux.softpedia.com/progScreenshots/DirectFBGL-Screenshot-18610.html

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.