|
Post by matthew on Nov 28, 2012 20:40:54 GMT -5
I've noticed you've mentioned 'Quadrants' and 'Angles'. Have you actually written any code for calculating the angle? Or is your code just supposed to display the X and Y co-ordinates of the Mouse? Could you Post the code for your Mouse routine?
|
|
|
Post by Darkjester on Nov 29, 2012 0:12:50 GMT -5
i think i know your problem may lie with the way with 2 coordinate systems trying to overlap, the offset could come from using the opengl coordinate system and not translating directly to screen space, if that makes any sense? i had a similar problem a while back. not much time at the moment but ill take a closer look when i return.
|
|
|
Post by joeschmoe on Nov 29, 2012 7:05:30 GMT -5
Sorry, Matthew. I was just using those terms to try and clarify what was happening. I figured saying "left" or "right" could get confusing. I'm not computing or using any angles in this program, just getting those mouse coords.
I use exactly the same code for the mouse that you used in your snippets.
|
|
|
Post by joeschmoe on Nov 29, 2012 7:09:53 GMT -5
Joshie,
That crossed my mind when it first started happening but I'd thought I read that b4gl automatically corrects for that so I dismissed it. Not so?
|
|
|
Post by matthew on Nov 29, 2012 7:33:57 GMT -5
Okay, check to see that the code you've used to create a 2d screen is the same as mine. Make sure you aren't using a command like 'gluPerspective' in your program as it's not required for a 2d screen. Then look through your program and make sure there isn't a rogue 'glTranslatef' instruction somewhere. If there is, comment it out and try running your program. The code that updates the Mouse Position should look like the following...
' Update mouse position currMousePosX = (mouse_x() * WindowWidth()) currMousePosY = (mouse_y() * Windowheight())
|
|
|
Post by joeschmoe on Nov 29, 2012 13:34:58 GMT -5
Seems to be getting close. I was using a 'gluPerspective" command and a 'glTranslatef' command (to place my field at the right distance, I thought). When I remove gluPerspective and/or glTranslate the line is perfectly located but the field doesn't show up. That should be easy enough to correct, right?
|
|
|
Post by matthew on Nov 29, 2012 14:02:42 GMT -5
Well put the 'glTranslatef' Instruction back and report back what happens. :-)
|
|
|
Post by joeschmoe on Nov 29, 2012 14:18:13 GMT -5
With the glTranslate but without gluPerspective the field is gone and the line stays as a bunch of lines wherever I moved the mouse and flickers a lot. On the plus side, the line is perfectly aligned with mouse and sprite.
|
|
|
Post by joeschmoe on Nov 29, 2012 14:22:26 GMT -5
Staring at the code, I noticed that, in the section to place the field there're two glLoadIdentity() commands, but in the section to create the line I only had one. When I added the second glLoadIdentity() to that section, it worked perfectly. Sorry to run you around if that's all it was.
|
|
|
Post by matthew on Nov 29, 2012 14:34:36 GMT -5
Ah never underestimate the importance of the glLoadIdentity() Command. :-D There's a good description of what it does here, it may seem a bit complicated but it's well worth reading.
|
|
|
Post by joeschmoe on Nov 29, 2012 14:44:57 GMT -5
Thanks for your help, Matthew. I wish I had your patience with pinheads like me. In the time that I've been trying to learn programming, I'm always surprised at how one misplaced or omitted stupid line can completely kill the whole project. My GF (who programs in some boring business languages) always tells me: "It's not doing anything you're not telling it to do", meaning, I guess, that it's not magic and stuff doesn't happen on there for supernatural reasons, so keep looking at it. Again, my apologies for being dense...just born that way, I guess.
|
|