how to put a 3D object at fixed screen location ?

Hi,

I’m new to OpenGL. Could someone give me an example
show me how to put a 3D object (such as axis) at fixed screen
location (eg. left-bottom corner). And it will not change
position when window re-size.

Thanks
KC

You can use glViewport; for example glViewport(0,0,50,50) will set the drawing area to the bottom left corner (0,0) of the window and 50x50 pixels.

Now if you used the identity matrix for MVP a line from -1,-1 to 1,1 will draw from 0,0 to 50,50 in the window.

Experiment a bit with this like moving the view port with glViewport(100,100,50,50)

1 Like

Hi

Thanks for reply. But that’s not what I want. I want to have one and only one 3D object at fixed screen location, not the whole scene.

For example, I want to draw a small xyz-axis which could show
the orientation of the scene. When I rotate the scene, the small
xyz-axis will rotate, but it always site at left-bottom corner
of the window even when window re-sized.

Regards
KC

Generally, you would draw your fixed item separately. Draw your 3D scene with whatever orientation you need, then set things up again, and draw your locked object on top.

Bruce

Thanks for adding that Bruce

I should have been more clear

glViewport(0,0,window_width,window_height);

render scene

glViewport(0,0,50,50);
glDisable(GL_DEPTH_TEST); // if you want axes on top

render xyz-axes

Hi,

I think I got the big piture, but still need
to try out something …
Thanks.

KC