diff --git a/shaders/shader.vert b/shaders/shader.vert index 76bf4e0..1ffef71 100644 --- a/shaders/shader.vert +++ b/shaders/shader.vert @@ -16,7 +16,7 @@ layout(location = 0) out vec3 geoColor; layout(location = 1) out vec2 geoTexCoord; void main() { - gl_Position = ubo.geom_rot * ubo.model * vec4(inPosition, 1.0); + gl_Position = ubo.proj * ubo.view * ubo.geom_rot * ubo.model * vec4(inPosition, 1.0); geoColor = inColor; geoTexCoord = inTexCoord; } \ No newline at end of file diff --git a/shaders/vert.spv b/shaders/vert.spv index 308206e..d3b1d59 100644 Binary files a/shaders/vert.spv and b/shaders/vert.spv differ diff --git a/src/main.rs b/src/main.rs index 4fdb3a8..0fb944e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -669,7 +669,7 @@ unsafe fn create_pipeline(device: &Device, data: &mut app_data::AppData) -> Resu .vertex_attribute_descriptions(&attribute_descriptions); let input_assembly_state = vk::PipelineInputAssemblyStateCreateInfo::builder() - .topology(vk::PrimitiveTopology::POINT_LIST) + .topology(vk::PrimitiveTopology::TRIANGLE_LIST) .primitive_restart_enable(false); let viewport = vk::Viewport::builder() @@ -735,7 +735,7 @@ unsafe fn create_pipeline(device: &Device, data: &mut app_data::AppData) -> Resu data.pipeline_layout = device.create_pipeline_layout(&layout_info, None)?; - let stages = &[vert_stage, geo_stage, frag_stage]; + let stages = &[vert_stage, frag_stage]; let info = vk::GraphicsPipelineCreateInfo::builder() .stages(stages) .vertex_input_state(&vertex_input_state) diff --git a/src/scene.rs b/src/scene.rs index ed131a2..f1d91d8 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -21,39 +21,70 @@ pub struct Scene { impl Scene { pub unsafe fn prepare_data(&mut self, instance: &vulkanalia::Instance, device: &vulkanalia::Device, data: &AppData) -> Result<()> { - self.vertices.push( - vertex::Vertex::new(vec3(8.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0), vec2(0.0, 0.0)) - ); - self.indices.push(0); - self.vertices.push( - vertex::Vertex::new(vec3(-8.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0), vec2(0.0, 0.0)) - ); - self.indices.push(1); - - self.vertices.push( - vertex::Vertex::new(vec3(0.0, 8.0, 0.0), vec3(1.0, 1.0, 0.0), vec2(0.0, 0.0)) - ); - self.indices.push(2); - - self.vertices.push( - vertex::Vertex::new(vec3(0.0, -8.0, 0.0), vec3(0.0, 1.0, 1.0), vec2(0.0, 0.0)) - ); - self.indices.push(3); - - let grid_size = 1; + let grid_size = 1000; for x_index in -grid_size..grid_size { for y_index in -grid_size..grid_size { - if !(((x_index as i32).abs() == 8 && y_index == 0) || (x_index == 0 && (y_index as i32).abs() == 8)){ - let index = self.indices.len(); - let vert = vertex::Vertex::new( - vec3(x_index as f32, y_index as f32, 0.0), - vec3(0.0, 1.0, 0.0), - vec2(0.0, 0.0) - ); - self.vertices.push(vert); - self.indices.push(index as u32); - } + let index = self.vertices.len(); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 - 0.5, y_index as f32 + 0.5, 0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.indices.push(index as u32); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 - 0.5, y_index as f32 - 0.5, 0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.indices.push(index as u32 + 1); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 + 0.5, y_index as f32 + 0.5, 0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.indices.push(index as u32 + 2); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 + 0.5, y_index as f32 - 0.5, 0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.indices.push(index as u32 + 2); + self.indices.push(index as u32 + 1); + self.indices.push(index as u32 + 3); + } + } + + for x_index in -grid_size..grid_size { + for y_index in -grid_size..grid_size { + let index = self.vertices.len(); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 - 0.5, y_index as f32 + 0.5, -0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 - 0.5, y_index as f32 - 0.5, -0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 + 0.5, y_index as f32 + 0.5, -0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.vertices.push(vertex::Vertex::new( + vec3(x_index as f32 + 0.5, y_index as f32 - 0.5, -0.5), + vec3(0.0, 1.0, 0.0), + vec2(0.0, 0.0) + )); + self.indices.push(index as u32 + 2); + self.indices.push(index as u32 + 1); + self.indices.push(index as u32); + + self.indices.push(index as u32 + 3); + self.indices.push(index as u32 + 1); + self.indices.push(index as u32 + 2); } }