mirror of https://github.com/Leinnan/doppler.git
Camera display imgui, imgui design fixes
This commit is contained in:
parent
d78ba01130
commit
a48a8ab252
|
|
@ -162,20 +162,26 @@ impl Client for ExampleClient {
|
||||||
menu_bar.end(ui);
|
menu_bar.end(ui);
|
||||||
}
|
}
|
||||||
if self.show_camera_info {
|
if self.show_camera_info {
|
||||||
let text = format!("{:?}", self.camera)
|
|
||||||
.replace("{", "{\n")
|
|
||||||
.replace("}", "\n}")
|
|
||||||
.replace("],", "],\n");
|
|
||||||
Window::new(im_str!("CameraInfo"))
|
Window::new(im_str!("CameraInfo"))
|
||||||
.size([300.0, 300.0], Condition::Always)
|
.size([260.0, 430.0], Condition::Always)
|
||||||
.position([50.0, 50.0], Condition::Always)
|
.position([40.0, 40.0], Condition::Always)
|
||||||
.title_bar(false)
|
.title_bar(false)
|
||||||
.scroll_bar(false)
|
.scroll_bar(false)
|
||||||
|
.no_inputs()
|
||||||
|
.bg_alpha(0.8)
|
||||||
.collapsible(false)
|
.collapsible(false)
|
||||||
.build(&ui, || {
|
.build(&ui, || {
|
||||||
ui.text(im_str!("Camera info"));
|
ui.text(im_str!("Camera info"));
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.text(text);
|
<Camera as imgui_inspect::InspectRenderDefault<Camera>>::render(
|
||||||
|
&[&self.camera],
|
||||||
|
&"CameraInfo",
|
||||||
|
ui,
|
||||||
|
&imgui_inspect::InspectArgsDefault {
|
||||||
|
header: Some(false),
|
||||||
|
..imgui_inspect::InspectArgsDefault::default()
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if self.show_object_info {
|
if self.show_object_info {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use crate::gaia::imgui_helper::*;
|
||||||
use cgmath;
|
use cgmath;
|
||||||
use cgmath::prelude::*;
|
use cgmath::prelude::*;
|
||||||
use cgmath::vec3;
|
use cgmath::vec3;
|
||||||
|
use imgui_glfw_rs::imgui;
|
||||||
|
use imgui_inspect_derive::Inspect;
|
||||||
|
|
||||||
type Point3 = cgmath::Point3<f32>;
|
type Point3 = cgmath::Point3<f32>;
|
||||||
type Vector3 = cgmath::Vector3<f32>;
|
type Vector3 = cgmath::Vector3<f32>;
|
||||||
|
|
@ -25,13 +28,18 @@ const SPEED: f32 = 2.5;
|
||||||
const SENSITIVTY: f32 = 0.1;
|
const SENSITIVTY: f32 = 0.1;
|
||||||
const ZOOM: f32 = 45.0;
|
const ZOOM: f32 = 45.0;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Inspect, Debug, Clone, Copy)]
|
||||||
pub struct Camera {
|
pub struct Camera {
|
||||||
// Camera Attributes
|
// Camera Attributes
|
||||||
|
#[inspect(proxy_type = "CgmathPoint3f32")]
|
||||||
pub position: Point3,
|
pub position: Point3,
|
||||||
|
#[inspect(proxy_type = "CgmathVec3f32")]
|
||||||
pub front: Vector3,
|
pub front: Vector3,
|
||||||
|
#[inspect(proxy_type = "CgmathVec3f32")]
|
||||||
pub up: Vector3,
|
pub up: Vector3,
|
||||||
|
#[inspect(proxy_type = "CgmathVec3f32")]
|
||||||
pub right: Vector3,
|
pub right: Vector3,
|
||||||
|
#[inspect(proxy_type = "CgmathVec3f32")]
|
||||||
pub worldup: Vector3,
|
pub worldup: Vector3,
|
||||||
// Euler Angles
|
// Euler Angles
|
||||||
pub yaw: f32,
|
pub yaw: f32,
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ impl Engine {
|
||||||
)
|
)
|
||||||
.no_decoration()
|
.no_decoration()
|
||||||
.no_inputs()
|
.no_inputs()
|
||||||
|
.bg_alpha(0.8)
|
||||||
.save_settings(false)
|
.save_settings(false)
|
||||||
.build(&ui, || {
|
.build(&ui, || {
|
||||||
ui.text("Welcome in doppler world!");
|
ui.text("Welcome in doppler world!");
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ pub struct FramebufferSystem {
|
||||||
|
|
||||||
impl Drop for FramebufferSystem {
|
impl Drop for FramebufferSystem {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
println!("Drop framebuffer!");
|
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::DeleteVertexArrays(1, &self.vao);
|
gl::DeleteVertexArrays(1, &self.vao);
|
||||||
gl::DeleteBuffers(1, &self.vbo);
|
gl::DeleteBuffers(1, &self.vbo);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
use cgmath::Vector3;
|
use cgmath::{Point3, Vector3};
|
||||||
use imgui_glfw_rs::imgui;
|
use imgui_glfw_rs::imgui;
|
||||||
use imgui_inspect::InspectArgsDefault;
|
use imgui_inspect::InspectArgsDefault;
|
||||||
use imgui_inspect::InspectRenderDefault;
|
use imgui_inspect::InspectRenderDefault;
|
||||||
|
|
||||||
|
pub struct CgmathPoint3f32;
|
||||||
pub struct CgmathVec3f32;
|
pub struct CgmathVec3f32;
|
||||||
impl InspectRenderDefault<Vector3<f32>> for CgmathVec3f32 {
|
impl InspectRenderDefault<Vector3<f32>> for CgmathVec3f32 {
|
||||||
fn render(
|
fn render(
|
||||||
|
|
@ -12,7 +13,10 @@ impl InspectRenderDefault<Vector3<f32>> for CgmathVec3f32 {
|
||||||
_args: &InspectArgsDefault,
|
_args: &InspectArgsDefault,
|
||||||
) {
|
) {
|
||||||
ui.text(label);
|
ui.text(label);
|
||||||
ui.text(format!("{:?}", data));
|
for el in data.iter() {
|
||||||
|
let text = format!("X: {:.3}, Y: {:.3}, Z: {:.3}", el.x, el.y, el.z);
|
||||||
|
ui.text(&text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_mut(
|
fn render_mut(
|
||||||
|
|
@ -35,3 +39,38 @@ impl InspectRenderDefault<Vector3<f32>> for CgmathVec3f32 {
|
||||||
change
|
change
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl InspectRenderDefault<Point3<f32>> for CgmathPoint3f32 {
|
||||||
|
fn render(
|
||||||
|
data: &[&Point3<f32>],
|
||||||
|
label: &'static str,
|
||||||
|
ui: &imgui::Ui,
|
||||||
|
_args: &InspectArgsDefault,
|
||||||
|
) {
|
||||||
|
ui.text(label);
|
||||||
|
for el in data.iter() {
|
||||||
|
let text = format!("X: {:.3}, Y: {:.3}, Z: {:.3}", el.x, el.y, el.z);
|
||||||
|
ui.text(&text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_mut(
|
||||||
|
data: &mut [&mut Point3<f32>],
|
||||||
|
label: &'static str,
|
||||||
|
ui: &imgui::Ui,
|
||||||
|
_args: &InspectArgsDefault,
|
||||||
|
) -> bool {
|
||||||
|
use imgui::*;
|
||||||
|
let label_im = im_str!("##x,y,z{}", label);
|
||||||
|
ui.text(label);
|
||||||
|
let mut change = false;
|
||||||
|
for el in data.iter_mut() {
|
||||||
|
let mut array: [f32; 3] = [el.x, el.y, el.z];
|
||||||
|
change |= ui.drag_float3(&label_im, &mut array).build();
|
||||||
|
el.x = array[0];
|
||||||
|
el.y = array[1];
|
||||||
|
el.z = array[2];
|
||||||
|
}
|
||||||
|
change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ pub struct Texture {
|
||||||
|
|
||||||
impl Drop for Texture {
|
impl Drop for Texture {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe { gl::DeleteTextures(1, &self.id); }
|
unsafe {
|
||||||
|
gl::DeleteTextures(1, &self.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use gl::types::*;
|
||||||
|
|
||||||
use crate::gaia::consts;
|
use crate::gaia::consts;
|
||||||
use cgmath::prelude::*;
|
use cgmath::prelude::*;
|
||||||
use cgmath::{Matrix, Matrix4, Vector3, Vector2};
|
use cgmath::{Matrix, Matrix4, Vector2, Vector3};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Shader {
|
pub struct Shader {
|
||||||
|
|
@ -19,7 +19,9 @@ pub struct Shader {
|
||||||
|
|
||||||
impl Drop for Shader {
|
impl Drop for Shader {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe{gl::DeleteShader(self.ID);}
|
unsafe {
|
||||||
|
gl::DeleteShader(self.ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue