Hg200

Joined 29 March 2020
373 bytes added ,  4 January 2021
m
no edit summary
mNo edit summary
mNo edit summary
 
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 = diag([1, 1, 1, 1])
   // 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 = diag([1, 1, 1, 1])
   // 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 so that the image fits tightly into the bounding box. The z-coordinate is not modified!
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 projection matrix are loaded on the matrix stack.
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">
Line 169: Line 175:
   m_glfcns.glLoadIdentity ();
   m_glfcns.glLoadIdentity ();
   m_glfcns.glScaled (1, 1, -1);
   m_glfcns.glScaled (1, 1, -1);
   // Matrix x_gl_mat2
   // Matrix x_gl_mat1
   m_glfcns.glMultMatrixd (x_mat1.data ());
   m_glfcns.glMultMatrixd (x_mat1.data ());
   m_glfcns.glMatrixMode (GL_PROJECTION);
   m_glfcns.glMatrixMode (GL_PROJECTION);
Line 175: Line 181:


   Matrix vp = get_viewport_scaled ();
   Matrix vp = get_viewport_scaled ();
   // Install Orthographic Projection Matrix with viewport
   // Install orthographic projection matrix with viewport
   // setting 0, vp(2), vp(3), 0 and near / far values xZ1, xZ2
   // setting "0, vp(2), vp(3), 0" and near / far values "xZ1, xZ2"
   m_glfcns.glOrtho (0, vp(2), vp(3), 0, xZ1, xZ2);
   m_glfcns.glOrtho (0, vp(2), vp(3), 0, xZ1, xZ2);
   // Matrix x_gl_mat2
   // Matrix x_gl_mat2
Line 185: Line 191:


</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.
20

edits