Cleaning window managers for consistency.
This commit is contained in:
parent
5d984aa61d
commit
392a2b7889
28 changed files with 452 additions and 325 deletions
67
src/windows/ui_interfaces/x11/XcbGlWindowInterface.cpp
Normal file
67
src/windows/ui_interfaces/x11/XcbGlWindowInterface.cpp
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue