20
edits
mNo edit summary |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 79: | Line 79: | ||
(gdb) print *bb.rep.data@bb.rep.len | (gdb) print *bb.rep.data@bb.rep.len | ||
(gdb) $1 = {72.79, 31.50, 434, 342.29} | |||
Compare the result with the output on the Octave prompt: | Compare the result with the output on the Octave prompt: | ||
hax = axes (); | hax = axes (); | ||
get (hax, "position") | get (hax, "position") | ||
ans = 73.80 47.20 434.00 342.30 | |||
get (gcf, 'position') | |||
ans = 22 300 560 420 | |||
Where 420 - 342.30 - 31.5 + 1 = 47.20 | |||
=== x_projection === | === x_projection === | ||
Line 112: | Line 118: | ||
v_angle = get_cameraviewangle (); | v_angle = get_cameraviewangle (); | ||
// x_projection | // x_projection: identity "diag([1, 1, 1, 1])" | ||
Matrix x_projection = xform_matrix (); | Matrix x_projection = xform_matrix (); | ||
// Calculate backwards from the angle to the ratio. This step | // Calculate backwards from the angle to the ratio. This step | ||
Line 137: | Line 143: | ||
pix = (bb(2) < bb(3) ? bb(2) : bb(3)); | pix = (bb(2) < bb(3) ? bb(2) : bb(3)); | ||
// x_viewport | // x_viewport: identity "diag([1, 1, 1, 1])" | ||
Matrix x_viewport = xform_matrix (); | Matrix x_viewport = xform_matrix (); | ||
// Move to the center of the bounding box inside the figure. | // Move to the center of the bounding box inside the figure. | ||
Line 147: | Line 153: | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
Note: The matrix "x_gl_mat2" scales x, y | Note: The matrix "x_gl_mat2" scales x, y. However the z-coordinate is not modified! | ||
= setup_opengl_transformation () = | = setup_opengl_transformation () = | ||
Line 153: | Line 159: | ||
== OpenGL backend == | == OpenGL backend == | ||
In the OpenGL backend, the view matrix, an orthographic matrix, and the | In the OpenGL backend, the view matrix, an orthographic matrix, and the viewport transform are used to transform the octave plot into the screen window. | ||
{{Code|Section of opengl_renderer::setup_opengl_transformation ()"|<syntaxhighlight lang="C" style="font-size:13px"> | {{Code|Section of opengl_renderer::setup_opengl_transformation ()"|<syntaxhighlight lang="C" style="font-size:13px"> | ||
Matrix x_zlim = props.get_transform_zlim (); | |||
xZ1 = x_zlim(0)-(x_zlim(1)-x_zlim(0))/2; | |||
xZ2 = x_zlim(1)+(x_zlim(1)-x_zlim(0))/2; | |||
// Load x_gl_mat1 and x_gl_mat2 | |||
Matrix x_mat1 = props.get_opengl_matrix_1 (); | |||
Matrix x_mat2 = props.get_opengl_matrix_2 (); | |||
m_glfcns.glMatrixMode (GL_MODELVIEW); | |||
m_glfcns.glLoadIdentity (); | |||
m_glfcns.glScaled (1, 1, -1); | |||
// Matrix x_gl_mat1 | |||
m_glfcns.glMultMatrixd (x_mat1.data ()); | |||
m_glfcns.glMatrixMode (GL_PROJECTION); | |||
m_glfcns.glLoadIdentity (); | |||
Matrix vp = get_viewport_scaled (); | |||
// Install orthographic projection matrix with viewport | |||
// setting "0, vp(2), vp(3), 0" and near / far values "xZ1, xZ2" | |||
m_glfcns.glOrtho (0, vp(2), vp(3), 0, xZ1, xZ2); | |||
// Matrix x_gl_mat2 | |||
m_glfcns.glMultMatrixd (x_mat2.data ()); | |||
m_glfcns.glMatrixMode (GL_MODELVIEW); | |||
m_glfcns.glClear (GL_DEPTH_BUFFER_BIT); | |||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
Hint: If you debug in "setup_opengl_transformation ()", you can print the viewport "vp": | |||
(gdb) print *vp.rep.data@vp.rep.len | |||
(gdb) $1 = {0, 0, 560, 420} | |||
This is consistent with the window size. |
edits