This commit is contained in:
shenjack-mac 2023-02-08 21:39:06 +08:00
parent baf8d0e7c6
commit 2aa19fce49
5 changed files with 25 additions and 57 deletions

View File

@ -210,16 +210,6 @@ class SR1ShipRender(BaseScreen):
self.debug_d_pos_label.text = f'x: {self.camera_rs.dx} y: {self.camera_rs.dy}' self.debug_d_pos_label.text = f'x: {self.camera_rs.dx} y: {self.camera_rs.dy}'
self.debug_d_pos_label.position = self.camera_rs.dx + (self.window_pointer.width / 2), self.camera_rs.dy + ( self.debug_d_pos_label.position = self.camera_rs.dx + (self.window_pointer.width / 2), self.camera_rs.dy + (
self.window_pointer.height / 2) + 10, 0 self.window_pointer.height / 2) + 10, 0
# if DR_option.use_DR_rust:
# # print(f'{self.dx=} {self.dy=} {self.scale=}')
# # from objprint import op
# # op(random.choices(self.parts_sprite), indent=1)
# return better_update_parts(self, SR1ShipRender_Option, self.window_pointer,
# self.rust_parts, 60)
# for part_id in self.part_data:
# # x y scale
# self.parts_sprite[part_id].x = self.part_data[part_id].x * 60 + self.window_pointer.width / 2
# self.parts_sprite[part_id].y = self.part_data[part_id].y * 60 + self.window_pointer.height / 2
self.need_update_parts = False self.need_update_parts = False
def on_draw(self): def on_draw(self):
@ -308,13 +298,18 @@ class SR1ShipRender(BaseScreen):
self.debug_mouse_delta_line.visible = SR1ShipRender_Option.debug_mouse_d_pos self.debug_mouse_delta_line.visible = SR1ShipRender_Option.debug_mouse_d_pos
# print('sr1 mouse') # print('sr1 mouse')
elif command.re_match('get_buf'): elif command.re_match('get_buf'):
import pyglet
def screenshot(window): def screenshot(window):
from libs.pyglet.gl.gl import GLubyte, GL_RGBA, GL_UNSIGNED_BYTE, glReadPixels from libs.pyglet.gl import GLubyte, GLint, GL_RGBA, GL_UNSIGNED_BYTE, \
glReadPixels, glGetIntegerv
# from libs.pyglet.gl.gl_compat import GL_AUX_BUFFERS, GL_AUX0
import pyglet
width = window.width width = window.width
height = window.height height = window.height
format_str = "RGBA" format_str = "RGBA"
buffer_count = GLint(0)
# glGetIntegerv(GL_AUX_BUFFERS, buffer_count)
print(buffer_count)
buf = (GLubyte * (len(format_str) * width * height))() buf = (GLubyte * (len(format_str) * width * height))()
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buf) glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buf)
# print(buf) # print(buf)

View File

@ -8,8 +8,8 @@ fonts_folder = "libs/fonts"
[window] [window]
style = "None" style = "None"
width = 2123 width = 1358
height = 1266 height = 739
visible = true visible = true
gui_scale = 1 gui_scale = 1
caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}" caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}"

View File

@ -8,6 +8,7 @@
mod sr1_render; mod sr1_render;
mod render; mod render;
mod types;
use pyo3::prelude::*; use pyo3::prelude::*;
@ -33,6 +34,5 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?; m.add_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?;
m.add_class::<sr1_render::types::PartDatas>()?; m.add_class::<sr1_render::types::PartDatas>()?;
m.add_class::<render::camera::CameraRs>()?; m.add_class::<render::camera::CameraRs>()?;
// m.add_class::<render::camera::CenterCameraRs>()?;
Ok(()) Ok(())
} }

View File

@ -126,46 +126,4 @@ pub mod camera {
return Ok(()) return Ok(())
} }
} }
// #[pymethods]
// impl CenterCameraRs {
// #[new]
// pub fn py_new() -> (Self, CameraRs) {
// (CenterCameraRs, CameraRs)
// }
//
// pub fn begin(self_: PyRef<'_, Self>) -> PyResult<()> {
// let super = self_.as_ref();
// Python::with_gil(|py| -> PyResult<()> {
// // let x = self
// let view = super.window.getattr(py, intern!(py, "view"))?;
//
// let args = ((super.dx * super.zoom, super.dy * super.zoom, 0), );
// let view_matrix = view.call_method1(py, intern!(py, "translate"), args)?;
//
// let args = ((super.zoom, super.zoom, 1), );
// let view_matrix = view_matrix.call_method1(py, intern!(py, "scale"), args)?;
//
// super.window.setattr(py, intern!(py, "view"), view_matrix)?;
// Ok(())
// })?;
// return Ok(())
// }
// pub fn end(&self) -> PyResult<()> {
// Python::with_gil(|py| -> PyResult<()> {
// let view = self.window.getattr(py, intern!(py, "view"))?;
//
// let args = ((1.0 / self.zoom, 1.0 / self.zoom, 1), );
// let view_matrix = view.call_method1(py, intern!(py, "scale"), args)?;
//
// let args = ((-self.dx * self.zoom, -self.dy * self.zoom, 0), );
// let view_matrix = view_matrix.call_method1(py, intern!(py, "translate"), args)?;
//
// self.window.setattr(py, intern!(py, "view"), view_matrix)?;
// Ok(())
// })?;
// return Ok(())
// }
// }
} }

View File

@ -0,0 +1,15 @@
/*
* -------------------------------
* Difficult Rocket
* Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
* All rights reserved
* -------------------------------
*/
pub mod sr1 {
pub mod data {
}
}