summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-04-13 14:50:54 +0200
committerYorhel <git@yorhel.nl>2010-04-13 14:50:54 +0200
commit5e045b40892b6b1ccd420a76964533bdcdaed3e2 (patch)
treee1adff72297411ee27728f64d601180de60db498
parent295ddc65460fcbdf1e7c6389eaf289d6d469cf58 (diff)
Cleaned up the arch zooming effect
How ugly it may be, it serves as a good way to test the BMP loader and texture setting function.
-rw-r--r--archzoom.ml39
-rw-r--r--data/arch.bmpbin0 -> 262198 bytes
-rw-r--r--main.ml32
3 files changed, 41 insertions, 30 deletions
diff --git a/archzoom.ml b/archzoom.ml
new file mode 100644
index 0000000..bc2f05f
--- /dev/null
+++ b/archzoom.ml
@@ -0,0 +1,39 @@
+(* Very lame and badly implemented infinite zoom on an Arch Linux logo,
+ * loaded to texture from data/arch.bmp *)
+
+
+
+let tex_id = ref None
+
+
+let settex () =
+ match !tex_id with
+ Some n -> GlTex.bind_texture `texture_2d n
+ | None -> tex_id := Some (Util.setTexture (Util.loadBMP "data/arch.bmp"))
+
+
+
+(* this zoom function assumes the Arch texture is activated *)
+let draw t =
+ settex ();
+ GlMat.push ();
+ Gl.enable `texture_2d;
+ let d () =
+ GlDraw.begins `quads;
+ GlTex.coord2( 0.0, 1.0); GlDraw.vertex3 (-1.0, 1.0, 0.0);
+ GlTex.coord2( 1.0, 1.0); GlDraw.vertex3 ( 1.0, 1.0, 0.0);
+ GlTex.coord2( 1.0, 0.0); GlDraw.vertex3 ( 1.0, -1.0, 0.0);
+ GlTex.coord2( 0.0, 0.0); GlDraw.vertex3 (-1.0, -1.0, 0.0);
+ GlDraw.ends () in
+ let di = 1.05 in
+ let ti = 2.80 +. t -. (float (truncate (t/.di)))*.di in
+ let zoom = ti**ti in
+ GlMat.scale3 (zoom, zoom, 1.0);
+ GlMat.translate3 (0.0, 0.33333, -2.0);
+ for i=0 to 3 do
+ GlMat.translate ~y:(-0.3) ();
+ GlMat.scale3 (0.1, 0.1, 1.0);
+ d ();
+ done;
+ Gl.disable `texture_2d;
+ GlMat.pop ()
diff --git a/data/arch.bmp b/data/arch.bmp
new file mode 100644
index 0000000..df388c2
--- /dev/null
+++ b/data/arch.bmp
Binary files differ
diff --git a/main.ml b/main.ml
index e723e95..aa24df6 100644
--- a/main.ml
+++ b/main.ml
@@ -6,40 +6,13 @@ let width = 960.0 and height = 540.0
let starttime = Unix.gettimeofday ()
-(* this zoom function assumes the Arch texture is activated *)
-let drawZoom t =
- GlMat.push ();
- (*GlMat.translate3 (0.0, 0.0, (-2.0 -. t *. t));
- GlMat.rotate ~angle:(t *. t *. 45.0) ~z:1.0 ();*)
- Gl.enable `texture_2d;
- let d () =
- GlDraw.begins `quads;
- GlTex.coord2( 0.0, 1.0); GlDraw.vertex3 (-1.0, 1.0, 0.0);
- GlTex.coord2( 1.0, 1.0); GlDraw.vertex3 ( 1.0, 1.0, 0.0);
- GlTex.coord2( 1.0, 0.0); GlDraw.vertex3 ( 1.0, -1.0, 0.0);
- GlTex.coord2( 0.0, 0.0); GlDraw.vertex3 (-1.0, -1.0, 0.0);
- GlDraw.ends () in
- let di = 1.05 in
- let ti = 2.80 +. t -. (float (truncate (t/.di)))*.di in
- let zoom = ti**ti in
- GlMat.scale3 (zoom, zoom, 1.0);
- GlMat.translate3 (0.0, 0.33333, -3.0);
- for i=0 to 3 do
- GlMat.translate ~y:(-0.3) ();
- GlMat.scale3 (0.1, 0.1, 1.0);
- d ();
- done;
- Gl.disable `texture_2d;
- GlMat.pop ()
-
-
let drawFrame () =
let t = (Unix.gettimeofday ()) -. starttime in
GlClear.clear [`color; `depth];
GlMat.load_identity ();
- Metaballs.draw t;
- (*drawZoom t;*)
+ (*Metaballs.draw t;*)
+ Archzoom.draw t;
Util.drawInfo height width t;
Glut.swapBuffers ()
@@ -68,7 +41,6 @@ let _ =
GluMat.perspective ~fovy:60.0 ~aspect:(width /. height) ~z:(0.1,100.0);
GlDraw.viewport 0 0 (truncate width) (truncate height);
GlMat.mode `modelview;
- (*ignore (Util.setTexture (Util.loadBMP "test.bmp"));*)
(* run *)
Glut.mainLoop ()