【发布时间】:2015-01-31 16:55:39
【问题描述】:
我正在尝试在 debian 服务器上使用 glx 创建 opengl 上下文。问题是我无法进行显示,原因似乎是因为没有运行 X 服务器,我无法使用 sudo startx 启动 X 服务器,因为它说没有屏幕。
服务器在异地,无法在其上添加显示,我需要制作一个可以在其上运行并渲染东西和一些东西的 opengl 应用程序。
这是我当前的 c++ 测试代码:
#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;
}
我检查 X Server 是否正在运行:
if ! xset q &>/dev/null; then
echo "No X server at \$DISPLAY [$DISPLAY]" >&2;
fi
输出如下:
No X server at $DISPLAY []
这让我认为 $DISPLAY 变量未设置,但我不知道如何检查它是否已设置。
然后我运行“sudo startx”并得到以下信息:
Fatal server error:
(EE) no screens found(EE)
【问题讨论】:
标签: c++ linux opengl debian x11