Problem with wxScrolledWindow + wxGLCanvas

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
Disch
Experienced Solver
Experienced Solver
Posts: 99
Joined: Wed Oct 17, 2007 2:01 am

Problem with wxScrolledWindow + wxGLCanvas

Post by Disch »

Hey everyone.

I'm trying to have a wxScrolledWindow with a wxGLCanvas for a client area.

So far so good, except for one problem. I've uploaded pictures to illustrate

skiffmapA: The window before any scroll (OK)
skiffmapB: The window after scrolling right 1 "tick" (OK)
skiffmapC: The window after scrolling back left (messed up)

C and A should look identical. It's as if the left column of C simply didn't get refreshed after the scroll.

Things I noticed:

1) this problem persists for scrolling in all directions. I just took the screenshots of scrolling left, but scrolling right/up/down all have the same problem.

2) this problem persists when I click the scroll arrows, or in the 'page scroll' void on either side of the scrollbar, but does not happen when I drag the scroll bar. Dragging the scroll bar has no ill effects at all.

3) if I force refresh the window (dragging it offscreen, or put another window on top of it), it will correct itself.


With #3 in mind I tried catching the wxScrolledWinEvent messages and tried to force a Refresh and Update when scrolls were detected, but that didn't help any.

How can I fix this problem?

I'm using wx 2.8.8.0 on Ubuntu with GCC via Code::Blocks.

Any help appreciated!
Attachments
skiffmapA.png
skiffmapA.png (7.52 KiB) Viewed 2812 times
skiffmapB.png
skiffmapB.png (7.5 KiB) Viewed 2812 times
skiffmapC.png
skiffmapC.png (7.54 KiB) Viewed 2812 times
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Hi,

I would definitely not recommend putting a GL canvas inside a scrolled window; I'd rather recommend putting single scrollbars around the GL canvas, and render the contents of the pane according to the position of the scrollbars.
"Keyboard not detected. Press F1 to continue"
-- Windows
yuri
Earned some good credits
Earned some good credits
Posts: 104
Joined: Thu Apr 09, 2009 4:58 pm
Location: Russia

Post by yuri »

Auria wrote:Hi,

I would definitely not recommend putting a GL canvas inside a scrolled window; I'd rather recommend putting single scrollbars around the GL canvas, and render the contents of the pane according to the position of the scrollbars.
Yes, and when you've got to implementing zoom you'd find that scrollbars are just a waste of screen space, and you will implement pan/zoom navigation entirely inside your GLCanvas, just like everybody else :) It really is much more simple that way.
User avatar
Disch
Experienced Solver
Experienced Solver
Posts: 99
Joined: Wed Oct 17, 2007 2:01 am

Post by Disch »

Auria:

That makes sense. I'll give that a go. Thanks.

yuri:

You mean like draw my own scroll bars via OpenGL instead of using the window managers? What's the benefit of that?

Seems to me like it would just be tons more work and would clash with the user's display scheme... and would be unintuitive, and wouldn't function in all the normal ways a scroll bar does, etc, etc.
yuri
Earned some good credits
Earned some good credits
Posts: 104
Joined: Thu Apr 09, 2009 4:58 pm
Location: Russia

Post by yuri »

Disch wrote: You mean like draw my own scroll bars via OpenGL instead of using the window managers? What's the benefit of that?
No, I mean do it without scrollbars at all.
Scrollbar is GUI element to scroll in one given direction.
That's fine in may cases where user mostly "scrools", like word doc or excel spreadsheet.

You CAN use scrollbars too, but most of the time your users would like to PAN instead of SCROLL, that is move your canvas in two dimenstions at once following mouse pointer. One can do it with SCROLL, moving one bar then another, but that's not very convenient.

Using opengl you may easily implement PAN yourself, without scrollbars. Look like navigation is done with GoogleEarch, there is no scrollbars on screen at all. And if you ever come to implement zoom and rotate - you'll need to do it using opengl camera anyway, so why bother with separate approach at all? Just set up opengl camera and probably toggle or two on toolbar to select between zoom/pan/rotate, then move camera appropriately upon receiving mouse events.
xin.songtao
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Apr 18, 2007 6:10 am
Location: Shanghai China

Post by xin.songtao »

maybe the glViewport is the key of your problem.
from: Shanghai China
language: C++/C
platform:MSW\MacOS\Linux
Email: [email protected]
Post Reply