Editing User:Hg200
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 79: | Line 79: | ||
(gdb) print *bb.rep.data@bb.rep.len | (gdb) print *bb.rep.data@bb.rep.len | ||
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"); | ||
=== x_projection === | === x_projection === | ||
Line 118: | Line 112: | ||
v_angle = get_cameraviewangle (); | v_angle = get_cameraviewangle (); | ||
// x_projection | // x_projection = 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 143: | Line 137: | ||
pix = (bb(2) < bb(3) ? bb(2) : bb(3)); | pix = (bb(2) < bb(3) ? bb(2) : bb(3)); | ||
// x_viewport | // x_viewport = 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 153: | Line 147: | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
Note: The matrix "x_gl_mat2" scales x, y. | 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! | ||
= setup_opengl_transformation () = | = setup_opengl_transformation () = | ||
Line 159: | Line 153: | ||
== 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 projection matrix are loaded on the matrix stack. | ||
{{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 175: | Line 169: | ||
m_glfcns.glLoadIdentity (); | m_glfcns.glLoadIdentity (); | ||
m_glfcns.glScaled (1, 1, -1); | m_glfcns.glScaled (1, 1, -1); | ||
// Matrix | // Matrix x_gl_mat2 | ||
m_glfcns.glMultMatrixd (x_mat1.data ()); | m_glfcns.glMultMatrixd (x_mat1.data ()); | ||
m_glfcns.glMatrixMode (GL_PROJECTION); | m_glfcns.glMatrixMode (GL_PROJECTION); | ||
Line 181: | Line 175: | ||
Matrix vp = get_viewport_scaled (); | Matrix vp = get_viewport_scaled (); | ||
// Install | // Install Orthographic Projection Matrix with viewport | ||
// setting | // 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 191: | Line 185: | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||