Skip to content

Commit

Permalink
Working on new control
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakadu committed Oct 31, 2012
1 parent 5c019e9 commit 89e7614
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -17,3 +17,5 @@ myconfig.macos
gen
bin
gen
#emacs temporary
*~
43 changes: 43 additions & 0 deletions src/GLPrimitives.ml
@@ -0,0 +1,43 @@
open LightCommon;

class virtual base =
object(self)
inherit DisplayObject.c as super;
end;

class _c =
object(self)
inherit base as super;

method !name = if name = "" then Printf.sprintf "glprimitives%d" (Oo.id self) else name;
method setColor _ = ();
method color = `NoColor;
method filters = [];
method setFilters _ = ();
method boundsInSpace:
!'space. (option (<asDisplayObject: DisplayObject.c; .. > as 'space)) -> Rectangle.t =
fun _ -> Rectangle.create 0. 0. 300. 300.
;
method private render' ?alpha:(alpha') ~transform _ =
(
debug "GLPrimitives._c.render";
Render.GLPrimitives.render ()
);
end;

class c =
object(self)
inherit _c ;
method ccast : [= `Image of c ] = `Image (self :> c);
end;

value create () = new c;









2 changes: 1 addition & 1 deletion src/Makefile
Expand Up @@ -103,7 +103,7 @@ CFLAGS += -D$(PLATFORM)
$(SYNTAX) Debug.cmx Debug.cmo: MLPPOPT := -D$(PLATFORM)

MLSOURCES = $(BMLSOURCES) Hardware.ml LocalNotifications.ml Motion.ml ProfTimer.ml WeakMemo.ml LightCommon.ml Ev.ml EventDispatcher.ml Point.ml Rectangle.ml Matrix.ml Render.ml Filters.ml \
DisplayObject.ml GLPrograms.ml Quad.ml Texture.ml RenderTexture.ml Image.ml AtlasNode.ml TextureAtlas.ml Atlas.ml Clip.ml BitmapFont.ml Sprite.ml TLF.ml Timers.ml Timer.ml LightLib.ml\
DisplayObject.ml GLPrograms.ml Quad.ml Texture.ml RenderTexture.ml Image.ml GLPrimitives.ml AtlasNode.ml TextureAtlas.ml Atlas.ml Clip.ml BitmapFont.ml Sprite.ml TLF.ml Timers.ml Timer.ml LightLib.ml\
Touch.ml Stage.ml Tween.ml Sound.ml GameCenter.ml URLLoader.ml KVStorage.ml Payment.ml $(AMLSOURCES) FB.ml Lightning.ml

#Texture.cmo Texture.cmx: MLFLAGS += -package threads -thread
Expand Down
3 changes: 3 additions & 0 deletions src/Render.ml
Expand Up @@ -138,3 +138,6 @@ module Image = struct

end;

module GLPrimitives = struct
external render: unit -> unit = "ml_glPrimitives_render" "noalloc";
end;
5 changes: 5 additions & 0 deletions src/Render.mli
Expand Up @@ -121,3 +121,8 @@ module Image :
end
;

module GLPrimitives :
sig
external render : unit -> unit = "ml_glPrimitives_render" "noalloc";
end
;
9 changes: 9 additions & 0 deletions src/render_stub.c
Expand Up @@ -903,6 +903,15 @@ void ml_image_flip_tex_y(value image) {
tq->br.tex = tmp;
}

void ml_glPrimitives_render(value xs) {
PRINT_DEBUG("ml_glPrimitices_render");
glBegin(GL_LINES);
glColor3f(255.0,0,0);
glVertex2f(50,50);
glVertex2f(100,150);
glEnd();
}

void ml_image_render(value matrix, value program, value alpha, value image) {
//fprintf(stderr,"render image\n");
PRINT_DEBUG("RENDER IMAGE");
Expand Down
2 changes: 1 addition & 1 deletion test/Makefile
@@ -1,4 +1,4 @@
sdl:
pc:
$(MAKE) -f Makefile.pc

clean:
Expand Down
1 change: 1 addition & 0 deletions test/Makefile.in
Expand Up @@ -12,6 +12,7 @@ OAUTH = ../src/social/oauth/oauth.cma
$(TARGET).byte: $(MLFILES) $(TARGET).cmo
$(OCAMLC) -custom -verbose -o test.byte -g \
-I ../src ../src/lightning.cma $(OAUTH) $(SOCIAL) $(MLFILES) ../src/social/facebook/fbconnect.cma $(TARGET).cmo \
-ccopt -lglut \
-package bigarray,unix,extlib,xmlm,ojson -linkpkg

example.cmo: $(MLFILES)
Expand Down
24 changes: 21 additions & 3 deletions test/example.ml
Expand Up @@ -1032,6 +1032,7 @@ value tweens (stage:Stage.c) =
(* Stage.addTween tweenAlpha; *)
(* tweenX#animate bt#prop'x 300.; *)
tweenY#animate bt#prop'y 600.;
tweenY#animate bt#prop'x 600.;
(* tweenAlpha#animate bt#prop'alpha 0.5; *)
(* tweenX#setOnComplete (fun () -> Stage.removeg tweenX); *)
(* tweenY#setOnComplete (fun () -> Stage.removeTween tweenY); *)
Expand Down Expand Up @@ -1369,19 +1370,36 @@ value texture_atlas (stage:Stage.c) =
let image = Image.create (TextureAtlas.subTexture atlas "/background_levels/1.png") in
stage#addChild image;

value glPrimitives (stage: Stage.c) =
let xxx = GLPrimitives.create () in
( xxx#setX 0.
; xxx#setY 0.
; xxx#setWidth 400.
; xxx#setHeight 400.
; debug "Adding child"
; stage#addChild xxx )
;
let stage width height =
object(self)
inherit Stage.c width height as super;
value bgColor = 0xCCCCCC;
initializer begin
debug "%s" (Render.get_gl_extensions ());

glPrimitives self;
(* let delay = 0.1 in
let twin = Tween.create delay in
let () = twin#setOnComplete (fun () -> debug "completed" ) in
let duration = 1.0 in
twin#process duration |> ignore *)
(* tweens self;
udid self;*)
(* debug "%s" (Render.get_gl_extensions ()); *)
(*
let timer = Timer.create ~repeatCount:1 2. "PZIDA" in
(
ignore(timer#addEventListener Timer.ev_TIMER_COMPLETE (fun _ _ _ -> pvr self));
timer#start ()
);

*)
(* Sound.init (); *)

(* let channel1 = Sound.createChannel (Sound.load "achievement1.caf")
Expand Down

0 comments on commit 89e7614

Please sign in to comment.