c - How do I transform glOrtho clipping planes? -


i've created opengl application define viewing volume glortho(). use glulookat() transform points. problem - points fall out of clipping plane because "left behind". , end black screen.

how change viewing volume still tight objects once have been transformed glulookat()?

here's code better illustrate problem:

vector3d eyepos = new vector3d(0.25, 0.25, 0.6); vector3d point = new vector3d(0, 0, 0.001);             vector3d = new vector3d(0, 1,0);             matrix4d mat = matrix4d.lookat(eyepos, point, up);  gl.viewport(0, 0, glcontrol1.width, glcontrol1.height);  gl.matrixmode(matrixmode.projection); gl.loadidentity();   gl.ortho(0, 1, 0, 1, 0, 1);  gl.matrixmode(matrixmode.modelview); gl.loadidentity();    gl.loadmatrix(ref mat); gl.clear(clearbuffermask.colorbufferbit | clearbuffermask.depthbufferbit); gl.enable(enablecap.depthtest); gl.depthmask(true); gl.cleardepth(1.0); gl.color3(color.yellow); gl.begin(primitivetype.triangles); gl.vertex3(0.2, 0.3, 0.01); gl.vertex3(0, 0.600, 0.01); gl.vertex3(0.600, 0.600, 0.01); gl.color3(color.blue); gl.vertex3(0, 0.6, 0.01); gl.vertex3(0.2, 0.3, 0.01); gl.vertex3(0.7, 0.5, 0.03); gl.color3(color.red); gl.vertex3(0.100, 0.000, 0.01); gl.vertex3(0, 0.0, 0.01); gl.vertex3(0.600, 0.600, 0.03);  gl.end(); glcontrol1.swapbuffers(); 

i suppose more succinct revision of question how transform 2 points lookat matrix?("mat" in code)

okay, got problem.

you set camera position (0.25, 0.25, 0.6) , point @ view direction (-0.25, -0.25, -0.599) (has normalised). mentioned in comment below question, drawing cube in upper right corner of view direction. 2 points (0.25, 0.25, 0.6) (the camera position) , point defined camera position , view direction, vector , right vector (have @ this) define cube of things shown on screen (the 2 points define diagonal within cube). unfortunatly, of points not within cube.

may be, mixed camera position point wanna at? change of 2 values should solve problem. rest of code seems correct. thing have check whether points within clip space of projections. solution check points are, use, e.g. keyboard input, move camera dynamically.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -