Reputation: 1167
I am trying to make a opengl context with glx on a debian server. The problem is that I can't make the display and it seems the reason is because there is no X server running and I cannot start an X server with sudo startx
because it says there are no screens.
The server is offsite and there is no way of adding a display onto it and I need to make an opengl application that can run on it and render things and some stuff.
This is my current c++ test code:
#include <cstdio>
#include <X11/Xutil.h>
#include <GL/gl.h>
#include <GL/glx.h>
typedef GLXContext (*glXCreateContextAttribsARBProc) (Display*, GLXFBConfig, GLXContext, Bool, const int*);
typedef Bool (*glXMakeContextCurrentARBProc) (Display*, GLXDrawable, GLXDrawable, GLXContext);
static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = NULL;
static glxMakeContextCurrentARBProc glxMakeContextCurrentARB = NULL;
int main(){
printf("tacos\n");
glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB((const GLubyte*) "glXCreateContextAttribsARB");
glXMakeContextCurrentARB = (glXMakeContextCurrentARBProc) glXGetProcAddressARB((const GLubyte*) "glXMakeContextCurrent");
[ ... ] // Check if the two funcs are null, they are not when I run the program.
const char* display_name = NULL;
Display* display = XOpenDisplay(display_name);
if (display == NULL){
printf("failed to open display\n"); // outputs this and ends program
return 0;
}
printf("Great Success\n"); // does not get this far ^
return 0;
}
I check if X Server is running with this:
if ! xset q &>/dev/null; then
echo "No X server at \$DISPLAY [$DISPLAY]" >&2;
fi
Which outputs the following:
No X server at $DISPLAY []
Which leads me to think the $DISPLAY var is not set, though I don't know how to check if it is set.
I then ran 'sudo startx' and got the following:
Fatal server error:
(EE) no screens found(EE)
Upvotes: 0
Views: 531
Reputation: 162164
Well, GLX is the X11 OpenGL transport protocol. So you absolutely need an X server running (do you have a GPU at the off-site location available?).
The later versions of the Xorg server in the default configuration will refuse to start if no monitors are connected. However using the right xorg.conf placed in /etc/X11 and with the right command line options you can coax the server into starting even then. However you will either have to start a redirecting composite manager or rewrite your OpenGL programs to use a Framebuffer Objects, otherwise you'll not get a framebuffer to draw to (I highly recommend going the Framebuffer Object route).
Upvotes: 2