From d95ce956ee63fcd3eca91d26dd29c85c1928e541 Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Wed, 13 Apr 2005 17:39:40 +0000 Subject: [PATCH] another random rejig commit --- Makefile | 39 ----------- clutter/cltr-scratch.c | 143 +++++++++++++++++++++++++++++++++++++++++ clutter/cltr-scratch.h | 14 ++++ 3 files changed, 157 insertions(+), 39 deletions(-) delete mode 100644 Makefile create mode 100644 clutter/cltr-scratch.c create mode 100644 clutter/cltr-scratch.h diff --git a/Makefile b/Makefile deleted file mode 100644 index aaa5dc56d..000000000 --- a/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -LIBS=-lpng -lGL -ljpeg -L/usr/X11R6/lib -lX11 `pkg-config --libs pangoft2 pango glib-2.0 gthread-2.0` -CFLAGS=`pkg-config --cflags pangoft2 pango glib-2.0 gthread-2.0` - -.c.o: - $(CC) -g -Wall $(CFLAGS) $(INCS) -c $*.c - -OBJS=cltr.o pixbuf.o util.o fonts.o \ - cltr-core.o \ - cltr-glu.o \ - cltr-texture.o \ - cltr-widget.o \ - cltr-events.o \ - cltr-window.o \ - cltr-photo-grid.o \ - cltr-list.o \ - cltr-scratch.o - -# cltr-photo-grid.o - -clutter: $(OBJS) - $(CC) -g -Wall -o $@ $(OBJS) $(LIBS) - -$(OBJS): pixbuf.h util.h fonts.h \ - cltr.h \ - cltr-private.h \ - cltr-glu.h \ - cltr-events.h \ - cltr-texture.h \ - cltr-widget.h \ - cltr-window.h \ - cltr-photo-grid.h \ - cltr-list.h \ - cltr-scratch.h - -#cltr-photo-grid.h - - -clean: - rm -fr *.o clutter test diff --git a/clutter/cltr-scratch.c b/clutter/cltr-scratch.c new file mode 100644 index 000000000..d0ead1c5a --- /dev/null +++ b/clutter/cltr-scratch.c @@ -0,0 +1,143 @@ +#include "cltr-scratch.h" +#include "cltr-private.h" + +struct CltrScratch +{ + CltrWidget widget; + + Pixbuf *pixb; + CltrTexture *tex; +}; + +static void +cltr_scratch_show(CltrWidget *widget); + +static gboolean +cltr_scratch_handle_xevent (CltrWidget *widget, XEvent *xev); + +static void +cltr_scratch_paint(CltrWidget *widget); + + +CltrWidget* +cltr_scratch_new(int width, int height) +{ + CltrScratch *scratch; + ClutterFont *font; + PixbufPixel pixel = { 255, 255, 255, 100 }; + + scratch = g_malloc0(sizeof(CltrScratch)); + + scratch->widget.width = width; + scratch->widget.height = height; + + scratch->widget.show = cltr_scratch_show; + scratch->widget.paint = cltr_scratch_paint; + + scratch->widget.xevent_handler = cltr_scratch_handle_xevent; + + scratch->pixb = pixbuf_new(width, height); + + pixel_set_vals(&pixel, 0, 0, 0, 255); + + pixbuf_fill_rect(scratch->pixb, 0, 0, width, height, &pixel); + + font = font_new ("Sans Bold 72"); + + pixel_set_vals(&pixel, 255, 255, 255, 255); + + font_draw(font, scratch->pixb, "Hello", 0, 0, &pixel); + + scratch->tex = cltr_texture_new(scratch->pixb); + + return CLTR_WIDGET(scratch); +} + +static void +cltr_scratch_show(CltrWidget *widget) +{ + cltr_widget_queue_paint(widget); +} + +static gboolean +cltr_scratch_handle_xevent (CltrWidget *widget, XEvent *xev) +{ + + return TRUE; +} + +static void +cltr_scratch_paint(CltrWidget *widget) +{ + CltrScratch *scratch = CLTR_SCRATCH(widget); + + int times = 100, num = 0; + int spost = 0; + float alphainc = 0.9f / times; + float alpha = 0.1f; + + glPushMatrix(); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + + glBlendFunc(GL_SRC_ALPHA,GL_ONE); + glEnable(GL_BLEND); + + + /* + glEnable(GL_BLEND); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + */ + + for (num = 0;num < times;num++) + { + glColor4f(1.0f, 1.0f, 1.0f, alpha); + cltr_texture_render_to_gl_quad(scratch->tex, + widget->x - spost, + widget->y - spost, + widget->x + widget->width + spost, + widget->y + widget->height + spost); + spost += 2; + alpha = alpha - alphainc; + } + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + cltr_texture_render_to_gl_quad(scratch->tex, + widget->x, + widget->y, + widget->x + widget->width , + widget->y + widget->height); + + + glDisable(GL_BLEND); + + glPopMatrix(); +} + + +static void +cltr_scratch_paint_old(CltrWidget *widget) +{ + glPushMatrix(); + + CLTR_MARK(); + + glEnable(GL_BLEND); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glColor4ub(100, 200, 50, 100); + + glRecti(widget->x, widget->y, + widget->x + widget->width, + widget->y + widget->height); + + + glDisable(GL_BLEND); + + glPopMatrix(); +} diff --git a/clutter/cltr-scratch.h b/clutter/cltr-scratch.h new file mode 100644 index 000000000..f9b6de993 --- /dev/null +++ b/clutter/cltr-scratch.h @@ -0,0 +1,14 @@ +#ifndef _HAVE_CLTR_SCRATCH_H +#define _HAVE_CLTR_SCRATCH_H + +#include "cltr.h" + +typedef struct CltrScratch CltrScratch; + +#define CLTR_SCRATCH(w) ((CltrScratch*)(w)) + +CltrWidget* +cltr_scratch_new(int width, int height); + + +#endif