mirror of
https://github.com/emilk/egui.git
synced 2026-06-28 07:23:13 -04:00
Rename Triangles to Mesh
This commit is contained in:
@@ -65,7 +65,7 @@ impl WebBackend {
|
||||
self.painter.upload_egui_texture(&self.ctx.texture());
|
||||
self.painter.clear(clear_color);
|
||||
self.painter
|
||||
.paint_jobs(paint_jobs, self.ctx.pixels_per_point())
|
||||
.paint_meshes(paint_jobs, self.ctx.pixels_per_point())
|
||||
}
|
||||
|
||||
pub fn painter_debug_info(&self) -> String {
|
||||
|
||||
@@ -12,5 +12,6 @@ pub trait Painter {
|
||||
|
||||
fn clear(&mut self, lear_color: egui::Rgba);
|
||||
|
||||
fn paint_jobs(&mut self, jobs: egui::PaintJobs, pixels_per_point: f32) -> Result<(), JsValue>;
|
||||
fn paint_meshes(&mut self, jobs: egui::PaintJobs, pixels_per_point: f32)
|
||||
-> Result<(), JsValue>;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use {
|
||||
|
||||
use egui::{
|
||||
math::clamp,
|
||||
paint::{Color32, PaintJobs, Texture, Triangles},
|
||||
paint::{Color32, Mesh, PaintJobs, Texture},
|
||||
vec2,
|
||||
};
|
||||
|
||||
@@ -265,21 +265,21 @@ impl WebGlPainter {
|
||||
}
|
||||
}
|
||||
|
||||
fn paint_triangles(&self, triangles: &Triangles) -> Result<(), JsValue> {
|
||||
debug_assert!(triangles.is_valid());
|
||||
let indices: Vec<u16> = triangles.indices.iter().map(|idx| *idx as u16).collect();
|
||||
fn paint_mesh(&self, mesh: &Mesh) -> Result<(), JsValue> {
|
||||
debug_assert!(mesh.is_valid());
|
||||
let indices: Vec<u16> = mesh.indices.iter().map(|idx| *idx as u16).collect();
|
||||
|
||||
let mut positions: Vec<f32> = Vec::with_capacity(2 * triangles.vertices.len());
|
||||
let mut tex_coords: Vec<f32> = Vec::with_capacity(2 * triangles.vertices.len());
|
||||
for v in &triangles.vertices {
|
||||
let mut positions: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());
|
||||
let mut tex_coords: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());
|
||||
for v in &mesh.vertices {
|
||||
positions.push(v.pos.x);
|
||||
positions.push(v.pos.y);
|
||||
tex_coords.push(v.uv.x);
|
||||
tex_coords.push(v.uv.y);
|
||||
}
|
||||
|
||||
let mut colors: Vec<u8> = Vec::with_capacity(4 * triangles.vertices.len());
|
||||
for v in &triangles.vertices {
|
||||
let mut colors: Vec<u8> = Vec::with_capacity(4 * mesh.vertices.len());
|
||||
for v in &mesh.vertices {
|
||||
colors.push(v.color[0]);
|
||||
colors.push(v.color[1]);
|
||||
colors.push(v.color[2]);
|
||||
@@ -478,7 +478,7 @@ impl crate::Painter for WebGlPainter {
|
||||
gl.clear(Gl::COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
fn paint_jobs(&mut self, jobs: PaintJobs, pixels_per_point: f32) -> Result<(), JsValue> {
|
||||
fn paint_meshes(&mut self, jobs: PaintJobs, pixels_per_point: f32) -> Result<(), JsValue> {
|
||||
self.upload_user_textures();
|
||||
|
||||
let gl = &self.gl;
|
||||
@@ -504,8 +504,8 @@ impl crate::Painter for WebGlPainter {
|
||||
let u_sampler_loc = gl.get_uniform_location(&self.program, "u_sampler").unwrap();
|
||||
gl.uniform1i(Some(&u_sampler_loc), 0);
|
||||
|
||||
for (clip_rect, triangles) in jobs {
|
||||
if let Some(gl_texture) = self.get_texture(triangles.texture_id) {
|
||||
for (clip_rect, mesh) in jobs {
|
||||
if let Some(gl_texture) = self.get_texture(mesh.texture_id) {
|
||||
gl.bind_texture(Gl::TEXTURE_2D, Some(gl_texture));
|
||||
|
||||
let clip_min_x = pixels_per_point * clip_rect.min.x;
|
||||
@@ -529,13 +529,13 @@ impl crate::Painter for WebGlPainter {
|
||||
clip_max_y - clip_min_y,
|
||||
);
|
||||
|
||||
for triangles in triangles.split_to_u16() {
|
||||
self.paint_triangles(&triangles)?;
|
||||
for mesh in mesh.split_to_u16() {
|
||||
self.paint_mesh(&mesh)?;
|
||||
}
|
||||
} else {
|
||||
crate::console_warn(format!(
|
||||
"WebGL: Failed to find texture {:?}",
|
||||
triangles.texture_id
|
||||
mesh.texture_id
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use {
|
||||
|
||||
use egui::{
|
||||
math::clamp,
|
||||
paint::{Color32, PaintJobs, Texture, Triangles},
|
||||
paint::{Color32, Mesh, PaintJobs, Texture},
|
||||
vec2,
|
||||
};
|
||||
|
||||
@@ -255,21 +255,21 @@ impl WebGl2Painter {
|
||||
}
|
||||
}
|
||||
|
||||
fn paint_triangles(&self, triangles: &Triangles) -> Result<(), JsValue> {
|
||||
debug_assert!(triangles.is_valid());
|
||||
let indices: Vec<u16> = triangles.indices.iter().map(|idx| *idx as u16).collect();
|
||||
fn paint_mesh(&self, mesh: &Mesh) -> Result<(), JsValue> {
|
||||
debug_assert!(mesh.is_valid());
|
||||
let indices: Vec<u16> = mesh.indices.iter().map(|idx| *idx as u16).collect();
|
||||
|
||||
let mut positions: Vec<f32> = Vec::with_capacity(2 * triangles.vertices.len());
|
||||
let mut tex_coords: Vec<f32> = Vec::with_capacity(2 * triangles.vertices.len());
|
||||
for v in &triangles.vertices {
|
||||
let mut positions: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());
|
||||
let mut tex_coords: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());
|
||||
for v in &mesh.vertices {
|
||||
positions.push(v.pos.x);
|
||||
positions.push(v.pos.y);
|
||||
tex_coords.push(v.uv.x);
|
||||
tex_coords.push(v.uv.y);
|
||||
}
|
||||
|
||||
let mut colors: Vec<u8> = Vec::with_capacity(4 * triangles.vertices.len());
|
||||
for v in &triangles.vertices {
|
||||
let mut colors: Vec<u8> = Vec::with_capacity(4 * mesh.vertices.len());
|
||||
for v in &mesh.vertices {
|
||||
colors.push(v.color[0]);
|
||||
colors.push(v.color[1]);
|
||||
colors.push(v.color[2]);
|
||||
@@ -467,7 +467,7 @@ impl crate::Painter for WebGl2Painter {
|
||||
gl.clear(Gl::COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
fn paint_jobs(&mut self, jobs: PaintJobs, pixels_per_point: f32) -> Result<(), JsValue> {
|
||||
fn paint_meshes(&mut self, jobs: PaintJobs, pixels_per_point: f32) -> Result<(), JsValue> {
|
||||
self.upload_user_textures();
|
||||
|
||||
let gl = &self.gl;
|
||||
@@ -493,8 +493,8 @@ impl crate::Painter for WebGl2Painter {
|
||||
let u_sampler_loc = gl.get_uniform_location(&self.program, "u_sampler").unwrap();
|
||||
gl.uniform1i(Some(&u_sampler_loc), 0);
|
||||
|
||||
for (clip_rect, triangles) in jobs {
|
||||
if let Some(gl_texture) = self.get_texture(triangles.texture_id) {
|
||||
for (clip_rect, mesh) in jobs {
|
||||
if let Some(gl_texture) = self.get_texture(mesh.texture_id) {
|
||||
gl.bind_texture(Gl::TEXTURE_2D, Some(gl_texture));
|
||||
|
||||
let clip_min_x = pixels_per_point * clip_rect.min.x;
|
||||
@@ -518,13 +518,13 @@ impl crate::Painter for WebGl2Painter {
|
||||
clip_max_y - clip_min_y,
|
||||
);
|
||||
|
||||
for triangles in triangles.split_to_u16() {
|
||||
self.paint_triangles(&triangles)?;
|
||||
for mesh in mesh.split_to_u16() {
|
||||
self.paint_mesh(&mesh)?;
|
||||
}
|
||||
} else {
|
||||
crate::console_warn(format!(
|
||||
"WebGL: Failed to find texture {:?}",
|
||||
triangles.texture_id
|
||||
mesh.texture_id
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user