-SUBDIRS = po themes data render parser kernel plugins tools
+SUBDIRS = po themes data render render2 parser kernel plugins tools
MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in
doc:
AC_SUBST(FC_CFLAGS)
AC_SUBST(FC_LIBS)
+## XXX REMOVE ME PLS XXX ##
+PKG_CHECK_MODULES(XFT, [xft])
+AC_SUBST(XFT_CFLAGS)
+AC_SUBST(XFT_LIBS)
+## XXX REMOVE ME PLS XXX ##
+
PKG_CHECK_MODULES(XML, [libxml-2.0])
AC_SUBST(XML_CFLAGS)
AC_SUBST(XML_LIBS)
po/Makefile.in
themes/Makefile
data/Makefile
- render/Makefile
+ render/Makefile
+ render2/Makefile
parser/Makefile
kernel/Makefile
plugins/Makefile
--- /dev/null
+rendertest
+librender.a
+.libs
+Makefile.in
+.deps
+Makefile
+libobrender2.la
+instance.lo
+init.lo
--- /dev/null
+themedir=$(datadir)/openbox/themes
+
+theme=operation
+
+CPPFLAGS=$(FC_CFLAGS) $(GLIB_CFLAGS) $(GL_CFLAGS) @CPPFLAGS@ \
+ -DG_LOG_DOMAIN=\"Render\" \
+ -DDEFAULT_THEME=\"$(theme)\" \
+ -DTHEMEDIR=\"$(themedir)\"
+
+INCLUDES=-I..
+LIBS=$(FC_LIBS) $(GLIB_LIBS) $(GL_LIBS) @LIBS@
+
+noinst_PROGRAMS=rendertest
+rendertest_LDFLAGS=-lobrender2 -L.
+rendertest_SOURCES=test.c
+
+lib_LTLIBRARIES=libobrender2.la
+libobrender2_la_SOURCES=init.c instance.c
+
+
+noinst_HEADERS=render.h instance.h
+
+MAINTAINERCLEANFILES=Makefile.in
+
+distclean-local:
+ $(RM) *\~ *.orig *.rej .\#*
--- /dev/null
+#include "instance.h"
+#include "render.h"
+
+static int glXRating(Display *display, XVisualInfo *v)
+{
+ int rating = 0;
+ int val;
+ g_print("evaluating visual %d\n", (int)v->visualid);
+ glXGetConfig(display, v, GLX_BUFFER_SIZE, &val);
+ g_print("buffer size %d\n", val);
+
+ switch (val) {
+ case 32:
+ rating += 300;
+ break;
+ case 24:
+ rating += 200;
+ break;
+ case 16:
+ rating += 100;
+ break;
+ }
+
+ glXGetConfig(display, v, GLX_LEVEL, &val);
+ g_print("level %d\n", val);
+ if (val != 0)
+ rating = -10000;
+
+ glXGetConfig(display, v, GLX_DEPTH_SIZE, &val);
+ g_print("depth size %d\n", val);
+ switch (val) {
+ case 32:
+ rating += 30;
+ break;
+ case 24:
+ rating += 20;
+ break;
+ case 16:
+ rating += 10;
+ break;
+ case 0:
+ rating -= 10000;
+ }
+
+ glXGetConfig(display, v, GLX_DOUBLEBUFFER, &val);
+ g_print("double buffer %d\n", val);
+ if (val)
+ rating++;
+ return rating;
+}
+
+struct RrInstance *RrInit(Display *display,
+ int screen)
+{
+ int count, i = 0, val, best = 0, rate = 0, temp;
+ XVisualInfo vimatch, *vilist;
+ struct RrInstance *ret = NULL;
+
+ vimatch.screen = screen;
+ vimatch.class = TrueColor;
+ vilist = XGetVisualInfo(display, VisualScreenMask | VisualClassMask,
+ &vimatch, &count);
+
+ if (vilist) {
+ g_print("looking for a GL visual in %d visuals\n", count);
+ for (i = 0; i < count; i++) {
+ glXGetConfig(display, &vilist[i], GLX_USE_GL, &val);
+ if (val) {
+ temp = glXRating(display, &vilist[i]);
+ if (temp > rate) {
+ best = i;
+ rate = temp;
+ }
+ }
+ }
+ }
+ if (rate > 0) {
+ g_print("picked visual %d with rating %d\n", best, rate);
+ ret = RrInstanceNew(display, screen, vilist[best]);
+ } else {
+ g_print("no valid GL visual was found\n");
+ }
+ return ret;
+}
+
+void RrDestroy(struct RrInstance *inst)
+{
+ RrInstanceFree(inst);
+}
--- /dev/null
+#include "instance.h"
+#include <glib.h>
+
+struct RrInstance *RrInstanceNew(Display *display,
+ int screen,
+ XVisualInfo visinfo)
+{
+ struct RrInstance *inst;
+
+ inst = g_new(struct RrInstance, 1);
+ inst->display = display;
+ inst->screen = screen;
+ inst->visinfo = visinfo;
+ inst->cmap = XCreateColormap(display, RootWindow(display, screen),
+ RrVisual(inst), AllocNone);
+ inst->glx_context = glXCreateContext(display, &visinfo, NULL, TRUE);
+
+ g_assert(inst->glx_context);
+
+ return inst;
+}
+
+void RrInstanceFree(struct RrInstance *inst)
+{
+ if (inst) {
+ glXDestroyContext(inst->display, inst->glx_context);
+ XFreeColormap(inst->display, inst->cmap);
+ g_free(inst);
+ }
+}
--- /dev/null
+#ifndef __instance_h
+#define __instance_h
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/glx.h>
+
+struct RrInstance {
+ Display *display;
+ int screen;
+ XVisualInfo visinfo;
+ Colormap cmap;
+ GLXContext glx_context;
+};
+
+struct RrInstance *RrInstanceNew(Display *display,
+ int screen,
+ XVisualInfo visinfo);
+void RrInstanceFree(struct RrInstance *inst);
+
+
+#define RrDisplay(i) ((i)->display)
+#define RrScreen(i) ((i)->screen)
+#define RrDepth(i) ((i)->visinfo.depth)
+#define RrVisual(i) ((i)->visinfo.visual)
+#define RrColormap(i) ((i)->cmap)
+#define RrContext(i) ((i)->glx_context)
+
+#endif
--- /dev/null
+#ifndef __render_h__
+#define __render_h__
+
+#include <glib.h>
+#include <X11/Xlib.h>
+
+/*
+#define RrBool gboolean
+#define RrTrue 1
+#define RrFalse 0
+*/
+
+struct RrInstance;
+
+/*! Returns a struct to be used when calling members of the library.
+ If the library fails to initialize, NULL is returned.
+ @param display The X Display to use.
+ @param screen The number of the screen to use.
+*/
+struct RrInstance *RrInit(Display *display,
+ int screen);
+
+/*! Destroys an instance of the library.
+ @param inst The instance to destroy.
+*/
+void RrDestroy(struct RrInstance *inst);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/shape.h>
+#include <string.h>
+#include <stdlib.h>
+#include "render.h"
+#include <glib.h>
+
+static int x_error_handler(Display * disp, XErrorEvent * error)
+{
+ char buf[1024];
+ XGetErrorText(disp, error->error_code, buf, 1024);
+ printf("%s\n", buf);
+ return 0;
+}
+
+int main()
+{
+ Display *display;
+ Window win;
+ struct RrInstance *inst;
+ XEvent report;
+ XClassHint chint;
+
+ if (!(display = XOpenDisplay(NULL))) {
+ fprintf(stderr, "couldn't connect to X server in DISPLAY\n");
+ return EXIT_FAILURE;
+ }
+ XSetErrorHandler(x_error_handler);
+ win = XCreateWindow(display, RootWindow(display, DefaultScreen(display)),
+ 10, 10, 100, 100, 0,
+ CopyFromParent, /* depth */
+ CopyFromParent, /* class */
+ CopyFromParent, /* visual */
+ 0, /* valuemask */
+ 0); /* attributes */
+ XMapWindow(display, win);
+ XSelectInput(display, win, ExposureMask | StructureNotifyMask);
+
+ chint.res_name = "rendertest";
+ chint.res_class = "Rendertest";
+ XSetClassHint(display, win, &chint);
+
+ /* init Render */
+ inst = RrInit(display, DefaultScreen(display));
+
+ /*paint(win, look);*/
+ while (1) {
+ XNextEvent(display, &report);
+ switch (report.type) {
+ case Expose:
+ break;
+ case ConfigureNotify:
+ /*look->area.width = report.xconfigure.width;
+ look->area.height = report.xconfigure.height;
+ paint(win, look);*/
+ break;
+ }
+
+ }
+
+ return 1;
+}