Solved

OpenGL+MFC+Scrollview

Posted on 2004-10-24
789 Views
Last Modified: 2013-12-06
I want to implement scrollbars for openGl scene

That what I’m doing:
IMPLEMENT_DYNCREATE(COglView, CScrollView)

void COglView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
CRect clientRec;
GetClientRect(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
glScalef(m_scalefactor,m_scalefactor,m_scalefactor);

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.
P.S
some example could be very help
0
Question by:vadim85
    1 Comment
     
    LVL 17

    Accepted Solution

    by:
    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:
    http://www.codeproject.com/opengl/opengl_zooming.asp?df=100&forumid=3268&exp=0&select=795912

    This sample talks about doing similar GL scrollbars in Motif, but the general approach should be quite applicable.
    http://www.csee.umbc.edu/~squire/cs437_l12.html

    -d
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
    Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now