X-Git-Url: https://codewiz.org/gitweb?p=mandelwow.git;a=blobdiff_plain;f=mandelwow.rs;h=80c46d4ba71aefe5f01b0e5c3f19e50611532216;hp=3c4da07d4f6064c4ba538416be0ebf9fc8c45bdf;hb=ae66bb7bf28bd495d38241b643144956c2f9af91;hpb=a351d13b67d0dab55fa1ab1378a7f9554e06a231 diff --git a/mandelwow.rs b/mandelwow.rs index 3c4da07..80c46d4 100644 --- a/mandelwow.rs +++ b/mandelwow.rs @@ -4,6 +4,8 @@ extern crate glium; extern crate glutin; +extern crate libxm; +extern crate sdl2; use glium::{DisplayBuild, Surface}; use glium::index::{IndexBuffer, PrimitiveType}; @@ -11,6 +13,7 @@ use glutin::ElementState::Pressed; use glutin::Event::KeyboardInput; use glutin::VirtualKeyCode; +mod sound; mod support; #[derive(Copy, Clone)] @@ -81,8 +84,8 @@ fn mandelwow_program(display: &glium::Display) -> glium::Program { float zx2 = zx * zx; float zy2 = zy * zy; if (zx2 * zy2 > 4.0) { - float index = 1.0 - float(iter) / float(maxiter); - f_color = vec4(index, index * 0.5, index, index * 0.5); + float index = float(iter) / float(maxiter); + f_color = vec4(index, 0.1, 0.5 - index / 2, 0.8 - index); return; } zy = zx * zy * 2.0 + c.y; @@ -154,10 +157,10 @@ fn bounding_box(display: &glium::Display, depth: glium::Depth { test: glium::draw_parameters::DepthTest::IfLess, write: true, - .. Default::default() + ..Default::default() }, blend: glium::Blend::alpha_blending(), - .. Default::default() + ..Default::default() }; let front_indices = IndexBuffer::new(display, PrimitiveType::LineLoop, @@ -232,10 +235,10 @@ fn mandel(display: &glium::Display, depth: glium::Depth { test: glium::draw_parameters::DepthTest::IfLess, write: true, - .. Default::default() + ..Default::default() }, blend: glium::Blend::alpha_blending(), - .. Default::default() + ..Default::default() }; frame.draw(&vb, &indices, program, uniforms, ¶ms).unwrap(); @@ -249,12 +252,13 @@ fn mandelwow(display: &glium::Display, bounds: &Cube, mandel_w: f32) { let mut z0 = [mandel_w, 0f32]; - let zres = 50; + let zres = 30; let zmin = bounds.zmin; let zmax = bounds.zmax; let zstep = (zmax - zmin) / zres as f32; let mut zy = zmin; - for _ in 0..zres { + // zres + 1 to reach the other face of the cube (fencepost error) + for _ in 0..(zres + 1) { z0[1] = zy; zy += zstep; @@ -270,6 +274,8 @@ fn mandelwow(display: &glium::Display, } fn main() { + sound::start(); + let display = glium::glutin::WindowBuilder::new() //.with_dimensions(1024, 768) .with_fullscreen(glutin::get_primary_monitor()) @@ -302,8 +308,8 @@ fn main() { xmax: 0.7, ymin: -1.0, ymax: 1.0, - zmin: -1.2, - zmax: 1.2, + zmin: -1.1, + zmax: 1.1, }; // Vary the wow factor to slice the Mandelwow along its 4th dimension. @@ -325,8 +331,8 @@ fn main() { [ 0.0, 0.0, z_trans, 1.0f32] ]; - // Draw the bounding box before the fractal, when the Z-buffer is still clear, so the lines - // behind the semi-translucent areas will be drawn. + // Draw the bounding box before the fractal, when the Z-buffer is still clear, + // so the lines behind the semi-translucent areas will be drawn. if bounding_box_enabled { let uniforms = uniform! { model: model,