GLX implementation and *nix-specific file handling implementation

I added gl-x11 which allows compatibility with X11 (Xlib-based) and GLX.
I also added various functions to handle file finding based on FHS.
Various changes to autotools to both install files correctly and to configure correctly.
This commit is contained in:
Zachary Lund
2013-12-27 20:43:28 -06:00
parent 1c91e0d0e0
commit 80b8176e29
11 changed files with 402 additions and 21 deletions

View File

@@ -33,5 +33,7 @@ obs_SOURCES += platform-osx.mm
endif
if OS_NIX
obs_CPPFLAGS = $(AM_CPPFLAGS) $(GTK_CFLAGS) $(X11_CFLAGS) $(XINERAMA_CFLAGS)
obs_SOURCES += platform-x11.cpp
obs_LDADD += $(GTK_LIBS) $(X11_LIBS) $(XINERAMA_LIBS)
endif

View File

@@ -14,19 +14,78 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/* Here we use xinerama to fetch data about monitor geometry
* Even if there are not multiple monitors, this should still work.
*/
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>
#include <unistd.h>
#include <sstream>
#include "platform.hpp"
using namespace std;
static inline bool check_path(const char* data, const char *path, string &output)
{
ostringstream str;
str << "/usr/local/share/obs-studio/" << data;
output = str.str();
printf("Attempted path: %s\n", output.c_str());
return (access(output.c_str(), R_OK) == 0);
}
bool GetDataFilePath(const char *data, string &output)
{
// TODO
char *data_path = getenv("OBS_DATA_PATH");
if (data_path != NULL) {
if (check_path(data, data_path, output))
return true;
}
if (check_path(data, "/usr/local/share/obs-studio/", output))
return true;
if (check_path(data, "/usr/share/obs-studio/", output))
return true;
return false;
}
void GetMonitors(vector<MonitorInfo> &monitors)
{
int num_screens;
XineramaScreenInfo *screens;
int event_code = 0, error_code = 0;
Display* display = XOpenDisplay(NULL);
if (!XineramaQueryExtension(display, &event_code, &error_code)) {
printf("Xinerama extension unavailable. We don't handle this yet.\n");
return;
}
/* Do I need to make a call to XineramaQueryVersion...? */
screens = XineramaQueryScreens(display, &num_screens);
if (num_screens == 0 || !screens) {
printf("Xinerama isn't active on this screen.\n");
return;
}
monitors.clear();
// TODO
do {
--num_screens;
monitors.emplace_back(
screens[num_screens].x_org,
screens[num_screens].y_org,
screens[num_screens].width,
screens[num_screens].height
);
} while (num_screens > 0);
XCloseDisplay(display);
}

View File

@@ -23,6 +23,14 @@
#include <memory>
using namespace std;
#ifdef __linux__
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#endif
#include <memory>
using namespace std;
gs_window WxToGSWindow(const wxWindow *wxwin)
{
gs_window window;
@@ -31,7 +39,7 @@ gs_window WxToGSWindow(const wxWindow *wxwin)
#elif _WIN32
window.hwnd = wxwin->GetHandle();
#else
/* TODO: linux stuff */
window.id = gdk_x11_drawable_get_xid(gtk_widget_get_window(wxwin->GetHandle()));
#endif
return window;
}