forked from mia/Aegisub
Use wxGL to make OpenGL usage portable
Originally committed to SVN as r3591.
This commit is contained in:
parent
9230d5360a
commit
e0b36fdaff
2 changed files with 18 additions and 41 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/app.h>
|
#include <wx/app.h>
|
||||||
#include <wx/apptrait.h>
|
#include <wx/apptrait.h>
|
||||||
|
#include <wx/glcanvas.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "include/platform.h"
|
#include "include/platform.h"
|
||||||
|
@ -29,62 +30,37 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include "GL/glx.h"
|
#ifdef __WXMAC__
|
||||||
#include "GL/gl.h"
|
#include "OpenGL/glu.h"
|
||||||
|
#include "OpenGL/gl.h"
|
||||||
|
#else
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PlatformUnix::PlatformUnix() {
|
PlatformUnix::PlatformUnix() {
|
||||||
GetVideoInfo();
|
GetVideoInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gather video adapter information via OpenGL/GLX.
|
* @brief Gather video adapter information via OpenGL
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void PlatformUnix::GetVideoInfo() {
|
void PlatformUnix::GetVideoInfo() {
|
||||||
Display *dpy;
|
int attList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
|
||||||
XVisualInfo *vi;
|
wxGLCanvas *glc = new wxGLCanvas(wxTheApp->GetTopWindow(), wxID_ANY, attList, wxDefaultPosition, wxDefaultSize);
|
||||||
GLXContext cx;
|
wxGLContext *ctx = new wxGLContext(glc, 0);
|
||||||
Window root, win;
|
ctx->SetCurrent(glc);
|
||||||
XSetWindowAttributes attr;
|
|
||||||
unsigned long mask;
|
|
||||||
int attList[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };
|
|
||||||
|
|
||||||
vendor = wxString();
|
|
||||||
renderer = wxString();
|
|
||||||
version = wxString();
|
|
||||||
|
|
||||||
// Like in glxinfo.c, but somewhat simpler and shorter.
|
|
||||||
dpy = XOpenDisplay(0);
|
|
||||||
if (!dpy) return;
|
|
||||||
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attList);
|
|
||||||
if (!vi) return;
|
|
||||||
cx = glXCreateContext(dpy, vi, 0, GL_TRUE);
|
|
||||||
if (!cx) return;
|
|
||||||
|
|
||||||
root = RootWindow(dpy, DefaultScreen(dpy));
|
|
||||||
attr.background_pixel = 0;
|
|
||||||
attr.border_pixel = 0;
|
|
||||||
attr.colormap = XCreateColormap(dpy, root, vi->visual, AllocNone);
|
|
||||||
attr.event_mask = StructureNotifyMask | ExposureMask;
|
|
||||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
|
||||||
win = XCreateWindow(dpy, root, 0, 0, 100, 100, 0, vi->depth,
|
|
||||||
InputOutput, vi->visual, mask, &attr);
|
|
||||||
|
|
||||||
if (!glXMakeCurrent(dpy, win, cx)) {
|
|
||||||
glXDestroyContext(dpy, cx);
|
|
||||||
XDestroyWindow(dpy, win);
|
|
||||||
XCloseDisplay(dpy);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vendor = wxString(glGetString(GL_VENDOR));
|
vendor = wxString(glGetString(GL_VENDOR));
|
||||||
renderer = wxString(glGetString(GL_RENDERER));
|
renderer = wxString(glGetString(GL_RENDERER));
|
||||||
version = wxString(glGetString(GL_VERSION));
|
version = wxString(glGetString(GL_VERSION));
|
||||||
|
|
||||||
glXDestroyContext(dpy, cx);
|
delete ctx;
|
||||||
XDestroyWindow(dpy, win);
|
delete glc;
|
||||||
XCloseDisplay(dpy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString PlatformUnix::OSVersion() {
|
wxString PlatformUnix::OSVersion() {
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include <wx/font.h>
|
#include <wx/font.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/glcanvas.h>
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
|
Loading…
Reference in a new issue