Skip to content

Commit

Permalink
Headless context debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Apr 23, 2021
1 parent 734003c commit 806f261
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/HeadlessOpenGLContext.cpp
Expand Up @@ -106,6 +106,13 @@ HGLRC HeadlessOpenGLContext::_tempContext;

#elif defined(POSIX)

// Get an environment variable as a string
std::string strenv(const std::string& key)
{
const char* v = getenv(key.c_str());
return v ? std::string(v) : std::string();
}

class HeadlessOpenGLContext :
public IGLContext
{
Expand All @@ -125,9 +132,13 @@ class HeadlessOpenGLContext :
auto glxcreatepixelbuffer = (PFNGLXCREATEPBUFFERPROC)glXGetProcAddress((GLubyte*)"glXCreatePbuffer");
auto glxmakecurrent = (PFNGLXMAKECONTEXTCURRENTPROC)glXGetProcAddress((GLubyte*)"glXMakeContextCurrent");

auto displayName = strenv("DISPLAY");

std::cout << "DISPLAY environment variable = '" << displayName << "'" << std::endl;

std::cout << "XOpenDisplay..." << std::endl;

_display = XOpenDisplay(nullptr);
_display = XOpenDisplay(displayName.empty() ? ":0" : displayName.c_str());

std::cout << "XOpenDisplay returned: " << _display << std::endl;

Expand Down

0 comments on commit 806f261

Please sign in to comment.