10-01-2005, 09:05 AM
I want to create 3 slider bars so that each bar moves an object either over the x-axis, y-axis, or z-axis. But I am having problems figuring out how to draw these 3 slider bars. Does anyone have any ideas on what I need to do or where I can look to find information on this. I have searched online and can't tell if this is an opengl thing or not. Thanks!
10-01-2005, 12:43 PM
Technically, no, it's not, but you could argue the drawing part is.
What you need to do is do a little GUI programming. As with everything, there are alot of ways to attack the problem. Personally, for GUI's I've been going with object-oriented approaches for quite some time now, seeing how well a hierarchy system lends itself to a fairly simple implementation of a windowed interface.
For your case though, if all you need are slider bars, all you need is some kind of data structure to represent each slider bar, which really could at a minimum just contain a max, min, and current value. Then for rendering, use an orthogonal (or you could use a perspective one if you wanted to get fancy) projection matrix and have at least a function that accepts one of your data structures and draws, say, a textured quad representing the scale of the slider bar, and then the "handle," that is the part that the user grabs and slides. Naturally the position of the handle will be determined by the max min and current values.
Then you'll need to write the interface code for the user, which depends on how you're getting input. If you're using the mouse, you'll have to come up with a way to map mouse coordinates to GUI coordinates, and there are a bunch of ways to do this; a simple matrix transformation, OpenGL picking, making your projection matrix dimensions /almost/ match the screen resolution. Some click and drag code for the handle, and then some code back around the sliderbar data structure that adjusts the current value based on the new position.
10-10-2005, 06:42 AM
What I did was made a line and a rectangle that appeared at the left end of the line. Then I used the mouseFunc to determine if the user clicked down on the rectangle. If the user did I set a boolean flag to true, and then in the motionFunc, if the flag was true I moved the rectangle along the slider bar making sure the slider never went past the ends of the line. It seems to work well! Thanks for your help...it lead me in the right direction!
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.