   Mouse Input
  I''m trying to put buttons in my GL game. I have the mouse coordinates stored in variables, and I''m checking them to see whether or not the mouse is over the button, like this:if (mouse_x>=228&&mouse_x<=420&&mouse_y>=270&&mouse_y<=300)    This works fine when I''m in 640x480 resolution, but everything screws up when I try to resize the window. How can I change the mouse coordinates to fix this? 
  I''m taking a guess that you have drawn the button in OpenGL.Take a look at NeHe lesson 32 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=32.Have a look at the Selection() function. This is where the OpenGL picks the object from the selection buffer.Hope that helps,  ----MikePortfolio: Http://members.iinet.net.au/~slyonsTeam AI: Http://members.iinet.net.au/~slyons/teamai;  ROAR! try your best to stay away from HARD CODING THINGS!i know it can be simpler to do it this way..but trust me when you look back you think..why the hell did i do it this way...anyway try and do somehting like this:make a struct for your button.. like this one:struct Button{int Left;int Right;int Top;int Bottom;// you could alternativly use a POINT variable// and you could also add in functions for OnPress..};Anyway...thats a simple button structure...then just do this to fill it...Button Button_1;Button_1.Left = 200;  //wherever you want the Left to beButton_1.Right = 300; //wherever you want the Right to beButton_1.Top = 100;   // im just making this upButton_1.Bottom = 150;// same with this one...lolRIGHT... now that youve done all that  you should THEORETICALLY have a button something like the one below/////////////////  (Right - Left = Width)<- in this case would be 50// Your Button ///////////////////(Bottom - Top = Height)<- in this case is 100right now instead of doing:if (mouse_x>=228&&mouse_x<=420&&mouse_y>=270&&mouse_y<=300)you could do:if(mouse_x>= Button_1.Left && mouse_x<= Button_1.Right){if(mouse_y>= Button_1.Bottom && mouse_y <= Button.Top{// Do your action here} }right i bet your not thinking...well thats alot more code for not much different... BUT if you have your screen Width and Height held in a variable you can offset your Buttons reletive to the screen res...Such as:Button_1.Left = Screen_Size.x + 200;Button_1.Right = Button_1.Left + 100;Button_1.Top = Screen_Size.y + 200;Button_1.Bottom = Button_1.Top + 50;that way you ALWAYS get your buttons relative to the screen and your ALREADY made collision detection for it will still work as its working off the rects values rather than your hard coded ones... Another good thing to mention here is that you can now include functions within your button if you want.. like OnMousePress(POINT Mouse_Point), this would then allow you to have 10 buttons all round the screen that you could all have running off the same structure... so they all work off the same blueprints in effect... this means every button would have individual values as well as individual collision detection that would work as a whole .... well kinda...lolAnd now im laughing my ass off at the amount ive written about this small subject...lolbut try your best to get away from ahrd coded values..it will come back and bite your ass later on...LOL and it also is good programming to not hardcode things, as then it can look better, rather than looking at a load of numbers that mean nothing, you can look at an objects members and then work out whats going on from there....anyway there you go.. i cba waffling anymore...lol   [edited by - Grofit on February 3, 2004 12:40:25 AM]