PDA

View Full Version : How to set borders for the screen?



09-13-2002, 05:04 AM
Hello!

I am programming with Borland C++ Builder5.

I have a 3D cube that i can move around with my Keys. So if i do that and the Cube reaches the border of the Screen(or Form in window-mode) it doesn't stop and goes on until its gone.

So how can i set borders for my screen?
Is there a OpenGL-Function to set this?

Thanks for Help!!

Robbo
09-13-2002, 05:20 AM
The short answer to your question is `no' - there is not border function such as you describe. This is perhaps a problem with `collision detection' in that you must check to see whether or not the cube is still within the viewing frustum after you have moved its position.

Do a search on frustum intersections with cube on google or something.

09-13-2002, 05:31 AM
Hi!

Thanks for your reply. I'll have have a look at the frustum thing.

Thanks again!

nexusone
09-13-2002, 06:26 AM
If you want to keep it for going of the screen then setup a boundry like this.

example:

if ( cube_x > x_boundry_right) cube_x = x_boundry_right;
if ( cube_x < x_boundry_left) cube_x = x_boundry_left;

repeat check for y and z.

If you want to just bounce around the screen, then add a direction varible.

if (cube_x > x_boundry_right) cube_direction = Left; // if hit right boundry, move now to the left

hope this helps



Originally posted by Clouddancer:
Hello!

I am programming with Borland C++ Builder5.

I have a 3D cube that i can move around with my Keys. So if i do that and the Cube reaches the border of the Screen(or Form in window-mode) it doesn't stop and goes on until its gone.

So how can i set borders for my screen?
Is there a OpenGL-Function to set this?

Thanks for Help!!

09-13-2002, 01:23 PM
Hi!

Thanks for this input! I'll have a look at it and try this out like that. hope i'll get it running:-)