Images and browser plugin

Sorry if this is not the right place to post this one.

I am trying to create a game that uses quite some onScreeImage. I programmed it and now I exported it to a p3d file, but when I try to run the p3d it says:

gobj: Loading texture /mf/
gobj: Implicitly rescaling from by to by
:pnimage: could not read

For every image I have on the screen.
I tried adding -r tk in the command that creates the file but it was not successful.

Any tips?

Thanks in advance,

  • Fernando Coelho.

It’s weird, I load images from p3d files without problems (that is: it should work). Can you give more details?

The images are in the .png format.

here is the code that writes it:

        for i in range (20):
            for j in range(20):
                imageObject = StaticImage('grama 1.png', True, (32*i, 24*j))
        imageObject = StaticImage('planta.jpg', True, (40, 40)) 

Where StaticImage is a class that loads the image, converts pixels to screen position and set the transparency.

I removed one of the fors so I could get the whole error message:

DirectStart: Starting the game.
:display: loading display module: libpandagl.dll
:display: loading display module: libpandadx9.dll
:display: loading display module: libpandadx8.dll
:display: loading display module: libtinydisplay.dll
Known pipe types:
  wglGraphicsPipe
  wdxGraphicsPipe9
  wdxGraphicsPipe8
  TinyWinGraphicsPipe
  TinyOffscreenGraphicsPipe
(all display modules loaded.)
:display:windisplay: OS version: 6.0.2.6002
:display:windisplay:   Service Pack 2
:display:windisplay: max Mhz 2936000000, current Mhz 2136000000
:ShowBase: Default graphics pipe is wglGraphicsPipe (OpenGL).
:display: Unable to set window properties: !undecorated
:ShowBase: Successfully opened window of type wglGraphicsWindow (OpenGL)
:audio: NullAudioManager
:audio: NullAudioManager
:ShowBase: __dev__ == 0
:pnmimage(error): Could not read image grama 1.png
:gobj: Loading texture /mf/grama 1.png
:gobj: Implicitly rescaling grama 1.png from 32 by 24 to 32 by 16
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image grama 1.png
:pnmimage(error): Could not read image example.png
:gobj: Loading texture /mf/example.png
:gobj: Implicitly rescaling example.png from 23 by 33 to 16 by 32
:ShowBase: Got window event: origin=(-1, -1) size=(640, 480) title="Panda" !undecorated !fullscreen foreground !minimized open !cursor_hidden absolute
:ShowBase: Got window event: origin=(-1, -1) size=(640, 480) title="Panda" !undecorated !fullscreen !foreground !minimized open !cursor_hidden absolute
:ShowBase: Got window event: origin=(-1, -1) size=(640, 480) title="Panda" !undecorated !fullscreen foreground !minimized open !cursor_hidden absolute
:display: Closing wglGraphicsWindow
:ShowBase: Got window event: origin=(-1, -1) size=(640, 480) title="Panda" !undecorated !fullscreen !foreground !minimized !open !cursor_hidden absolute
:ShowBase: User closed main window.
:ShowBase: Exiting ShowBase.

Replace this:

imageObject = StaticImage('grama 1.png', True, (32*i, 24*j)) 

with this:

imageObject = StaticImage(base.appRunner.multifileRoot + '/grama 1.png', True, (32*i, 24*j)) 

David

Ah, it works now, thanks a lot.

BTW, in case someone reads this in the future, looking for help: the “base.appRunner” will only exist if the game is running from a p3d file. Took me a few minutes to realize this.

This is true, note that you can do the following to find out if you’re running in the web or from the python file itself like this:

if base.appRunner:
    print "Running in web!"
else:
    print "Running from python file!"

~powerpup118

Yup, or in the case of a filename:

if base.appRunner:
    filename = base.appRunner.multifileRoot + '/' + filename

I used this and now I can code my non-browser version and export it with no problems.