Segfault while scaling textures


I am trying to set some text on a model(a cube with 8 vertices,6 faces). Since the text is static, i am doing this by putting the text on a png image and then using that image as a texture to the model.

environ = loader.loadModel("mycube")
#black text = on a white background
boxTexture = loader.loadTexture('equal.png')
#environ.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition)
environ.setTexScale(TextureStage.getDefault(), 25,25)

without the setTexScale, i can only see the white background.
When i tried to use clamp, the model is just turning black.
So i assumed that the texture is large enough to be wrapped and wanted to scale down.

when i used setTexScale(TextureStage.getDefault,u,v) with values of u and v less than 1 i get a seg fault.But if the values are greater than 1 , it seems to work fine.

Here are my questions:

  • Is there a better way to set some text on a model other than using textures?
  • If i have to use textures, is what i am doing the right way to do it?
  • If i get a seg fault for values less than 1 , is this the a problem with panda1.1(on debian unstable) or is it that i cannot scale down textures?

Thanks in advance.

You should certainly be able to scale the UV’s to a value less than 1. And, in fact, it works just fine for me. Tell me more about this.

You say when you scale the UV’s to a value larger than 1, “it works fine”. Do you mean that you can see the texture changing scale, or do you just mean that it doesn’t crash? If you’re unable to see the texture on your model at any scale, other than a single uniform color, it may be that your model is lacking UV’s altogether (see Automatic Texture Coordinates in the manual). If this is the case, it might actually be your graphics driver that is causing the segment fault, not Panda itself, since applying texture without UV’s is technically an error condition and might not be handled gracefully by the driver.


I have uploaded the sample code to test this

Yes david, you were right, the model did not have u,v values.Hence, when i comment out the setTextGen lines, the scale function has no effect.But when i generate the texture coordinates automatically, there is a difference between the scaled and unscaled versions and yes it works for values greater and less than 1.Thanks for the help.

When i tried setting the texGenMode to TexGenAttrib.MPointSprite, i got the following error when the values of u and v are < 1 , otherwise it is ok:

suman:/home/suman/exercise/paper/npl_sw/python/panda_gui# ppython
DirectStart: Starting the game.
Warning: DirectNotify: category 'Interval' already exists
Known pipe types:
(all display modules loaded.)
:express(warning): Adjusting global clock's real time by -1.18295 seconds.
Assertion failed: _supports_point_sprite at line 5375 of panda/src/glstuff/glGraphicsStateGuardian_src.cxx
Traceback (most recent call last):
  File "", line 40, in ?
  File "debtmp/usr/share/panda3d/direct/src/showbase/", line 1798, in run
  File "debtmp/usr/share/panda3d/direct/src/task/", line 782, in run
  File "debtmp/usr/share/panda3d/direct/src/task/", line 730, in step
  File "debtmp/usr/share/panda3d/direct/src/task/", line 673, in __stepThroughList
  File "debtmp/usr/share/panda3d/direct/src/task/", line 604, in __executeTask
  File "debtmp/usr/share/panda3d/direct/src/showbase/", line 1195, in igLoop
AssertionError: _supports_point_sprite at line 5375 of panda/src/glstuff/glGraphicsStateGuardian_src.cxx

Irrespective of what scale i tried i was unable to set the png on the face of the cube.can you please take a look at the code i uploaded and give me a hint/pointer about how i can set the whole png on the face of a cube.I tried setting WMClamp , but that gives me a blank texture.

Thanks for your time.

Ah, OK. You shouldn’t really be setting TexGenAttrib.MPointSprite, except when you are rendering a cloud of sprites as points. It doesn’t make sense to apply this TexGen mode to polygons, and it doesn’t make sense to scale the UV’s when you have applied this mode. So a Python exception, although not very informative, is a reasonable behavior for this error condition.

There’s no TexGenAttrib mode that will apply the same texture to each of the six faces of your cube. You will have to have actual UV’s for this. You can do this by using a modeling package, or if you have a good understanding of your cube’s geometry, you can try hand-editing the egg file to insert UV’s–you just need to put { 0 0 }, {0 1}, {1 1}, and {1 0} on the four corners of each face. (This also means you will need to replicate the corner vertices for each face, since a corner might have two different UV values, according to which face is it a part of.)


Thanks for the tip of editing the .egg file.When i started editing the file, i found that there are 24 vertices. But somewhere i made a mistake setting the UV values, but that did not seem to work.

So, i decided to go the modelling package way, and i used blender’s UV editor to add UV values to the model and it worked like a charm. Thanks for the help :slight_smile:. Using the modelling package i was also make the edges of my cube smooth instead of sharp.

Consider this as an very novice question:

how much work would it be to add a support to autogenerate the UV’s, for all faces of a cube?

If i have some time left to work on graphics, i would pick something like this.Should be very educational for me.

But how do you even find all the faces of a cube? What if you’re not even rendering a cube? All Panda has to go by is a set of polygons; it has no real idea what the geometry is shaped like.

In any case, most of the TexGenAttrib modes are based on what the hardware is already capable of doing–Panda isn’t actually generating the UV’s itself; it’s asking the hardware to do it. And there aren’t any hardware modes that generate the faces of a cube (although I guess you could hack the cube map modes to do it, but you’d have to load your texture up as a six-faced cube map–a more expensive proposition).

If your purpose is to generate a cube which has the UV’s already programmed into it, consider writing a standalone program that generates such a cube. You could use the Egg library to do this; there’s a tiny bit of documentation about this in the manual (and a lot more in the generated API docs). If you’re familiar with C++, you could also look at egg-make-tube (pandatool/src/eggprogs/eggMakeTube.cxx) for an example of a standalone program that generates a particular geometrical shape.