render2d coordinates change when fullscreen is toggled

In the code below, an OnscreenImage is placed on the boarder of the screen, the user is allowed to toggle full screen, and a line at the end of the full-screen toggling function repositions the OnscreenImage so that it should be held in the same position. However, it seems that toggling full screen is somehow changing the render 2d coordinate system so that (-1,0,0) no longer correctly refers to the left edge of the screen. I’m currently running Ubuntu Jaunty with Panda 1.6.2, and everything seems to work fine (i.e. I couldn’t reproduce the bug) in Mac OS X. Has anyone seen this before? Anyone know a work around?

Thanks!

import sys
from pandac.PandaModules import *
from direct.gui.OnscreenText import OnscreenText
import direct.directbase.DirectStart
from pandac.PandaModules import ConfigVariableBool
from direct.gui.OnscreenImage import OnscreenImage

def changeFullScreen():
    if (not fs):
        fs.setValue(1)
    else:
        fs.setValue(0)
    base.openMainWindow()
    image.setPos(render2d,-1,0,0 )

fs = ConfigVariableBool("fullscreen")

image = OnscreenImage(image = 'stop.png')
image.setScale(.1)
image.setPos(render2d,-1,0,0 )

base.accept('f', changeFullScreen)

run()

On startup:

After fullscreen:

After closing fullscreen:

Edit
A permanent link to the images: mcstrother.p3dp.com/fullscreenProblem.zip

The OnscreenImage class parents itself to aspect2d by default, and aspect2d does indeed change its coordinates when the window is resized. If you really want it to remain unchanged when you resize the window, you can choose one of:

a) explicitly parent the image to render2d
b) explicitly parent it to base.a2dLeft
c) leave it parented to aspect2d, but explicitly reposition it every time the window changes sizes (by listening for the window-event).

David

Thanks a lot! Option c seems to resolve my problem perfectly. I’d also love to be able to use base.a2dLeft (I’m trying to layout a 2d GUI), but it seems to be of type float.

base.a2dLeft is a float value containing the X coordinate of the left border of the screen.

Use base.a2dLeftCenter instead - which is a NodePath that should automatically be positioned by panda.
There’s also base.a2dTopLeft and base.a2dBottomLeft.

Ah. Perfect. Thank you both!