# Headless OpenGL Rendering using ssh and X11 forwarding

**URL:** <https://community.khronos.org/t/headless-opengl-rendering-using-ssh-and-x11-forwarding/109508>\
**Category:** OpenGL: Advanced Coding\
**Created:** [March 7, 2023, 8:27pm UTC](https://community.khronos.org/t/headless-opengl-rendering-using-ssh-and-x11-forwarding/109508 "2023-03-07T20:27:15Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![oglnewbie](https://community.khronos.org/letter_avatar_proxy/v4/letter/o/3be4f8/32.png) [@oglnewbie](https://community.khronos.org/u/oglnewbie)\
**Post date:** [March 7, 2023, 8:27pm UTC](https://community.khronos.org/t/headless-opengl-rendering-using-ssh-and-x11-forwarding/109508/1 "2023-03-07T20:27:15Z")

</div>

Please help,

I have been going around and around with this problem but cannot seem to make any headway. I hope that one of you OpenGL EGL experts can help. 🙂

I have created a program that uses OpenGL EGL (version 1.5) with OpenGL 3 that successfully renders an offscreen triangle and saves it to an image file (PNG) when I **ssh** _without_ X11 forwarding on my Linux (Ubuntu 22.04) machine.

However when I try the same thing using **ssh** _with_ X11 forwarding enabled I get the following EGL error when I call **eglInitialize(…)**: 12290 (I _think_ is **EGL\_BAD\_ACCESS** ).

This seems really weird and I hope it is something simple that I am just not currently seeing.

I really like using OpenGL with EGL but need a way to remedy this situation if possible. Is there a way for EGL to determine if X11 forwarding is being employed and to ignore it or some other solution?

The snippet of relevant C++ code follows, with area where error occurs marked:

```auto
#include <iostream>
#include <cstdlib>

#include <EGL/egl.h>

#define EGL_EGLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
#include <EGL/eglext.h>
#include <GL/gl.h>
...
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if(display == EGL_NO_DISPLAY) {
    std::cerr << "Failed to get EGL display: " << eglGetError() << std::endl;
    exit(EXIT_FAILURE);
}
EGLint major;
EGLint minor;
if(eglInitialize(display, &major, &minor) == EGL_FALSE) {
    // ERROR 12290 is generated here
    std::cerr << "Failed to initialize EGL: " << eglGetError() << std::endl;
    exit(EXIT_FAILURE);
}
...

```

Any help would be greatly appreciated.

---

_[View the full topic](https://community.khronos.org/t/headless-opengl-rendering-using-ssh-and-x11-forwarding/109508)._
