mirror of https://github.com/AxioDL/metaforce.git
Minor visigen cleanup and GLX fix
This commit is contained in:
parent
54d2759ace
commit
ae48196c3f
|
@ -27,7 +27,7 @@
|
||||||
#define MWM_FUNC_CLOSE (1L<<5)
|
#define MWM_FUNC_CLOSE (1L<<5)
|
||||||
|
|
||||||
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
||||||
static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
|
static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = nullptr;
|
||||||
|
|
||||||
static const int ContextAttribList[7][7] =
|
static const int ContextAttribList[7][7] =
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ static const int ContextAttribList[7][7] =
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool s_glxError;
|
static bool s_glxError;
|
||||||
static int ctxErrorHandler(Display *dpy, XErrorEvent *ev)
|
static int ctxErrorHandler(Display */*dpy*/, XErrorEvent */*ev*/)
|
||||||
{
|
{
|
||||||
s_glxError = true;
|
s_glxError = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -77,8 +77,8 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev)
|
||||||
|
|
||||||
static logvisor::Module Log("visigen-xlib");
|
static logvisor::Module Log("visigen-xlib");
|
||||||
static logvisor::Module AthenaLog("Athena");
|
static logvisor::Module AthenaLog("Athena");
|
||||||
static void AthenaExc(athena::error::Level level, const char* file,
|
static void AthenaExc(athena::error::Level level, const char* /*file*/,
|
||||||
const char*, int line, const char* fmt, ...)
|
const char*, int /*line*/, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -93,9 +93,9 @@ static void UpdatePercent(float percent)
|
||||||
{
|
{
|
||||||
XLockDisplay(xDisp);
|
XLockDisplay(xDisp);
|
||||||
char title[256];
|
char title[256];
|
||||||
snprintf(title, 256, "VISIGen [%g%%]", percent * 100.f);
|
snprintf(title, 256, "VISIGen [%g%%]", double(percent * 100.f));
|
||||||
XChangeProperty(xDisp, windowId, XA_WM_NAME, XA_STRING, 8,
|
XChangeProperty(xDisp, windowId, XA_WM_NAME, XA_STRING, 8,
|
||||||
PropModeReplace, (unsigned char*)title, strlen(title));
|
PropModeReplace, reinterpret_cast<unsigned char*>(title), int(strlen(title)));
|
||||||
XUnlockDisplay(xDisp);
|
XUnlockDisplay(xDisp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ int main(int argc, const char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open Xlib Display */
|
/* Open Xlib Display */
|
||||||
xDisp = XOpenDisplay(0);
|
xDisp = XOpenDisplay(nullptr);
|
||||||
if (!xDisp)
|
if (!xDisp)
|
||||||
{
|
{
|
||||||
Log.report(logvisor::Error, "Can't open X display");
|
Log.report(logvisor::Error, "Can't open X display");
|
||||||
|
@ -146,7 +146,7 @@ int main(int argc, const char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int selVisualId = -1;
|
VisualID selVisualId = 0;
|
||||||
GLXFBConfig selFBConfig = nullptr;
|
GLXFBConfig selFBConfig = nullptr;
|
||||||
for (int i=0 ; i<numFBConfigs ; ++i)
|
for (int i=0 ; i<numFBConfigs ; ++i)
|
||||||
{
|
{
|
||||||
|
@ -161,10 +161,10 @@ int main(int argc, const char** argv)
|
||||||
if (doubleBuffer)
|
if (doubleBuffer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (colorSize >= 32 && depthSize >= 24)
|
if (colorSize >= 32 && depthSize >= 24 && visualId != 0)
|
||||||
{
|
{
|
||||||
selFBConfig = config;
|
selFBConfig = config;
|
||||||
selVisualId = visualId;
|
selVisualId = VisualID(visualId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,8 +218,8 @@ int main(int argc, const char** argv)
|
||||||
|
|
||||||
if (!glXCreateContextAttribsARB)
|
if (!glXCreateContextAttribsARB)
|
||||||
{
|
{
|
||||||
glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)
|
glXCreateContextAttribsARB = reinterpret_cast<glXCreateContextAttribsARBProc>(
|
||||||
glXGetProcAddressARB((const GLubyte*)"glXCreateContextAttribsARB");
|
glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB")));
|
||||||
if (!glXCreateContextAttribsARB)
|
if (!glXCreateContextAttribsARB)
|
||||||
{
|
{
|
||||||
Log.report(logvisor::Error, "unable to resolve glXCreateContextAttribsARB");
|
Log.report(logvisor::Error, "unable to resolve glXCreateContextAttribsARB");
|
||||||
|
@ -230,7 +230,7 @@ int main(int argc, const char** argv)
|
||||||
s_glxError = false;
|
s_glxError = false;
|
||||||
XErrorHandler oldHandler = XSetErrorHandler(ctxErrorHandler);
|
XErrorHandler oldHandler = XSetErrorHandler(ctxErrorHandler);
|
||||||
GLXContext glxCtx = nullptr;
|
GLXContext glxCtx = nullptr;
|
||||||
for (int attribIdx=0 ; attribIdx<std::extent<decltype(ContextAttribList)>::value ; ++attribIdx)
|
for (uint32_t attribIdx=0 ; attribIdx<std::extent<decltype(ContextAttribList)>::value ; ++attribIdx)
|
||||||
{
|
{
|
||||||
glxCtx = glXCreateContextAttribsARB(xDisp, selFBConfig, nullptr, True, ContextAttribList[attribIdx]);
|
glxCtx = glXCreateContextAttribsARB(xDisp, selFBConfig, nullptr, True, ContextAttribList[attribIdx]);
|
||||||
if (glxCtx)
|
if (glxCtx)
|
||||||
|
@ -253,12 +253,12 @@ int main(int argc, const char** argv)
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags = 0;
|
||||||
unsigned long functions;
|
unsigned long functions = 0;
|
||||||
unsigned long decorations;
|
unsigned long decorations = 0;
|
||||||
long inputMode;
|
long inputMode = 0;
|
||||||
unsigned long status;
|
unsigned long status = 0;
|
||||||
} wmHints = {0};
|
} wmHints;
|
||||||
|
|
||||||
Atom motifWmHints = XInternAtom(xDisp, "_MOTIF_WM_HINTS", True);
|
Atom motifWmHints = XInternAtom(xDisp, "_MOTIF_WM_HINTS", True);
|
||||||
if (motifWmHints)
|
if (motifWmHints)
|
||||||
|
@ -266,7 +266,7 @@ int main(int argc, const char** argv)
|
||||||
wmHints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
|
wmHints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
|
||||||
wmHints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MINIMIZE | MWM_DECOR_MENU;
|
wmHints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MINIMIZE | MWM_DECOR_MENU;
|
||||||
wmHints.functions |= MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE;
|
wmHints.functions |= MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE;
|
||||||
XChangeProperty(xDisp, windowId, motifWmHints, motifWmHints, 32, PropModeReplace, (unsigned char*)&wmHints, 5);
|
XChangeProperty(xDisp, windowId, motifWmHints, motifWmHints, 32, PropModeReplace, reinterpret_cast<unsigned char*>(&wmHints), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SIGINT will be used to cancel main thread when client thread ends
|
/* SIGINT will be used to cancel main thread when client thread ends
|
||||||
|
@ -311,7 +311,7 @@ int main(int argc, const char** argv)
|
||||||
exitEvent.type = ClientMessage;
|
exitEvent.type = ClientMessage;
|
||||||
exitEvent.window = windowId;
|
exitEvent.window = windowId;
|
||||||
exitEvent.format = 32;
|
exitEvent.format = 32;
|
||||||
XSendEvent(xDisp, windowId, 0, 0, (XEvent*)&exitEvent);
|
XSendEvent(xDisp, windowId, 0, 0, reinterpret_cast<XEvent*>(&exitEvent));
|
||||||
XFlush(xDisp);
|
XFlush(xDisp);
|
||||||
XUnlockDisplay(xDisp);
|
XUnlockDisplay(xDisp);
|
||||||
});
|
});
|
||||||
|
@ -323,10 +323,10 @@ int main(int argc, const char** argv)
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(x11Fd, &fds);
|
FD_SET(x11Fd, &fds);
|
||||||
if (pselect(x11Fd+1, &fds, NULL, NULL, NULL, &origmask) < 0)
|
if (pselect(x11Fd+1, &fds, nullptr, nullptr, nullptr, &origmask) < 0)
|
||||||
{
|
{
|
||||||
/* SIGINT/SIGUSR2 handled here */
|
/* SIGINT/SIGUSR2 handled here */
|
||||||
if (errno == EINTR)
|
if (errno == EINTR || errno == SIGUSR2)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,6 +344,7 @@ int main(int argc, const char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Terminate();
|
renderer.Terminate();
|
||||||
|
pthread_cancel(clientThread.native_handle());
|
||||||
if (clientThread.joinable())
|
if (clientThread.joinable())
|
||||||
clientThread.join();
|
clientThread.join();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue