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)