GLUT, OpenGL & mouse coordinates

Started by
17 comments, last by L. Spiro 11 years, 10 months ago
http://users.skynet.be/cyber-lord/engine.cpp
Advertisement
  gluPerspective(310,Width/Height,0,1000);

Do you really want a fov of 310 degrees? I'm not even sure it's possible. Try setting it to something like 45 or 60. Also, a near plane of zero is not something you should have.. Try changing to
  gluPerspective(45,Width/Height,1,1000);


I also don't see you giving triangle.z a value anywhere..

Finally, not that it matters much, but you can remove glFlush() since glutSwapBuffers() takes care of it.
And it should work if I do all that?
triangle.z exists because I may use it later, and I'm actually trying to make a little basic game engine.

And if you don't make your FoV that large (it works BTW) how can you do so that objects appear smaller? Dividing the view ratio(width/height)?
Really sorry if I'm annoying...
But thanks to you all!
--------------------
EDIT: Where making progress here!
OK, now it shows a reaction that acts a bit like it should act, but when I move the cursor farther away from the center of my window, the triangle allways gets farther and farther from it. so there must be somewhere a division or something... but I don't have a clue where... (if you leave the cursor in the middle, the triangle is under it)
http://users.skynet.be/cyber-lord/engine.cpp >> updated source code.
>> If you solve this, you're my HERO!

[Edited by - the_cyberlord on August 27, 2004 11:59:47 AM]
I found what the problem is:
gluUnProject(x,viewport[3]-y,0
change to
gluUnProject(x,viewport[3]-y,8
The triangle gets a closer match to the mouse pointer, but still not close enough.
Now the problem is: how do you find that value that should give the perfect match...
Again:
Who solves this is my HERO!
Thanks for everybody replying
No one???
PLEASE!
Quote:Original post by the_cyberlord
And it should work if I do all that?

I don't know - I just looked at your code and saw a few things that looked strange [disturbed]
Quote:And if you don't make your FoV that large (it works BTW) how can you do so that objects appear smaller? Dividing the view ratio(width/height)?

Well, you can use FoV to zoom, but I think it should be kept under 180 degrees. (Think about what happens at 180 degrees [smile])

Quote:OK, now it shows a reaction that acts a bit like it should act, but when I move the cursor farther away from the center of my window, the triangle allways gets farther and farther from it. so there must be somewhere a division or something... but I don't have a clue where... (if you leave the cursor in the middle, the triangle is under it)

Ahem. glTranslate(0.0,0.0,-5). It moves the triangle further away from the viewer. And what happens with objects that move away when you have a perspective projection? They look smaller. Of course, movements look smaller too. There's your division.
Start by removing the translation.
Then you add triangle.z=w_mouse_z;
The third argument to gluUnProject should be left between 0 and 1. You could set it to 0.1 or something but 0 should work - I don't think there's much risk your triangle gets clipped by the near plane.
You should now have a triangle that moves just inside the view frustum and follows your mouse pointer. If you want it further away, increase winZ (third argument to gluUnProject) a bit.

Hope that works for you [smile]
Thanks! You're really my hero!
(You see: triangle.z wasn't useless)

Now the fun stuff can begin!
hey your like me wanting to program for fun and not have to do all the technical crap how awesome atleast there are other people out there who like to program for idea rather then the technical crap that comes with it ! woot inspires me to make tools that can get rid of technicality as much as possible and focus more on creativity and fun programming experiences but still keep technical around for those who like it and are passionate about it as well!


user atmosphere experience should be a choice not a enforcement no matter what your doing! rule number 1 in good api design

technical
creative
or any other genre

should be a choice not an enforcement
This topic is almost 8 years old. The original poster is either dead or an old man (or worse—banned) by now.
Don’t revive the dead.

/Me attempts to close but fails to conjure moderator powers with error message, “Not yet level 60”.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement