mirror of
https://github.com/edubart/otclient.git
synced 2025-06-07 19:34:29 +02:00
Compiling on linux again
This commit is contained in:
parent
adf51f1852
commit
77995a2e88
@ -238,7 +238,7 @@ bool Graphics::selectPainterEngine(PainterEngine painterEngine)
|
||||
if(g_painter)
|
||||
g_painter->unbind();
|
||||
painter->bind();
|
||||
//g_window.setGraphicsContext(painter->getGraphicsContext());
|
||||
g_window.setGraphicsContext(painter->getGraphicsContext());
|
||||
g_painter = painter;
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,7 @@
|
||||
|
||||
#include "graphicscontext.h"
|
||||
|
||||
GraphicsContext::GraphicsContext(const std::string& name)
|
||||
GraphicsContext::GraphicsContext(const std::string& name) :
|
||||
m_name(name)
|
||||
{
|
||||
std::cout << "lal1: \"" << name.c_str() << "\" aa" << std::endl;
|
||||
m_name = name;
|
||||
std::cout << "lal2: \"" << getName().c_str() << "\" aa" << std::endl;
|
||||
}
|
||||
|
@ -25,16 +25,6 @@
|
||||
|
||||
#include "declarations.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
typedef HWND WindowType;
|
||||
typedef HDC DisplayType;
|
||||
#else
|
||||
#include <X11/Xlib.h>
|
||||
typedef Window WindowType;
|
||||
typedef Display *DisplayType;
|
||||
#endif
|
||||
|
||||
class GraphicsContext
|
||||
{
|
||||
public:
|
||||
@ -43,7 +33,7 @@ public:
|
||||
|
||||
std::string getName() { return m_name; }
|
||||
|
||||
virtual void create(WindowType window, DisplayType display) = 0;
|
||||
virtual void create() = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void restore() = 0;
|
||||
|
||||
@ -53,8 +43,6 @@ public:
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
WindowType m_window;
|
||||
DisplayType m_display;
|
||||
|
||||
};
|
||||
|
||||
|
@ -22,45 +22,64 @@
|
||||
|
||||
#include "graphicscontextglx.h"
|
||||
|
||||
|
||||
GraphicsContextGLX::GraphicsContextGLX() :
|
||||
GraphicsContext("GLX")
|
||||
GraphicsContext("GLX"), m_window(dynamic_cast<X11Window&>(g_window))
|
||||
{
|
||||
m_fbConfig = 0;
|
||||
m_glxContext = 0;
|
||||
}
|
||||
|
||||
void GraphicsContextGLX::create(WindowType window, DisplayType display)
|
||||
void GraphicsContextGLX::create()
|
||||
{
|
||||
m_window = window;
|
||||
m_display = display;
|
||||
static int attrList[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_DOUBLEBUFFER, True,
|
||||
GLX_RED_SIZE, 8,
|
||||
GLX_GREEN_SIZE, 8,
|
||||
GLX_BLUE_SIZE, 8,
|
||||
GLX_ALPHA_SIZE, 8,
|
||||
None
|
||||
};
|
||||
|
||||
m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
|
||||
int nelements;
|
||||
m_fbConfig = glXChooseFBConfig(m_window.getDisplay(), m_window.getScreen(), attrList, &nelements);
|
||||
if(!m_fbConfig)
|
||||
g_logger.fatal("Couldn't choose RGBA, double buffered fbconfig");
|
||||
|
||||
m_window.setVisual(glXGetVisualFromFBConfig(m_window.getDisplay(), *m_fbConfig));
|
||||
if(!m_window.getDisplay())
|
||||
g_logger.fatal("Couldn't choose RGBA, double buffered visual");
|
||||
|
||||
m_window.setRootWindow(RootWindow(m_window.getDisplay(), m_window.getVisual()->screen));
|
||||
|
||||
m_glxContext = glXCreateContext(m_window.getDisplay(), m_window.getVisual(), NULL, True);
|
||||
|
||||
if(!m_glxContext)
|
||||
g_logger.fatal("Unable to create GLX context");
|
||||
|
||||
if(!glXIsDirect(m_display, m_glxContext))
|
||||
if(!glXIsDirect(m_window.getDisplay(), m_glxContext))
|
||||
g_logger.warning("GL direct rendering is not possible");
|
||||
}
|
||||
|
||||
void GraphicsContextGLX::destroy()
|
||||
{
|
||||
if(m_glxContext) {
|
||||
glXMakeCurrent(m_display, None, NULL);
|
||||
glXDestroyContext(m_display, m_glxContext);
|
||||
glXMakeCurrent(m_window.getDisplay(), None, NULL);
|
||||
glXDestroyContext(m_window.getDisplay(), m_glxContext);
|
||||
m_glxContext = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsContextGLX::restore()
|
||||
{
|
||||
if(!glXMakeCurrent(m_display, m_window, m_glxContext))
|
||||
if(!glXMakeCurrent(m_window.getDisplay(), m_window.getWindow(), m_glxContext))
|
||||
g_logger.fatal("Unable to set GLX context on X11 window");
|
||||
}
|
||||
|
||||
bool GraphicsContextGLX::isExtensionSupported(const char *ext)
|
||||
{
|
||||
const char *exts = glXQueryExtensionsString(m_display, DefaultScreen(m_display));
|
||||
const char *exts = glXQueryExtensionsString(m_window.getDisplay(), m_window.getScreen());
|
||||
if(strstr(exts, ext))
|
||||
return true;
|
||||
return false;
|
||||
@ -73,7 +92,7 @@ void *GraphicsContextGLX::getExtensionProcAddress(const char *ext)
|
||||
|
||||
void GraphicsContextGLX::swapBuffers()
|
||||
{
|
||||
glXSwapBuffers(m_display, m_window);
|
||||
glXSwapBuffers(m_window.getDisplay(), m_window.getWindow());
|
||||
}
|
||||
|
||||
void GraphicsContextGLX::setVerticalSync(bool enable)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define GRAPHICSCONTEXTGLX_H
|
||||
|
||||
#include <framework/graphics/graphicscontext.h>
|
||||
#include <framework/platform/x11window.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
class GraphicsContextGLX : public GraphicsContext
|
||||
@ -31,7 +32,7 @@ class GraphicsContextGLX : public GraphicsContext
|
||||
public:
|
||||
GraphicsContextGLX();
|
||||
|
||||
void create(WindowType window, DisplayType display);
|
||||
void create();
|
||||
void destroy();
|
||||
void restore();
|
||||
|
||||
@ -43,6 +44,7 @@ public:
|
||||
void setVerticalSync(bool enable);
|
||||
|
||||
private:
|
||||
X11Window& m_window;
|
||||
GLXContext m_glxContext;
|
||||
GLXFBConfig *m_fbConfig;
|
||||
};
|
||||
|
@ -65,16 +65,15 @@ int PlatformWindow::loadMouseCursor(const std::string& file, const Point& hotSpo
|
||||
|
||||
void PlatformWindow::setGraphicsContext(const GraphicsContextPtr& graphicsContext)
|
||||
{
|
||||
// TODO
|
||||
if(m_graphicsContext && m_graphicsContext->getName() == graphicsContext->getName())
|
||||
return;
|
||||
|
||||
if(m_graphicsContext)
|
||||
internalDestroyContext();
|
||||
m_graphicsContext->destroy();
|
||||
|
||||
m_graphicsContext = graphicsContext;
|
||||
internalCreateContext();
|
||||
internalRestoreContext();
|
||||
m_graphicsContext->create();
|
||||
m_graphicsContext->restore();
|
||||
}
|
||||
|
||||
void PlatformWindow::updateUnmaximizedCoords()
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
void Platform::processArgs(std::vector<std::string>& args)
|
||||
{
|
||||
//nothing todo, linux args are already utf8 encoded
|
||||
//nothing to do, linux args are already utf8 encoded
|
||||
}
|
||||
|
||||
bool Platform::spawnProcess(std::string process, const std::vector<std::string>& args)
|
||||
|
@ -44,6 +44,8 @@ X11Window::X11Window()
|
||||
m_minimumSize = Size(600,480);
|
||||
m_size = Size(600,480);
|
||||
m_graphicsContext = GraphicsContextPtr(new GraphicsContextGLX);
|
||||
dump << GraphicsContextPtr(new GraphicsContextGLX())->getName().c_str();
|
||||
dump << (new GraphicsContextGLX())->getName().c_str();
|
||||
|
||||
m_keyMap[XK_Escape] = Fw::KeyEscape;
|
||||
m_keyMap[XK_Tab] = Fw::KeyTab;
|
||||
@ -401,32 +403,13 @@ void X11Window::internalChooseGLVisual()
|
||||
|
||||
m_rootWindow = DefaultRootWindow(m_display);
|
||||
#else
|
||||
static int attrList[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_DOUBLEBUFFER, True,
|
||||
GLX_RED_SIZE, 8,
|
||||
GLX_GREEN_SIZE, 8,
|
||||
GLX_BLUE_SIZE, 8,
|
||||
GLX_ALPHA_SIZE, 8,
|
||||
None
|
||||
};
|
||||
|
||||
int nelements;
|
||||
m_fbConfig = glXChooseFBConfig(m_display, m_screen, attrList, &nelements);
|
||||
if(!m_fbConfig)
|
||||
g_logger.fatal("Couldn't choose RGBA, double buffered fbconfig");
|
||||
|
||||
m_visual = glXGetVisualFromFBConfig(m_display, *m_fbConfig);
|
||||
if(!m_visual)
|
||||
g_logger.fatal("Couldn't choose RGBA, double buffered visual");
|
||||
|
||||
m_rootWindow = RootWindow(m_display, m_visual->screen);
|
||||
#endif
|
||||
}
|
||||
|
||||
void X11Window::internalCreateContext()
|
||||
{
|
||||
m_graphicsContext->create(m_window, m_display);
|
||||
m_graphicsContext->create();
|
||||
}
|
||||
|
||||
void X11Window::internalDestroyContext()
|
||||
|
@ -69,10 +69,16 @@ public:
|
||||
void setVerticalSync(bool enable);
|
||||
void setIcon(const std::string& file);
|
||||
void setClipboardText(const std::string& text);
|
||||
void setVisual(XVisualInfo *visual) { m_visual = visual; }
|
||||
void setRootWindow(const Window& window) { m_rootWindow = window; }
|
||||
|
||||
Size getDisplaySize();
|
||||
std::string getClipboardText();
|
||||
std::string getPlatformType();
|
||||
Window getWindow() { return m_window; }
|
||||
Display *getDisplay() { return m_display; }
|
||||
int getScreen() { return m_screen; }
|
||||
XVisualInfo *getVisual() { return m_visual; }
|
||||
|
||||
protected:
|
||||
int internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot);
|
||||
|
Loading…
x
Reference in New Issue
Block a user