rendertest_SOURCES=test.c
lib_LTLIBRARIES=libobrender2.la
-libobrender2_la_SOURCES=init.c instance.c color.c debug.c font.c surface.c
-
-noinst_HEADERS=render.h instance.h debug.h surface.h
+libobrender2_la_SOURCES=\
+ init.c \
+ instance.c \
+ color.c \
+ debug.c \
+ font.c \
+ surface.c \
+ texture.h
+
+noinst_HEADERS=\
+ render.h \
+ instance.h \
+ debug.h \
+ surface.h \
+ texture.h
MAINTAINERCLEANFILES=Makefile.in
/* surfaces */
struct RrSurface;
-struct RrTexture;
enum RrSurfaceType {
RR_SURFACE_PLANAR,
RR_SURFACE_NONPLANAR
};
-enum RrTextureType {
- RR_TEXTURE_FOO
-};
-
/*! The options available for the background of an RrSurface */
enum RrSurfaceColorType {
/*! No rendering on the surface background, its contents will be
void RrSurfaceFree(struct RrSurface *sur);
Window RrSurfaceWindow(struct RrSurface *sur);
-struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum);
+
+/* textures */
+
+enum RrLayout {
+ RR_TOP_LEFT,
+ RR_TOP,
+ RR_TOP_RIGHT,
+ RR_LEFT,
+ RR_CENTER,
+ RR_RIGHT,
+ RR_BOTTOM_LEFT,
+ RR_BOTTOM,
+ RR_BOTTOM_RIGHT
+};
+
+#ifndef __LONG64
+typedef long RrData32;
+#else
+typedef int RrData32;
+#endif
+
+void RrTextureSetRGBA(struct RrSurface *sur,
+ int texnum,
+ RrData32 *data,
+ int x,
+ int y,
+ int w,
+ int h);
+void RrTextureSetText(struct RrSurface *sur,
+ int texnum,
+ struct RrFont *font,
+ enum RrLayout layout,
+ const char *text);
#endif
int parenty;
};
+struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum);
+
#endif
--- /dev/null
+#include "texture.h"
+#include "surface.h"
+
+void texture_free(struct RrTexture *tex)
+{
+ switch (tex->type) {
+ case RR_TEXTURE_NONE:
+ break;
+ case RR_TEXTURE_TEXT:
+ free(tex->data.text.string);
+ break;
+ case RR_TEXTUER_RGBA:
+ break;
+ }
+ tex->type = RR_TEXTURE_NONE;
+}
+
+void RrTextureSetRGBA(struct RrSurface *sur,
+ int texnum,
+ RrData32 *data,
+ int x,
+ int y,
+ int w,
+ int h)
+{
+ struct RrTexture *tex = RrSurfaceTexture(sur, texnum);
+
+ if (!tex) return;
+ texture_free(tex);
+ tex->type = RR_TEXTURE_RGBA;
+ tex->data.rgba.data = data;
+ tex->data.rgba.x = x;
+ tex->data.rgba.y = y;
+ tex->data.rgba.w = w;
+ tex->data.rgba.h = h;
+}
+
+void RrTextureSetText(struct RrSurface *sur,
+ int texnum,
+ struct RrFont *font,
+ enum RrLayout layout,
+ const char *text)
+{
+ struct RrTexture *tex = RrSurfaceTexture(sur, texnum);
+ int l;
+
+ if (!tex) return;
+ texture_free(tex);
+ tex->type = RR_TEXTURE_TEXT;
+ tex->data.text.font = font;
+ tex->data.text.layout = layout;
+
+ l = strlen(text) + 1;
+ tex->data.text.string = malloc(l);
+ memcpy(tex->data.text.string, text, l);
+}
--- /dev/null
+#ifndef __render_texture_h
+#define __render_texture_h
+
+#include "render.h"
+
+enum RrTextureType {
+ RR_TEXTURE_NONE,
+ RR_TEXTURE_TEXT,
+ RR_TEXTURE_RGBA
+};
+
+struct RrTextureText {
+ struct RrFont *font;
+ enum RrLayout layout;
+ char *string;
+};
+
+struct RrTextureRGBA {
+ RrData32 *data;
+ int x;
+ int y;
+ int w;
+ int h;
+};
+
+union RrTextureData {
+ struct RrTextureText text;
+ struct RrTextureRGBA rgba;
+};
+
+struct RrTexture {
+ enum RrTextureType type;
+ union RrTextureData data;
+};
+
+#endif