• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 832
  • Last Modified:


I want to implement scrollbars for openGl scene

That what I’m doing:

void COglView::OnInitialUpdate()
CSize sizeTotal;
CRect clientRec;
sizeTotal = GetTotalSize();
sizeTotal.cx = (clientRec.Width())*m_GLManager.GetScaleFactor();
sizeTotal.cy = (clientRec.Height())*m_GLManager.GetScaleFactor();

SetScrollSizes(MM_TEXT, sizeTotal);

OnZoomin function:
m_scalefactor += 0.1;

OnDrawScene function

to “scroll” the scene I’m using glTranslatef(m_TranslateX,m_TranslateY,m_TranslateZ);

Now my question how to find the relationship between position of the scroll bar and how I should increase/decrease
m_TranslateX and m_TranslateY parameters ???

Please help me, it’s really urgent .
Thank you.
some example could be very help
1 Solution
Obviously, left and right, top and bottom, are arbitrary values.  If you have models you are viewing, you can take the bounding box that fits all of their bounding boxes, then add a little 'fudge' factor (maybe 10% or so to each dimension), and use that for your maximum extent values.  Those max values can then be used for the maximum of the scrollbars, and the scrollbars just map from -max => 0 => max, or something of that nature.

This sample uses a max and a 'current' rectangle to map the view properly.  I think that's a nice technique:

This sample talks about doing similar GL scrollbars in Motif, but the general approach should be quite applicable.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now