Add generated textures to repo for now
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/tag Build is failing Details

This commit is contained in:
Sijmen 2021-07-03 13:36:37 +02:00
parent 869598dc98
commit 9259003354
6 changed files with 32 additions and 7 deletions

11
.gitignore vendored
View File

@ -4,7 +4,16 @@
/flamegraph.svg /flamegraph.svg
/perf.data* /perf.data*
/chunks/ /chunks/
/assets
/assets/*
!/assets/grass_block_*.png
!/assets/font
/assets/font/*
!/assets/font/ascii_shadow.png
/release/
profile.txt profile.txt
callgrind.out.* callgrind.out.*

BIN
assets/font/ascii_shadow.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/grass_block_side_plains.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/grass_block_top_plains.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,5 +1,7 @@
use std::convert::TryInto; use std::convert::TryInto;
use anyhow::Context;
use crate::{ use crate::{
geometry::Geometry, geometry_buffers::GeometryBuffers, render_context::RenderContext, geometry::Geometry, geometry_buffers::GeometryBuffers, render_context::RenderContext,
texture::Texture, vertex::HudVertex, texture::Texture, vertex::HudVertex,
@ -27,8 +29,10 @@ pub struct TextRenderer {
impl TextRenderer { impl TextRenderer {
pub fn new(render_context: &RenderContext) -> anyhow::Result<Self> { pub fn new(render_context: &RenderContext) -> anyhow::Result<Self> {
let bytes = std::fs::read("assets/font/ascii_shadow.png")?; let bytes = std::fs::read("assets/font/ascii_shadow.png")
let texture = Texture::from_bytes(render_context, &bytes, "font")?; .context("Failed to load assets/font/ascii_shadow.png")?;
let texture = Texture::from_bytes(render_context, &bytes, "font")
.context("Failed to decode assets/font/ascii_shadow.png")?;
let sampler = render_context let sampler = render_context
.device .device

View File

@ -1,5 +1,6 @@
use std::{num::NonZeroU32, ops::Range}; use std::{num::NonZeroU32, ops::Range};
use anyhow::Context;
use cgmath::{Vector2, Zero}; use cgmath::{Vector2, Zero};
use image::{EncodableLayout, ImageBuffer, Rgba}; use image::{EncodableLayout, ImageBuffer, Rgba};
use wgpu::Origin3d; use wgpu::Origin3d;
@ -317,8 +318,9 @@ impl TextureManager {
} }
pub fn load(&mut self, render_context: &RenderContext, path: &str) -> anyhow::Result<usize> { pub fn load(&mut self, render_context: &RenderContext, path: &str) -> anyhow::Result<usize> {
let bytes = std::fs::read(path)?; let bytes = std::fs::read(path).context(format!("Failed to load {}", path))?;
let texture = Texture::from_bytes(render_context, &bytes, path)?; let texture = Texture::from_bytes(render_context, &bytes, path)
.context(format!("Failed to decode {}", path))?;
let id = self.textures.len(); let id = self.textures.len();
self.textures.push(texture); self.textures.push(texture);
@ -333,8 +335,9 @@ impl TextureManager {
path: &str, path: &str,
tile_size: Vector2<u32>, tile_size: Vector2<u32>,
) -> anyhow::Result<Range<usize>> { ) -> anyhow::Result<Range<usize>> {
let bytes = std::fs::read(path)?; let bytes = std::fs::read(path).context(format!("Failed to load {}", path))?;
let mut textures = Texture::from_bytes_atlas(render_context, &bytes, tile_size, path)?; let mut textures = Texture::from_bytes_atlas(render_context, &bytes, tile_size, path)
.context(format!("Failed to decode {}", path))?;
let start = self.textures.len(); let start = self.textures.len();
self.textures.append(&mut textures); self.textures.append(&mut textures);