Hi,
is it possible to draw with PseudoDC on glCanvas? I tried it and I get
only black screen,
but maybe I'm missing something.
Thanks
Anna
Hi,
is it possible to draw with PseudoDC on glCanvas? I tried it and I get
only black screen,
but maybe I'm missing something.
Thanks
Anna
no -- glCAnvas provided a canvas you can draw to with OpenGL calls -- it's completely independent of DCs.
-Chris
On 7/16/2011 5:35 AM, annakrat wrote:
is it possible to draw with PseudoDC on glCanvas? I tried it and I get
only black screen,
but maybe I'm missing something.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
> is it possible to draw with PseudoDC on glCanvas? I tried it and I get
> only black screen,
> but maybe I'm missing something.no -- glCAnvas provided a canvas you can draw to with OpenGL calls --
it's completely independent of DCs.
I know it's independent, I just need to draw an overlay image on the
glCanvas via PseudoDC.
I tried drawing with PaintDC and it works but PseudoDC doesn't work
for me. I tried PseudoDC
using the demo for glcanvas and when I call DrawToDC(dc) method, it
worked only for dc = wx.PaintDC
and not for wx.BufferedPaintDC (and it flickerd a lot). Unfortunately
this doesn't work in my program.
I add the modified code of OnPaint method from the demo
def OnPaint(self, event):
dc = wx.PaintDC(self)
## dc = wx.BufferedPaintDC(self, self._buffer)
# use PrepareDC to set position correctly
self.PrepareDC(dc)
dc.SetBackground(wx.TRANSPARENT_BRUSH)
dc.Clear()
self.SetCurrent()
if not self.init:
self.InitGL()
self.init = True
self.pdc.DrawToDC(dc)
self.OnDraw()
When I use the similar code in my program, nothing is drawn. If I call
DrawToDC
after calling SwapBuffers (in OnDraw) I can see only black screen.
Thanks for any suggestion
Anna
On Jul 18, 12:20 am, Chris Barker <Chris.Bar...@noaa.gov> wrote:
On 7/16/2011 5:35 AM, annakrat wrote:
-Chris
--
Christopher Barker, Ph.D.
OceanographerEmergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main receptionChris.Bar...@noaa.gov
You can try using PseudoDC to draw onto a wx.MemoryDC/bitmap, and then use OpenGL's methods to overlay that bitmap image on the canvas.
On 7/18/11 12:16 AM, annakrat wrote:
On Jul 18, 12:20 am, Chris Barker<Chris.Bar...@noaa.gov> wrote:
On 7/16/2011 5:35 AM, annakrat wrote:
is it possible to draw with PseudoDC on glCanvas? I tried it and I get
only black screen,
but maybe I'm missing something.no -- glCAnvas provided a canvas you can draw to with OpenGL calls --
it's completely independent of DCs.I know it's independent, I just need to draw an overlay image on the
glCanvas via PseudoDC.
I tried drawing with PaintDC and it works but PseudoDC doesn't work
for me. I tried PseudoDC
using the demo for glcanvas and when I call DrawToDC(dc) method, it
worked only for dc = wx.PaintDC
and not for wx.BufferedPaintDC (and it flickerd a lot). Unfortunately
this doesn't work in my program.
--
Robin Dunn
Software Craftsman
I finally managed to use PseudoDC to draw an overlay on glCanvas and
it seems to work fine.
B
On 18 čnc, 19:27, Robin Dunn <ro...@alldunn.com> wrote:
On 7/18/11 12:16 AM, annakrat wrote:
> On Jul 18, 12:20 am, Chris Barker<Chris.Bar...@noaa.gov> wrote:
>> On 7/16/2011 5:35 AM, annakrat wrote:>>> is it possible to draw with PseudoDC on glCanvas? I tried it and I get
>>> only black screen,
>>> but maybe I'm missing something.>> no -- glCAnvas provided a canvas you can draw to with OpenGL calls --
>> it's completely independent of DCs.> I know it's independent, I just need to draw an overlay image on the
> glCanvas via PseudoDC.
> I tried drawing with PaintDC and it works but PseudoDC doesn't work
> for me. I tried PseudoDC
> using the demo for glcanvas and when I call DrawToDC(dc) method, it
> worked only for dc = wx.PaintDC
> and not for wx.BufferedPaintDC (and it flickerd a lot). Unfortunately
> this doesn't work in my program.You can try using PseudoDC to draw onto a wx.MemoryDC/bitmap, and then
use OpenGL's methods to overlay that bitmap image on the canvas.--
Robin Dunn
Software Craftsmanhttp://wxPython.org
Sorry, I wanted to continue but I sent it by mistake.
The problem is that a user with Mac tested it and it didn't work for
him. No overlay is drawn.
I really don't understand where the problem is.
I edited the glcanvas demo:
class MyCanvasBase(glcanvas.GLCanvas):
def __init__(self, parent):
...
self.pdc = wx.PseudoDC()
self.pdc.BeginDrawing()
pen = wx.GREEN_PEN
self.pdc.SetPen(pen)
self.pdc.DrawLine(20,20,200,200)
self.pdc.EndDrawing()
def OnPaint(self, event):
dc = wx.PaintDC(self)
self.SetCurrent()
if not self.init:
self.InitGL()
self.init = True
self.OnDraw()
self.PrepareDC(dc)
self.pdc.DrawToDC(dc)
I can see both the line and the cube/cone. On Mac only the cone/cube
is visible.
Thanks for any ideas
Anna
On 27 čnc, 21:03, annakrat <kratocha...@gmail.com> wrote:
On 18 čnc, 19:27, Robin Dunn <ro...@alldunn.com> wrote:
> On 7/18/11 12:16 AM, annakrat wrote:
> > On Jul 18, 12:20 am, Chris Barker<Chris.Bar...@noaa.gov> wrote:
> >> On 7/16/2011 5:35 AM, annakrat wrote:> >>> is it possible to draw with PseudoDC on glCanvas? I tried it and I get
> >>> only black screen,
> >>> but maybe I'm missing something.> >> no -- glCAnvas provided a canvas you can draw to with OpenGL calls --
> >> it's completely independent of DCs.> > I know it's independent, I just need to draw an overlay image on the
> > glCanvas via PseudoDC.
> > I tried drawing with PaintDC and it works but PseudoDC doesn't work
> > for me. I tried PseudoDC
> > using the demo for glcanvas and when I call DrawToDC(dc) method, it
> > worked only for dc = wx.PaintDC
> > and not for wx.BufferedPaintDC (and it flickerd a lot). Unfortunately
> > this doesn't work in my program.> You can try using PseudoDC to draw onto a wx.MemoryDC/bitmap, and then
> use OpenGL's methods to overlay that bitmap image on the canvas.> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.orgI finally managed to use PseudoDC to draw an overlay on glCanvas and
it seems to work fine.
B
My guess is that since the OSX UI is based on OpenGL that probably there is some additional or out of order buffering, refreshing and/or context swapping that OSX is doing for the GL canvas, and so your DC operations are getting drawn over by GL. You might try using a wx.Overlay, at least on Mac. On the Mac it is a native UI tool that allows you to draw over some other widgets without actually blending the foreground and background drawing. You can think of the overlay as an extra piece of glass laid on top of your window, and any drawing you do on the overlay is kept separate. On MSW and GTK the overlay is just a simple simulation using a wx.ClientDC, so if you current approach works ok on those platforms then you will probably want to avoid it there and just leave them as-is.
Unfortunately the wx.Overlay classes are not documented, but I've attached a sample that I've used in the past for testing overlays that should help you figure it out. The example uses the overlay in some mouse event handlers, so as you can see it doesn't have to be done in the paint event handler. If you're pseudo dc drawing is constant (or mostly) then you can probably do it once and forget about it (until it needs to change) and then just do nothing except the GL stuff in the paint handler.
test_Overlay.py (2.64 KB)
On 7/27/11 12:16 PM, annakrat wrote:
I finally managed to use PseudoDC to draw an overlay on glCanvas and
it seems to work fine.
BSorry, I wanted to continue but I sent it by mistake.
The problem is that a user with Mac tested it and it didn't work for
him. No overlay is drawn.
I really don't understand where the problem is.I edited the glcanvas demo:
class MyCanvasBase(glcanvas.GLCanvas):
def __init__(self, parent):
...
self.pdc = wx.PseudoDC()
self.pdc.BeginDrawing()
pen = wx.GREEN_PEN
self.pdc.SetPen(pen)
self.pdc.DrawLine(20,20,200,200)
self.pdc.EndDrawing()def OnPaint(self, event):
dc = wx.PaintDC(self)
self.SetCurrent()
if not self.init:
self.InitGL()
self.init = True
self.OnDraw()
self.PrepareDC(dc)
self.pdc.DrawToDC(dc)I can see both the line and the cube/cone. On Mac only the cone/cube
is visible.
--
Robin Dunn
Software Craftsman
Thanks very much, I'll definitely try it.
Anna
On Wed, Jul 27, 2011 at 10:51 PM, Robin Dunn <robin@alldunn.com> wrote:
On 7/27/11 12:16 PM, annakrat wrote:
I finally managed to use PseudoDC to draw an overlay on glCanvas and
it seems to work fine.
BSorry, I wanted to continue but I sent it by mistake.
The problem is that a user with Mac tested it and it didn't work for
him. No overlay is drawn.
I really don't understand where the problem is.I edited the glcanvas demo:
class MyCanvasBase(glcanvas.GLCanvas):
def __init__(self, parent):
...
self.pdc = wx.PseudoDC()
self.pdc.BeginDrawing()
pen = wx.GREEN_PEN
self.pdc.SetPen(pen)
self.pdc.DrawLine(20,20,200,200)
self.pdc.EndDrawing()def OnPaint\(self, event\): dc = wx\.PaintDC\(self\) self\.SetCurrent\(\) if not self\.init: self\.InitGL\(\) self\.init = True self\.OnDraw\(\) self\.PrepareDC\(dc\) self\.pdc\.DrawToDC\(dc\)
I can see both the line and the cube/cone. On Mac only the cone/cube
is visible.My guess is that since the OSX UI is based on OpenGL that probably there is
some additional or out of order buffering, refreshing and/or context
swapping that OSX is doing for the GL canvas, and so your DC operations are
getting drawn over by GL. You might try using a wx.Overlay, at least on
Mac. On the Mac it is a native UI tool that allows you to draw over some
other widgets without actually blending the foreground and background
drawing. You can think of the overlay as an extra piece of glass laid on
top of your window, and any drawing you do on the overlay is kept separate.
On MSW and GTK the overlay is just a simple simulation using a wx.ClientDC,
so if you current approach works ok on those platforms then you will
probably want to avoid it there and just leave them as-is.Unfortunately the wx.Overlay classes are not documented, but I've attached a
sample that I've used in the past for testing overlays that should help you
figure it out. The example uses the overlay in some mouse event handlers,
so as you can see it doesn't have to be done in the paint event handler. If
you're pseudo dc drawing is constant (or mostly) then you can probably do it
once and forget about it (until it needs to change) and then just do nothing
except the GL stuff in the paint handler.--
Robin Dunn
Software Craftsman
http://wxPython.org--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
You also might try using GL more -- draw to a wx.Bitmap, turn that into a texture, and draw the texture with GL.
That way your DC drawing stuff could be anywhere in the draw order, not just on top.
-Chris
On 7/27/11 1:51 PM, Robin Dunn wrote:
You might try using a wx.Overlay, at least
on Mac. On the Mac it is a native UI tool that allows you to draw over
some other widgets without actually blending the foreground and
background drawing.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
>> I finally managed to use PseudoDC to draw an overlay on glCanvas and
>> it seems to work fine.
>> B> Sorry, I wanted to continue but I sent it by mistake.
> The problem is that a user with Mac tested it and it didn't work for
> him. No overlay is drawn.
> I really don't understand where the problem is.> I edited the glcanvas demo:
> class MyCanvasBase(glcanvas.GLCanvas):
> def __init__(self, parent):
> ...
> self.pdc = wx.PseudoDC()
> self.pdc.BeginDrawing()
> pen = wx.GREEN_PEN
> self.pdc.SetPen(pen)
> self.pdc.DrawLine(20,20,200,200)
> self.pdc.EndDrawing()> def OnPaint(self, event):
> dc = wx.PaintDC(self)
> self.SetCurrent()
> if not self.init:
> self.InitGL()
> self.init = True
> self.OnDraw()
> self.PrepareDC(dc)
> self.pdc.DrawToDC(dc)> I can see both the line and the cube/cone. On Mac only the cone/cube
> is visible.My guess is that since the OSX UI is based on OpenGL that probably there
is some additional or out of order buffering, refreshing and/or context
swapping that OSX is doing for the GL canvas, and so your DC operations
are getting drawn over by GL. You might try using a wx.Overlay, at
least on Mac. On the Mac it is a native UI tool that allows you to draw
over some other widgets without actually blending the foreground and
background drawing. You can think of the overlay as an extra piece of
glass laid on top of your window, and any drawing you do on the overlay
is kept separate. On MSW and GTK the overlay is just a simple
simulation using a wx.ClientDC, so if you current approach works ok on
those platforms then you will probably want to avoid it there and just
leave them as-is.Unfortunately the wx.Overlay classes are not documented, but I've
attached a sample that I've used in the past for testing overlays that
should help you figure it out. The example uses the overlay in some
mouse event handlers, so as you can see it doesn't have to be done in
the paint event handler. If you're pseudo dc drawing is constant (or
mostly) then you can probably do it once and forget about it (until it
needs to change) and then just do nothing except the GL stuff in the
paint handler.
I forgot to ask which version of wxPython is it available for? I
couldn't
find it anywhere and it's quite important for me.
Thanks
Anna
On 27 čnc, 22:51, Robin Dunn <ro...@alldunn.com> wrote:
On 7/27/11 12:16 PM, annakrat wrote:
--
Robin Dunn
Software Craftsmanhttp://wxPython.orgtest_Overlay.py
2KZobrazitStáhnout
I think it was added sometime in the 2.8 series. Try running the sample code I included with my last message. If it works then you have wx.Overlay. If not then you need a newer version.
On 7/27/11 11:32 PM, annakrat wrote:
On 27 �nc, 22:51, Robin Dunn<ro...@alldunn.com> wrote:
I can see both the line and the cube/cone. On Mac only the cone/cube
is visible.My guess is that since the OSX UI is based on OpenGL that probably there
is some additional or out of order buffering, refreshing and/or context
swapping that OSX is doing for the GL canvas, and so your DC operations
are getting drawn over by GL. You might try using a wx.Overlay, at
least on Mac. On the Mac it is a native UI tool that allows you to draw
over some other widgets without actually blending the foreground and
background drawing. You can think of the overlay as an extra piece of
glass laid on top of your window, and any drawing you do on the overlay
is kept separate. On MSW and GTK the overlay is just a simple
simulation using a wx.ClientDC, so if you current approach works ok on
those platforms then you will probably want to avoid it there and just
leave them as-is.Unfortunately the wx.Overlay classes are not documented, but I've
attached a sample that I've used in the past for testing overlays that
should help you figure it out. The example uses the overlay in some
mouse event handlers, so as you can see it doesn't have to be done in
the paint event handler. If you're pseudo dc drawing is constant (or
mostly) then you can probably do it once and forget about it (until it
needs to change) and then just do nothing except the GL stuff in the
paint handler.I forgot to ask which version of wxPython is it available for? I
couldn't
find it anywhere and it's quite important for me.
--
Robin Dunn
Software Craftsman
>>> I can see both the line and the cube/cone. On Mac only the cone/cube
>>> is visible.>> My guess is that since the OSX UI is based on OpenGL that probably there
>> is some additional or out of order buffering, refreshing and/or context
>> swapping that OSX is doing for the GL canvas, and so your DC operations
>> are getting drawn over by GL. You might try using a wx.Overlay, at
>> least on Mac. On the Mac it is a native UI tool that allows you to draw
>> over some other widgets without actually blending the foreground and
>> background drawing. You can think of the overlay as an extra piece of
>> glass laid on top of your window, and any drawing you do on the overlay
>> is kept separate. On MSW and GTK the overlay is just a simple
>> simulation using a wx.ClientDC, so if you current approach works ok on
>> those platforms then you will probably want to avoid it there and just
>> leave them as-is.>> Unfortunately the wx.Overlay classes are not documented, but I've
>> attached a sample that I've used in the past for testing overlays that
>> should help you figure it out. The example uses the overlay in some
>> mouse event handlers, so as you can see it doesn't have to be done in
>> the paint event handler. If you're pseudo dc drawing is constant (or
>> mostly) then you can probably do it once and forget about it (until it
>> needs to change) and then just do nothing except the GL stuff in the
>> paint handler.> I forgot to ask which version of wxPython is it available for? I
> couldn't
> find it anywhere and it's quite important for me.I think it was added sometime in the 2.8 series. Try running the sample
code I included with my last message. If it works then you have
wx.Overlay. If not then you need a newer version.
The program I contribute to has requirements on wxPython version >=
2.8.1.1 .
So it should be OK. wx.Overlay seems to work together with glCanvas on
Mac
so I'm going to use it.
Thanks very much for your advice, it was very helpful.
Anna
On 28 čnc, 22:15, Robin Dunn <ro...@alldunn.com> wrote:
On 7/27/11 11:32 PM, annakrat wrote:
> On 27 nc, 22:51, Robin Dunn<ro...@alldunn.com> wrote:
--
Robin Dunn
Software Craftsmanhttp://wxPython.org