繁体   English   中英

OpenGL EGL eglGetDisplay 不断返回 EGL 错误 0x3008(EGL_BAD_DISPLAY)

[英]OpenGL EGL eglGetDisplay keeps return EGL error 0x3008(EGL_BAD_DISPLAY )

我的 ubuntu 版本是16.04 ,我首先安装了mesa-common-dev, libgl1-mesa-dev, libglm-dev, libegl1-mesa-dev. 然后我安装了支持 opengl 的NVIDIA-Linux-x86_64-440.64.run

但是当我尝试运行一个玩具示例时,我不断收到此错误main: Assertion display != EGL_NO_DISPLAY failed

/* Compile with gcc -g3 -o example example.c -lX11 -lEGL */

#include <assert.h>
#include <stdio.h>
#include <EGL/egl.h>
#include <EGL/eglplatform.h>

void printEGLError();

int main(void) {
  Display* x_display = XOpenDisplay(NULL);
  EGLDisplay display = eglGetDisplay(x_display);
  // EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  assert(display != EGL_NO_DISPLAY);

  EGLint major, minor;
  eglInitialize(display, &major, &minor);
  char *string = eglQueryString(display, EGL_CLIENT_APIS);
  assert(string);

  printf("%s\n", string);

  return 0;
}

/* Use printEGLError to show a description of the last EGL Error.
  The descriptions are taken from the eglGetError manual */
#define ERROR_DESC(...) fprintf(stderr, "%s\n", __VA_ARGS__); break

void printEGLError() {

  switch(eglGetError()) {

  case(EGL_SUCCESS):
    ERROR_DESC("The last function succeeded without error.");
  case(EGL_NOT_INITIALIZED):
    ERROR_DESC("EGL is not initialized, or could not be initialized, for the specified EGL display connection.");
  case(EGL_BAD_ACCESS):
    ERROR_DESC("EGL cannot access a requested resource (for example a context is bound in another thread).");
  case(EGL_BAD_ALLOC):
    ERROR_DESC("EGL failed to allocate resources for the requested operation.");
  case(EGL_BAD_ATTRIBUTE):
    ERROR_DESC("An unrecognized attribute or attribute value was passed in the attribute list.");
  case(EGL_BAD_CONTEXT):
    ERROR_DESC("An EGLContext argument does not name a valid EGL rendering context.");
  case(EGL_BAD_CONFIG):
    ERROR_DESC("An EGLConfig argument does not name a valid EGL frame buffer configuration.");
  case(EGL_BAD_CURRENT_SURFACE):
    ERROR_DESC("The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid.");
  case(EGL_BAD_DISPLAY):
    ERROR_DESC("An EGLDisplay argument does not name a valid EGL display connection.");
  case(EGL_BAD_SURFACE):
    ERROR_DESC("An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.");
  case(EGL_BAD_MATCH):
    ERROR_DESC("Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).");
  case(EGL_BAD_PARAMETER):
    ERROR_DESC("One or more argument values are invalid.");
  case(EGL_BAD_NATIVE_PIXMAP):
    ERROR_DESC("A NativePixmapType argument does not refer to a valid native pixmap.");
  case(EGL_BAD_NATIVE_WINDOW):
    ERROR_DESC("A NativeWindowType argument does not refer to a valid native window.");
  case(EGL_CONTEXT_LOST):
    ERROR_DESC("A power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering. ");
  }
}

更多信息:我的显卡是Titan Xp ,我尝试运行sudo servide lightdm stop并删除所有可能的远程桌面软件。 但问题仍然存在。 任何人都可以帮忙吗?

对于那些可能对此问题感到困惑的人,只需unset DISPLAY 这可能会节省您的时间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM