   homemade engine issues
  hi!  this is my first post here, though i have been looking around and gleaming info for a while now (much thanks there!).  :)so, the reason i have been floating around here trying to glean info is because i would like to build a 3d engine using opengl and have had some issues.  well, my friend and i finally got to the point where we can move around using wasd and looking around with a mouse.  however, we have run into two issues that concern us.1.  when moving with the keyboard alone everything looks find.  when looking around with the mouse alone everything looks fine.  however, when we move (left and right are the most pronounced, though surely forward and backward do it too but aren't as visible) and rotate the view with the mouse, normal mouse look like in an fps is the goal, we have an issue where the objects appear to be oscilating from one spot to another.  i'm not sure how to describe this, but it is like the computer is rapidly flipping a childs flipbook and the pictures drawn aren't lining up so it seems to vibrate.originally we thought this was due to having a PostRedisplay call for the keyboard call back and the passive mouse motion call back.  so to remedy that we looked around online and saw that different places were using the timer call back and doing the redisplay in there.  so  we are now doing that too, however we are still experiencing the same issue.also, online we noticed that most people suggest moving the world around the camera in the opposite direction that the input states (so to move left move the world right, etc etc).  however, we started and still are doing it so that the actual eye position is the one moving and not the rest of the world.my questions on this are -- has anyone ever experienced this before, and if so how did you solve the issue?  also, is it vital to move the world around the eye as opposed to the eye through the world?2.  my second major issue with the engine (that i know of :) ) is that when i press down on the keyboard to move there is a stutter before the movement starts.  so, for example, if the eye is stationary (no translation or rotation occuring) and then i push 'w' to move forward, there is a slight move forward and a pause and then continuous movement until the key is released.  this occurrs for all four directions (forward, backward, right, and left) but not for mouse look.my question is pretty much the same as before -- has anyone ever experienced anything like this before and if so, how did you solve the issue?i know i haven't posted any code here, but that is because the faq said not to be a "fix this for me" kind of person.  :)  i have done lots of searching online and tried to find a tutorial or paper or anything on how to effectively create a mouse look system, but haven't been very successful, only tutorials on how to get the mouse location.  about the most useful mouse info i have found is how to warp the pointer around the screen (which is allowing us to have continuous movement as opposed to being locked at the edges).  however, having said that, i would be glad to post any code that you might think helpful in diagnosing the issues.bonus question -- does anyone know where i can find out what is actually going on in glutMainLoop()?  i have checked the man pages and what not, but i really would like to see the code in there or a list of what is happening and in what order.  thanks!and, i would like to say thank you for all the help ya'll have provided so far (unwittingly ;)) and any that is to come.   
  I'm not sure about the movement problems you're having; it sounds like that could be a problem in your code or perhaps related to using glut. As for moving the world or moving the camera, that's purely a conceptual distinction; it's all the same to OpenGL.   ;  Number one is probably an issue with applying the transformations and rotations, possibly in the wrong order. I haven't touched 3d code in some months so am not too sure about it. Your description is difficult to comprehend :) but from what you say it might be something else. Any chance of a screenshot?Number two is most likely an issue with your keyboard polling / processing code. Think of how you press a key in a text editor. First one letter appears, then a pause, then others follow if the key is still down. Therefore, if you only move once for each keydown, you will get this initial stutter (I think). So you want to start moving on the first keydown and ignore subsequent keydowns of the same key until a keyup for that key is detected. (I might be digging my grave here tho :D)Edit: answer  to your bonus questionEdit2: You might wanna ditch GLUT :) I suppose it only brings some startup code and main loop code to the table, and that stuff is a write-and-forget non-issue. Write it once, your way, and you can keep using it. Portability is usually not an issue unless you are aiming at the small devices market or the console market or really want to impress linux users.   ;Quote:Your description is difficult to comprehend :) but from what you say it might be something else. Any chance of a screenshot?yeah, i know, like i said, it is kinda hard to explain.  i tried to grab a screen shot that demonstrated the issue i am seeing and i can't seem to do it.  apparently the issue is then that the view is being drawn incorrectly like every other frame.  this then raises a question of when the input is taken in.  when using glut (which i really would like to get away from myself however my friend is dead set on it, i suggested we use the gl commands ourself write wrappers for what we need and let allegro do keyboard and mouse input if that is possible ... is it?) i don't know if keyboard and mouse are taken in at alternating times.  my friend explains it as whenever the windows interupt is registered glut then deals with the respective call back.  i'm not sure if that is how it is, but it doesn't explain why they can't be registered in the same loop and then have the transforms applied and then have the PostRedisplay called.  that is what would make sense to me -- mess with stuff and then display it.  if any of that made sense, can some one please comment on it?Quote:Number two is most likely an issue with your keyboard polling / processing code. Think of how you press a key in a text editor. First one letter appears, then a pause, then others follow if the key is still down. Therefore, if you only move once for each keydown, you will get this initial stutter (I think). So you want to start moving on the first keydown and ignore subsequent keydowns of the same key until a keyup for that key is detected. (I might be digging my grave here tho :D)on this topic i did some research for what glut does with keyboard polling.  this is what i came up with.  at first i was really excited because it seemed to be what i wanted.  however, it turns out that glutSetKeyRepeat() actually doesn't work in win32 and to do something similar you have to do glutIgnoreKeyRepeat().  in that case when you set it to ignore key repeats and use the glutMainLoop (man, this thing keeps popping up and i dislike it more and more ever time ...) you have to repress the key for it to reregister.  now i freely admit that i really didn't know what to do after setting glutIgnoreKeyRepeat() to ignore.  my guess is that there is a way to make it so that there is no need to keep repressing whatever key, but i don't know it.  so any help there would be good.Quote:Edit: answer  to your bonus questionthanks!Quote:Edit2: You might wanna ditch GLUT :) I suppose it only brings some startup code and main loop code to the table, and that stuff is a write-and-forget non-issue. Write it once, your way, and you can keep using it. Portability is usually not an issue unless you are aiming at the small devices market or the console market or really want to impress linux users.yeah, that is what i'm thinking more and more.  like i mentioned earlier in this post, i was contemplating dropping glut, writing my own main and wrappers that i know are working and how, and letting allegro get the keyboard and mouse data (because i don't know how opengl does it, but i am familiar with allegro).  any suggestions there?  think that will work?again, thanks for the help so far!  and remember, if you want to see any particular code i'm more than happy to post it if it means generating insight that i can use.  :)   ;Quote:Original post by supercat1my guess is that there is a way to make it so that there is no need to keep repressing whatever key, but i don't know it.  so any help there would be good.What your probably could do is to store the key states in a table. You can use the callbacks described at the bottom of that page to reset the key's state in your table. Then every frame you check if the key is down according to your table, and if it is, commence movement. This should give smooth results.Quote:Original post by supercat1yeah, that is what i'm thinking more and more.  like i mentioned earlier in this post, i was contemplating dropping glut, writing my own main and wrappers that i know are working and how, and letting allegro get the keyboard and mouse data (because i don't know how opengl does it, but i am familiar with allegro).  any suggestions there?  think that will work?OpenGL is a graphics library. Unlike DirectX, it does not provide for any input methods. Therefore, you really have to use another library (if moving away from GLUT). Apart from Allegro, there's also SDL input, and DirectX input. Someone in an old thread also suggested GL Framework (GLFW), although it seems to do a lot more than just input.[Edited by - lightbringer on June 7, 2006 6:16:21 PM];  Hi,Are you developing on XP/2000?  If so, try looking up WM_INPUT on the msdn site.  I use that and it works fine, I have a big if/else statement for the keyboard processing.As for your objects being skewed, Sounds like you may have either a) a problem with your FOV setupor most likely b) a problem with your camera code.Are you using a vector system for you camera?  If not, I would recomend using that.Hope this helps somewhat.( i need a new keyboard, so if there are any r's missing, that's my excuse )   ;  I was reading an article just now and something came up that sounded kind of like what you described. clicky. see the part about "shake" rendering problems with star systems. I'm assuming that your scene is not that big, but maybe you inadvertently used large numbers?   ;  thanks for the suggestions so far (and the article)!  when i get back to my pc, i'm on my college's campus right now, i'll look into those issues and read the article over again.   ;  The first issue is almost definitely a problem with the order that transformation are being applied. I had the same kind of problem until I fixed some bugs with matrix orders and stuff, then it worked - that was a good day.The second issue is due to the keyboard repeat delay. Even at its fastest it is not quick enough. A better way is to poll the keyboard status in your main loop. If you're using Windows for example, call GetKeyboardState to find out which keys are currently depressed.   ;  For smooth keyboard input you can try:#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)Instead of checking the array or whatever you are storing key states in just use one of these in its place.  You won't have any of the waiting when you use the default Windows keyboard stuff.Also, its not that hard to create a real WinMain() and WndProc().   