Commits

Reid van Melle committed 86c3009

Working on a new texture function... not sure if its working yet because this is very old
- still a lot of debugging to do

Comments (0)

Files changed (8)

+- nothing added yet
   Obj.magic ((Obj.magic a) + (Obj.magic b))
 let (-~) (a:units) (b:units) : units =
   Obj.magic ((Obj.magic a) - (Obj.magic b))
+let (/~) (a:units) (b:units) : units =
+  Obj.magic ((Obj.magic a) / (Obj.magic b))
 let (>>~) (a:units) (b:int) : units =
   Obj.magic ((Obj.magic a) lsr (Obj.magic b))
 let (<<~) (a:units) (b:int) : units =
 external cfx_qdiv : units -> units -> units = "ml_clutter_cfx_qdiv"
 external cfx_one : unit -> units = "ml_clutter_cfx_one"
 external cfx_qmul : units -> units -> units = "ml_clutter_cfx_qmul"
+let cfx_cast (x:int) : units = Obj.magic x
   
 (** comparing boxed pointer values for actors *)
 let actor_objs_equal (a:[> `actor] obj) (b:[> `actor] obj) =

src/clutter.props

   signal key_release_event : ClutterEvent -> bool
   signal leave_event : ClutterEvent -> bool
   signal motion_event : ClutterEvent -> bool
+  signal paint : ClutterActor
   signal parent_set : ClutterActor
+  signal realize
   signal scroll_event : ClutterEvent -> bool
   signal show
+  signal unrealize
   method set_anchor_point : "x:int -> y:int -> unit"
   method get_anchor_point : "int*int"
   method set_anchor_point_from_gravity : "ClutterEnums.gravity_type -> unit"

src/clutterActor.ml

   method destroy = Actor.destroy obj
   method set_geometry = Actor.set_geometry obj
   method get_geometry = Actor.get_geometry obj
+  method get_stage = Actor.get_stage obj
   (*method set_shader = Actor.set_shader obj
   method get_shader = Actor.get_shader obj
   method set_shader_param = Actor.set_shader_param obj*)
   
     
 module Texture = struct
-  type vertex
-  type region
+  type vertex = {
+    x:units;
+    y:units;
+    z:units;
+    tx:units;
+    ty:units;
+    color:Clutter.Color.t
+  }
+  type region =
+      (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
     
   exception Cogl_InvalidHandle
   exception Gerror
   external rectangle : handle -> x1:units -> y1:units -> x2:units -> y2:units
     -> tx1:units -> ty1:units -> tx2:units -> ty2:units -> unit
     = "ml_cogl_texture_rectangle_bc" "ml_cogl_texture_rectangle"
-  external polygon : handle -> n:int -> vertices:vertex array
+  external polygon : handle -> vertices:vertex array
     -> use_color:bool -> unit = "ml_cogl_texture_polygon"
       
 end
 ML_3(clutter_actor_set_position, ClutterActor_val, Int_val, Int_val, Unit)
 ML_6(clutter_actor_set_rotation, ClutterActor_val, Rotate_axis_type_val, Float_val, Int_val, Int_val, Int_val, Unit)
 ML_bc6(ml_clutter_actor_set_rotation)
+ML_1(clutter_actor_get_stage, ClutterActor_val, Val_ClutterActor)
 #include "cogl_tags.c"
 #include "ml_coglbox.h"
 #include "ml_clutter.h"
+#include <caml/bigarray.h>
+#include <assert.h>
 
 #define Fixed_val Int_val
 #define Angle_val Int_val
   if (err) ml_raise_gerror(err);
   CAMLreturn(Val_CoglHandle_new(h));
 }
+
+CAMLprim value
+ml_cogl_texture_polygon(value _handle, value _vertices, value _use_color)
+{
+  CAMLparam3(_handle, _vertices, _use_color);
+  assert(Tag_val(_vertices) == 0);
+  int n = Wosize_val(_vertices);
+  static CoglTextureVertex verts[32];
+  int i;
+  for (i=0; i<n; i++) {
+    value v = Field(_vertices,i);
+    assert(Tag_val(v) == 0);
+    assert(Wosize_val(v) == 6);
+    verts[i].x = Int_val(Field(v,0));
+    verts[i].y = Int_val(Field(v,1));
+    verts[i].z = Int_val(Field(v,2));
+    verts[i].tx = Int_val(Field(v,3));
+    verts[i].ty = Int_val(Field(v,4));
+    printf("vertex: %d,%d,%d  %d,%d  %d (%d)\n", verts[i].x, verts[i].y, verts[i].z,
+	   verts[i].tx, verts[i].ty, CFX_ONE, CLUTTER_INT_TO_FIXED(320));
+    verts[i].color = *(ClutterColor*)Pointer_val(Field(v,5));
+  }
+  cogl_texture_polygon(Pointer_val(_handle), n, verts, Bool_val(_use_color));
+  CAMLreturn(Val_unit);
+}
+
+CAMLprim value
+ml_cogl_texture_new_from_data(value _w, value _h, value _max_waste,
+			      value _auto_mipmap, value _format,
+			      value _internal_format, value _rowstride,
+			      value _data)
+{
+  CAMLparam5(_w, _h, _max_waste, _auto_mipmap, _format);
+  CAMLxparam3(_internal_format, _rowstride, _data);
+  struct caml_ba_array* ba = Caml_ba_array_val(_data);
+  CoglHandle t = cogl_texture_new_from_data
+    (Int_val(_w), Int_val(_h), Int_val(_max_waste), Bool_val(_auto_mipmap),
+     Pixel_format_val(_format), Pixel_format_val(_internal_format),
+     Int_val(_rowstride), ba->data);
+  CAMLreturn(Val_CoglHandle_new(t));
+}
+			
 // IS pointer_val what we want here? or just an opaque type?
-ML_8(cogl_texture_new_from_data, Int_val, Int_val, Int_val, Bool_val, Pixel_format_val, Pixel_format_val, Int_val, Pointer_val, Val_CoglHandle_new)
+//ML_8(cogl_texture_new_from_data, Int_val, Int_val, Int_val, Bool_val, Pixel_format_val, Pixel_format_val, Int_val, Pointer_val, Val_CoglHandle_new)
 ML_bc8(ml_cogl_texture_new_from_data)
 // cogl_texture_new_from_foreign
 ML_1(cogl_is_texture, Pointer_val, Val_bool)

tests/Makefile.in

 TARGETS	:= test-behave test-events test-cogl-primitives \
 	test-depth test-effect test-entry test-project \
 	test-rotate test-score test-scale test-unproject \
-	test-viewport test-clip
+	test-viewport test-clip test-gradient
 BYTE_TARGETS    := $(TARGETS:=.byte)
 OPT_TARGETS	:= $(TARGETS:=.opt)