changeset 2079:551862ab5d86

add alpha blending shit
author William Pitcock <nenolod@atheme.org>
date Mon, 15 Oct 2007 06:43:06 -0500
parents 1fa3c8cd366a
children f915d43db0dc
files src/paranormal-ng/builtins.c src/paranormal-ng/general.c src/paranormal-ng/paranormal.c
diffstat 3 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/paranormal-ng/builtins.c	Mon Oct 15 06:20:13 2007 -0500
+++ b/src/paranormal-ng/builtins.c	Mon Oct 15 06:43:06 2007 -0500
@@ -52,6 +52,7 @@
 DECLARE_ACTUATOR (general_copy);
 DECLARE_ACTUATOR (general_flip);
 DECLARE_ACTUATOR (general_evaluate);
+DECLARE_ACTUATOR (general_setalpha);
 
 /* **************** misc **************** */
 DECLARE_ACTUATOR (misc_floater);
@@ -100,6 +101,7 @@
   &builtin_general_copy,
   &builtin_general_flip,
   &builtin_general_evaluate,
+  &builtin_general_setalpha,
   /* **************** misc **************** */
   &builtin_misc_floater,
   /* **************** wave **************** */
--- a/src/paranormal-ng/general.c	Mon Oct 15 06:20:13 2007 -0500
+++ b/src/paranormal-ng/general.c	Mon Oct 15 06:43:06 2007 -0500
@@ -180,6 +180,34 @@
   NULL, NULL, general_clear_exec
 };
 
+/* **************** general_setalpha **************** */
+static struct pn_actuator_option_desc general_setalpha_opts[] =
+{
+  { "blend_colour", "The colour which should be used for blending.",
+    OPT_TYPE_COLOR, { cval: {255, 255, 255} } },
+  { "alpha", "The alpha value.",
+    OPT_TYPE_COLOR_INDEX, { ival: 128 } },
+  { NULL }
+};
+
+static void
+general_setalpha_exec (const struct pn_actuator_option *opts,
+	   gpointer data)
+{
+  GLubyte colour[] = { opts[0].val.cval.r, opts[0].val.cval.g, opts[0].val.cval.b,
+                       opts[1].val.ival };
+
+  glColor4ubv(colour);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+}
+
+struct pn_actuator_desc builtin_general_setalpha =
+{
+  "general_setalpha", "Change Blend Setting", "Changes the blending setting (alpha transparency mask).",
+  0, general_setalpha_opts,
+  NULL, NULL, general_setalpha_exec
+};
+
 /* **************** general_noop **************** */
 static void
 general_noop_exec (const struct pn_actuator_option *opts,
--- a/src/paranormal-ng/paranormal.c	Mon Oct 15 06:20:13 2007 -0500
+++ b/src/paranormal-ng/paranormal.c	Mon Oct 15 06:43:06 2007 -0500
@@ -74,6 +74,9 @@
   glViewport(0, 0, w, h);
   glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
   glClearDepth(1.0f);
+
+  glEnable(GL_BLEND);
+  glDisable(GL_DEPTH_TEST);
 }
 
 static void