簡體   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