mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 17:38:10 +00:00
cleanup
This commit is contained in:
1 parent
93b790fe8e
commit
650e106385
3 files changed
+10
-35
No files matched your search
@@ -138,26 +138,10 @@ impl RenderableObject {
|
||||
let img = image::open(&filename)?;
|
||||
|
||||
let mut rgba_image= img.to_rgba();
|
||||
//let mut rgba_image : RgbaImage = ImageBuffer::new(200, 200);
|
||||
|
||||
/*let mut rgba_image = ImageBuffer::from_fn(200, 200, |x, y| {
|
||||
image::Rgba([255u8, 255u8, 0u8, 255u8])
|
||||
});*/
|
||||
|
||||
// This should change the texture to translucent red.
|
||||
/*for pixel in rgba_image.pixels_mut() {
|
||||
pixel.0[0] = 255;
|
||||
pixel.0[1] = 0;
|
||||
pixel.0[2] = 0;
|
||||
pixel.0[3] = 127;
|
||||
}*/
|
||||
|
||||
let width = rgba_image.width();
|
||||
let height = rgba_image.height();
|
||||
|
||||
//let flat_samples = rgba_image.into_flat_samples();
|
||||
//let pixel_data = flat_samples.samples.as_ptr() as *const c_void;
|
||||
|
||||
let img_data = rgba_image.into_raw();
|
||||
let pixel_data = img_data.as_ptr() as *const c_void;
|
||||
|
||||
@@ -166,8 +150,8 @@ impl RenderableObject {
|
||||
println!("Loading texture into OpenGL {}x{}...", width, height);
|
||||
|
||||
unsafe {
|
||||
//gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR as i32);
|
||||
//gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR as i32);
|
||||
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR as i32);
|
||||
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR as i32);
|
||||
|
||||
gl::TexImage2D(
|
||||
gl::TEXTURE_2D,
|
||||
|
||||
@@ -82,10 +82,8 @@ pub struct PointCloudRenderer {
|
||||
|
||||
/// The OpenGL program
|
||||
shader_program_id: GLuint,
|
||||
|
||||
/// The OpenGL vertex shader
|
||||
vertex_shader_id: GLuint,
|
||||
|
||||
/// The OpenGL fragment shader
|
||||
fragment_shader_id: GLuint,
|
||||
|
||||
@@ -94,47 +92,40 @@ pub struct PointCloudRenderer {
|
||||
projection: [f32; 16],
|
||||
view_matrix: [[f32; 4]; 4],
|
||||
projection_matrix: [[f32; 4]; 4],
|
||||
|
||||
/// Matrix applied to each model
|
||||
/// If a model doesn't set its own, it defaults to identity matrix
|
||||
default_model_view_matrix: [[f32; 4]; 4],
|
||||
|
||||
/// Renderer setting: size of the rendered points
|
||||
point_size: u8,
|
||||
|
||||
/// Renderer setting: shading enabled
|
||||
enable_shading: bool,
|
||||
/// Uniform location in the shader program.
|
||||
enable_shading_index: GLint,
|
||||
|
||||
/// Point array size
|
||||
vertex_arrays_size_bytes: Vec<GLsizei>,
|
||||
|
||||
/// Uniform location in the shader program.
|
||||
view_transform_id: Uniform,
|
||||
|
||||
/// Uniform location in the shader program.
|
||||
projection_transform_id: Uniform,
|
||||
|
||||
/// Uniform location in the shader program.
|
||||
model_transform_id: Uniform,
|
||||
|
||||
/// Uniform for object textures in the shader program.
|
||||
object_texture_uniform: Uniform,
|
||||
|
||||
/// Location of the texture coordinate input
|
||||
texture_coordinates_attribute: Attribute,
|
||||
|
||||
/// Uniform location in the shader program.
|
||||
enable_shading_index: GLint,
|
||||
|
||||
/// Uniform location in the shader program.
|
||||
point_cloud_texture_indices: Vec<GLint>,
|
||||
/// 'in vec4 inColor'
|
||||
color_vertex_attribute_location: GLint,
|
||||
|
||||
vertex_array_objects: Vec<VertexArray>,
|
||||
vertex_color_buffer_objects: Vec<Buffer>,
|
||||
|
||||
/// 'in vec4 inColor'
|
||||
color_vertex_attribute_location: GLint,
|
||||
|
||||
renderable_objects: Vec<PositionableObject>
|
||||
}
|
||||
|
||||
@@ -275,7 +266,6 @@ impl PointCloudRenderer {
|
||||
&path, self.shader_program_id)?;
|
||||
|
||||
|
||||
let filename = "/home/bt/dev/storyteller/assets/gamecube_ssbm_pichu/Pichu/singletex/pichu.png";
|
||||
let filename = "/home/bt/dev/storyteller/assets/n64_mario64/yoshi_grp.png";
|
||||
|
||||
renderable_object.load_texture(filename, &self.object_texture_uniform)?;
|
||||
@@ -327,7 +317,6 @@ impl PointCloudRenderer {
|
||||
let mut renderable_object = RenderableObject::from_wavefront(
|
||||
&path, self.shader_program_id)?;
|
||||
|
||||
let filename = "/home/bt/dev/storyteller/assets/n64_mario64/yoshi_grp.png";
|
||||
let filename = "/home/bt/dev/storyteller/assets/gamecube_ssbm_pichu/Pichu/singletex/pichu.png";
|
||||
|
||||
renderable_object.load_texture(filename, &self.object_texture_uniform)?;
|
||||
@@ -466,7 +455,7 @@ impl PointCloudRenderer {
|
||||
pub fn render(&mut self) -> Result<()> {
|
||||
// Animate the models.
|
||||
for obj in self.renderable_objects.iter_mut() {
|
||||
obj.increment_rotation_y(0.15); // TODO: Should be based on wall clock instead
|
||||
obj.increment_rotation_y(0.05); // TODO: Should be based on wall clock instead
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
||||
@@ -21,6 +21,8 @@ void main()
|
||||
//fragmentColor = vec4(texCoord.r, texCoord.g, 127, 255);
|
||||
//fragmentColor = texture2D(objTexture, texCoord); // * 0.80 + color * 0.20;
|
||||
//fragmentColor = 0.5 * texture2D(objTexture, texCoord) + 0.01 * vec4(texCoord.r, texCoord.g, 0, 255);
|
||||
fragmentColor = texture2D(objTexture, texCoord);
|
||||
//vec2 coord = vec2(texCoord.g, texCoord.g);
|
||||
vec2 coord = texCoord;
|
||||
fragmentColor = texture2D(objTexture, coord);
|
||||
//fragmentColor = vertexColor;
|
||||
}
|
||||
Reference in new issue
Block a user