Use iterators for the generalization of the ground vertex and fragment shaders
This commit is contained in:
+19
-17
@@ -65,30 +65,32 @@ fn main() {
|
|||||||
glium::texture::SrgbTexture2d::new(&display, image).unwrap()
|
glium::texture::SrgbTexture2d::new(&display, image).unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut uniform_sampler_2d_str: String = "".to_string();
|
let uniform_sampler_2d_str = (0..BIOMES_NUMBER)
|
||||||
for i in 1..BIOMES_NUMBER {
|
.map(|i| format!("tex{}", i))
|
||||||
uniform_sampler_2d_str += &format!(", tex{}", i);
|
.collect::<Vec<String>>()
|
||||||
}
|
.join(", ");
|
||||||
|
|
||||||
let mut switch_v_biome_str: String = "".to_string();
|
let switch_v_biome_str = (0..BIOMES_NUMBER)
|
||||||
for i in 0..BIOMES_NUMBER {
|
.map(|i| {
|
||||||
switch_v_biome_str += &format!(
|
format!(
|
||||||
"
|
"
|
||||||
case {}u:
|
case {}u:
|
||||||
f_color = texture(tex{}, v_tex_coords);
|
f_color = texture(tex{}, v_tex_coords);
|
||||||
break;
|
break;
|
||||||
",
|
",
|
||||||
i, i
|
i, i
|
||||||
);
|
)
|
||||||
}
|
})
|
||||||
switch_v_biome_str += &format!(
|
.collect::<Vec<String>>()
|
||||||
"
|
.join("")
|
||||||
|
+ &format!(
|
||||||
|
"
|
||||||
default: // case {}u:
|
default: // case {}u:
|
||||||
f_color = texture(tex{}, v_tex_coords);
|
f_color = texture(tex{}, v_tex_coords);
|
||||||
",
|
",
|
||||||
BIOMES_NUMBER - 1,
|
BIOMES_NUMBER - 1,
|
||||||
BIOMES_NUMBER - 1
|
BIOMES_NUMBER - 1
|
||||||
);
|
);
|
||||||
|
|
||||||
let fragment = &format!(
|
let fragment = &format!(
|
||||||
"
|
"
|
||||||
@@ -99,7 +101,7 @@ fn main() {
|
|||||||
|
|
||||||
out vec4 f_color;
|
out vec4 f_color;
|
||||||
|
|
||||||
uniform sampler2D tex0{};
|
uniform sampler2D {};
|
||||||
|
|
||||||
void main() {{
|
void main() {{
|
||||||
switch (v_biome) {{
|
switch (v_biome) {{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub struct CameraState {
|
|||||||
rotate_right: bool,
|
rotate_right: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const SPEED: f32 = 1.0; //1.0;
|
const SPEED: f32 = 100.0; //1.0;
|
||||||
|
|
||||||
impl CameraState {
|
impl CameraState {
|
||||||
pub fn new() -> CameraState {
|
pub fn new() -> CameraState {
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
|
|||||||
.path()
|
.path()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.replace("Extensions/LemnosLife/Map/Altis/Ground/", "")
|
.replace(ground_folder, "")
|
||||||
.replace(".height", "");
|
.replace(".height", "");
|
||||||
println!("{}", file_name);
|
println!("{}", file_name);
|
||||||
let file_name_parts: Vec<&str> = file_name.split(' ').collect();
|
let file_name_parts: Vec<&str> = file_name.split(' ').collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user