libobrender2.la
instance.lo
init.lo
+debug.lo
+color.lo
-DTHEMEDIR=\"$(themedir)\"
INCLUDES=-I..
-LIBS=$(GLIB_LIBS) $(GL_LIBS) @LIBS@
+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
+libobrender2_la_SOURCES=init.c instance.c color.c debug.c
-noinst_HEADERS=render.h instance.h
+noinst_HEADERS=render.h instance.h debug.h
MAINTAINERCLEANFILES=Makefile.in
--- /dev/null
+#include "render.h"
+#include "instance.h"
+#include "debug.h"
+#include <X11/Xlib.h>
+
+int RrColorParse(struct RrInstance *inst, const char *colorname,
+ struct RrColor *ret)
+{
+ XColor xcol;
+
+ if (!XParseColor(RrDisplay(inst), RrColormap(inst), colorname, &xcol)) {
+ RrDebug("unable to parse color '%s'", colorname);
+ ret->r = 0.0;
+ ret->g = 0.0;
+ ret->b = 0.0;
+ return 0;
+ }
+ ret->r = (xcol.red >> 8) / 255.0;
+ ret->g = (xcol.green >> 8) / 255.0;
+ ret->b = (xcol.blue >> 8) / 255.0;
+ return 1;
+}
--- /dev/null
+#include <stdio.h>
+#include <stdarg.h>
+
+void RrDebug(char *a, ...)
+{
+#ifdef DEBUG
+ va_list vl;
+ va_start(vl, a);
+ vprintf(a, vl);
+#endif
+}
--- /dev/null
+#ifndef __render_debug_h
+#define __render_debug_h
+
+void RrDebug(char *a, ...);
+
+#endif
--- /dev/null
+#ifndef __render_font_h
+#define __render_font_h
+
+#include "glft/glft.h"
+
+struct RrFont {
+ struct GlftFont *font;
+};
+
+#endif
#include "instance.h"
#include "render.h"
+#include "debug.h"
static int glXRating(Display *display, XVisualInfo *v)
{
int rating = 0;
int val;
- g_print("evaluating visual %d\n", (int)v->visualid);
+ RrDebug("evaluating visual %d\n", (int)v->visualid);
glXGetConfig(display, v, GLX_BUFFER_SIZE, &val);
- g_print("buffer size %d\n", val);
+ RrDebug("buffer size %d\n", val);
switch (val) {
case 32:
}
glXGetConfig(display, v, GLX_LEVEL, &val);
- g_print("level %d\n", val);
+ RrDebug("level %d\n", val);
if (val != 0)
rating = -10000;
glXGetConfig(display, v, GLX_DEPTH_SIZE, &val);
- g_print("depth size %d\n", val);
+ RrDebug("depth size %d\n", val);
switch (val) {
case 32:
rating += 30;
}
glXGetConfig(display, v, GLX_DOUBLEBUFFER, &val);
- g_print("double buffer %d\n", val);
+ RrDebug("double buffer %d\n", val);
if (val)
rating++;
return rating;
&vimatch, &count);
if (vilist) {
- g_print("looking for a GL visual in %d visuals\n", count);
+ RrDebug("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) {
}
}
if (rate > 0) {
- g_print("picked visual %d with rating %d\n", best, rate);
+ RrDebug("picked visual %d with rating %d\n", best, rate);
ret = RrInstanceNew(display, screen, vilist[best]);
}
return ret;
#include "instance.h"
-#include <glib.h>
+#include <stdlib.h>
+#include <assert.h>
/*
void truecolor_startup(void)
timage = XCreateImage(ob_display, render_visual, render_depth,
ZPixmap, 0, NULL, 1, 1, 32, 0);
- g_assert(timage != NULL);
+ assert(timage != NULL);
/\* find the offsets for each color in the visual's masks *\/
render_red_mask = red_mask = timage->red_mask;
render_green_mask = green_mask = timage->green_mask;
{
struct RrInstance *inst;
- inst = g_new(struct RrInstance, 1);
+ inst = malloc(sizeof(struct RrInstance));
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);
+ inst->glx_context = glXCreateContext(display, &visinfo, NULL, True);
- g_assert(inst->glx_context);
+ assert(inst->glx_context);
return inst;
}
if (inst) {
glXDestroyContext(inst->display, inst->glx_context);
XFreeColormap(inst->display, inst->cmap);
- g_free(inst);
+ free(inst);
}
}
#include <glib.h>
#include <X11/Xlib.h>
-/*
-#define RrBool gboolean
-#define RrTrue 1
-#define RrFalse 0
-*/
+/* initialization */
struct RrInstance;
-struct RrRGB;
-struct RrFont;
/*! Returns a struct to be used when calling members of the library.
If the library fails to initialize, NULL is returned.
struct RrInstance *RrInit(Display *display,
int screen);
-/*! Destroys an instance of the library.
+/*! Destroys an instance of the library. The instance should not be used after
+ calling this function.
@param inst The instance to destroy.
*/
void RrDestroy(struct RrInstance *inst);
+
+/* colors */
+
+/*! A Color (including alpha component) for the Render library. This should be
+ treated as an opaque data type, and be accessed only via the available
+ functions. */
+struct RrColor {
+ /*! The red component. */
+ float r;
+ /*! The green component. */
+ float g;
+ /*! The blue component. */
+ float b;
+ /*! The alpha component. */
+ float a;
+};
+
+/*! Returns the red component for an RrColor */
+#define RrColorRed(c) (c)->r
+/*! Returns the green component for an RrColor */
+#define RrColorGreen(c) (c)->g
+/*! Returns the blue component for an RrColor */
+#define RrColorBlue(c) (c)->b
+/*! Returns the alpha component for an RrColor */
+#define RrColorAlpha(c) (c)->a
+
+/*! Sets the values of all components for an RrColor */
+#define RrColorSet(c, w, x, y, z) (c)->r = (w), (c)->g = (x), \
+ (c)->b = (y), (c)->a = z
+
+
+/*! Gets color values from a colorname.
+ @param inst An instance of the library
+ @param colorname The name of the color.
+ @param ret The RrColor to set the colorvalues in.
+ @return nonzero if the colorname could be parsed; on error, it returns zero.
+*/
+int RrColorParse(struct RrInstance *inst, const char *colorname,
+ struct RrColor *ret);
+
+/* fonts */
+
+struct RrFont;
+
#endif