Cleaning window managers for consistency.

This commit is contained in:
James Grogan 2022-11-12 15:34:54 +00:00
parent 5d984aa61d
commit 392a2b7889
28 changed files with 452 additions and 325 deletions

View file

@ -0,0 +1,67 @@
#include "XcbGlWindowInterface.h"
#include "OpenGlInterface.h"
#include "XcbGlInterface.h"
#include "FileLogger.h"
#include <GL/gl.h>
XcbGlWindowInterface::XcbGlWindowInterface(XcbGlInterface* glInterface)
: mGlInterface(glInterface),
mDrawable(),
mWindow()
{
}
XcbGlWindowInterface::~XcbGlWindowInterface()
{
if (mWindow)
{
destroyWindow();
}
}
void XcbGlWindowInterface::draw()
{
OpenGlInterface::draw();
swapBuffers();
}
void XcbGlWindowInterface::swapBuffers()
{
glXSwapBuffers(mGlInterface->getDisplay(), mDrawable);
}
bool XcbGlWindowInterface::initialize(xcb_window_t window)
{
if (mWindow)
{
return true;
}
/* Create GLX Window */
mWindow = glXCreateWindow(mGlInterface->getDisplay(), mGlInterface->getConfig(), window, 0);
if (!mWindow)
{
glXDestroyContext(mGlInterface->getDisplay(), mGlInterface->getContext());
MLOG_ERROR("glXCreateWindow failed");
return false;
}
mDrawable = mWindow;
/* make OpenGL context current */
if (!glXMakeContextCurrent(mGlInterface->getDisplay(), mDrawable, mDrawable, mGlInterface->getContext()))
{
glXDestroyContext(mGlInterface->getDisplay(), mGlInterface->getContext());
MLOG_ERROR("glXMakeContextCurrent failed");
return false;
}
return true;
}
void XcbGlWindowInterface::destroyWindow()
{
glXDestroyWindow(mGlInterface->getDisplay(), mWindow);
}