Refresh problems when drawing to Window Device Contexts

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
jweathers
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Sep 01, 2004 9:08 pm
Location: Atlanta, GA

Refresh problems when drawing to Window Device Contexts

Post by jweathers » Wed Sep 01, 2004 9:32 pm

I've been developing a project with wxWidgets on MS Windows for the last few months. My current code runs just fine on that platform. However, I have recently started testing things on my Linux box with wxGTK, and I am now experiencing some bizarre problems.

I have written a subclass of wxWindow that I use as a canvas for displaying a board game. I maintain a wxBitmap that acts as a buffer for blitting to the window client area. Also, I have a bitmap of the empty board, a bitmap of the available pieces, and a bitmap of the available pieces rotated 180 degrees (for representing enemy pieces).

When I draw the board for the first time or update it just before or just after dragging a piece, I create a wxMemoryDC, select the buffer bitmap into it, draw my empty board onto it, and then draw each current piece onto it. Then, I unselect the buffer bitmap from the memory device context and draw the updated buffer bitmap to my canvas window's device context.

The problem is that all of my normal pieces (those created from the first pieces bitmap) get displayed just fine, but the rotated pieces (those created from the second bitmap) do not get displayed.

Here's a further oddity. I have implemented things so that when I click on a piece I can drag it around using a wxDragImage. When I click on a square where I know that a rotated piece should be located and then start to drag my mouse cursor, the missing piece mysteriously appears, but it just as suddenly disappears when I finish dragging it.

Again, my code works just fine on MS Windows.

I should mention that I am developing with the following:
wxMSW 2.5.2
wxGTK 2.5.1
gcc 3.3.3
Linux kernel 2.4.26
KDE 3.2.3
xorg-X11 6.7.0-r1
gtk+ 2.4.4

Any ideas on what might be going on?

Thanks in advance!
"A standing army is a standing menace to liberty."

jweathers
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Sep 01, 2004 9:08 pm
Location: Atlanta, GA

Post by jweathers » Mon Sep 06, 2004 7:30 pm

In case anyone else was curious about this problem, I'll share my "solution" with the list.
I still have no clue what was going on when I tried to use Blit to directly draw a subregion of my bitmap to the device context. All of my tests seemed to suggest something bizarre was happening with the underlying wxMask information.

However, I accomplished what I was attempting to do by using the GetSubBitmap method of wxBitmap and using DrawBitmap instead of Blit.

--
John Weathers
[email protected]
"A standing army is a standing menace to liberty."

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Tue Sep 07, 2004 6:40 am

Hi there John,

Thanks for sharing. Now someone in a similar situation might be able to find his solution on the forum ;-)

If this is really weird or bizarre, maybe you should post the bug to SF. If this is just Linux's way of doing things, there is not much to do about it ;-)

Regards,
- Jorgen

Post Reply