some old changes
This commit is contained in:
parent
623f21aedd
commit
7d17df39b3
5 changed files with 59 additions and 18 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
|
||||
"cmake.configureOnOpen": true
|
||||
}
|
|
@ -9,7 +9,7 @@ project(pixwerx)
|
|||
#
|
||||
# pixwerx ist C++17
|
||||
#
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
set (CMAKE_CXX_STANDARD 23)
|
||||
|
||||
# internal cmake modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/etc/cmake ${CMAKE_MODULE_PATH})
|
||||
|
|
|
@ -39,7 +39,7 @@ struct matrix_transform {
|
|||
}
|
||||
|
||||
inline static
|
||||
matrix_<4,4,T> perspective_frustum(const T &left,const T &right,
|
||||
matrix_<4,4,T> perspective_frustum_rh(const T &left,const T &right,
|
||||
const T &bottom,const T &top,
|
||||
const T &z_near,const T &z_far)
|
||||
{
|
||||
|
@ -48,16 +48,56 @@ struct matrix_transform {
|
|||
frustum(0,0) = T(2) * z_near / (right - left);
|
||||
frustum(1,1) = T(2) * z_near / (top - bottom);
|
||||
|
||||
frustum(0,2) = (right+left)/(right-left); //A
|
||||
frustum(1,2) = (top+bottom)/(top-bottom); //B
|
||||
frustum(2,2) = -(z_far+z_near)/(z_far-z_near); //C
|
||||
frustum(2,3) = -T(2) * z_far*z_near/(z_far-z_near); //D
|
||||
frustum(0,2) = (right+left)/(right-left); //A
|
||||
frustum(1,2) = (top+bottom)/(top-bottom); //B
|
||||
frustum(2,2) = -(z_far+z_near)/(z_far-z_near); //C
|
||||
frustum(2,3) = -T(2) * z_far*z_near/(z_far-z_near); //D
|
||||
|
||||
frustum(3,2) = -T(1);
|
||||
|
||||
return frustum;
|
||||
}
|
||||
|
||||
|
||||
// /// creates a projection from a frustum planes with a reversed depth mapped to [0..1]
|
||||
// pub fn make_projection_rh_from_frustum_reversed(
|
||||
// left: f32,
|
||||
// right: f32,
|
||||
// bottom: f32,
|
||||
// top: f32,
|
||||
// z_near: f32,
|
||||
// z_far: f32,
|
||||
// ) -> Mat4 {
|
||||
// assert!(z_near > 0.0 && z_far > 0.0);
|
||||
|
||||
// // info!("near {:?}", z_near);
|
||||
|
||||
// //
|
||||
// // reversed z 0..1 projection
|
||||
// //
|
||||
// let a = (right + left) / (right - left); // position in frame horizontal
|
||||
// let b = (top + bottom) / (top - bottom); // position in frame vertical
|
||||
|
||||
// let c = z_near / (z_far - z_near); // lower bound
|
||||
// let d = z_far * z_near / (z_far - z_near); // upper bound
|
||||
|
||||
// let sx = 2.0 * z_near / (right - left); // scale x
|
||||
// let sy = 2.0 * z_near / (top - bottom); // scale y
|
||||
|
||||
// // reverse z 0..1
|
||||
// // --------------
|
||||
// // sx 0 a 0
|
||||
// // 0 sy b 0
|
||||
// // 0 0 c d
|
||||
// // 0 0 -1 0
|
||||
|
||||
// Mat4::from_cols(
|
||||
// Vec4::new(sx, 0.0, 0.0, 0.0),
|
||||
// Vec4::new(0.0, sy, 0.0, 0.0),
|
||||
// Vec4::new(a, b, c, -1.0),
|
||||
// Vec4::new(0.0, 0.0, d, 0.0),
|
||||
// )
|
||||
// }
|
||||
inline static
|
||||
matrix_<4,4,T> perspective_projection(const T &field_of_view,
|
||||
const T &aspect_ratio,
|
||||
|
@ -69,7 +109,7 @@ struct matrix_transform {
|
|||
const auto top = right / aspect_ratio;
|
||||
const auto bottom = -top;
|
||||
|
||||
return perspective_frustum(left,right,
|
||||
return perspective_frustum_rh(left,right,
|
||||
bottom,top,
|
||||
z_near,z_far);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
set(GLFW_BUILD_EXAMPLES TRUE CACHE BOOL "Build the GLFW example programs" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "Build the GLFW example programs" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "Build the GLFW test programs" FORCE)
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "Build the GLFW documentation" FORCE)
|
||||
set(GLFW_INSTALL OFF CACHE BOOL "Generate installation target" FORCE)
|
||||
|
||||
#add_subdirectory(glfw-3.2.1)
|
||||
|
||||
add_subdirectory(glfw-3.3.5)
|
||||
add_subdirectory(lua-5.4.2)
|
||||
|
|
|
@ -54,9 +54,14 @@ g.texture_coordinates = { {
|
|||
{ 0.0, 1.0 }
|
||||
} }
|
||||
|
||||
z = -5.0
|
||||
z = 0
|
||||
s = 1
|
||||
|
||||
|
||||
-- 0 --- 3
|
||||
-- | \ |
|
||||
-- 1 --- 2
|
||||
|
||||
-- indices
|
||||
g.indices = {
|
||||
0, 1, 2, -- triangle #1
|
||||
|
@ -74,10 +79,6 @@ g.vertices = {
|
|||
{ -s, s, z }
|
||||
}
|
||||
|
||||
-- 0 --- 3
|
||||
-- | \ |
|
||||
-- 1 --- 2
|
||||
|
||||
g:compute_normals()
|
||||
|
||||
|
||||
|
@ -131,7 +132,7 @@ end
|
|||
local renderer = pw.renderer()
|
||||
|
||||
-- camera position
|
||||
local cam_pos = pw.vector3(0,0,0)
|
||||
local cam_pos = pw.vector3(0,0,5)
|
||||
|
||||
-- model position
|
||||
local model_pos = pw.vector3(0,0,0)
|
||||
|
@ -197,7 +198,7 @@ w.on_update = function(self)
|
|||
s:set_uniform_vec4("color",cl)
|
||||
|
||||
-- specific to our shader
|
||||
s:set_uniform_int("tex_color",0)
|
||||
s:set_uniform_int("tex_color",0) -- unit 0
|
||||
|
||||
-- bind the texture
|
||||
tx:bind()
|
||||
|
@ -228,7 +229,7 @@ while w:update() do
|
|||
if pw.input.get().has_input then
|
||||
|
||||
|
||||
-- somehow works
|
||||
-- somehow (depending on X11/Wayland) works
|
||||
if pw.input.get().input_string == 'f' then
|
||||
w.fullscreen = not w.fullscreen
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue