Image Resolution loss in panda3d C++

I use the following codes to set up my background picture:

np_background = window->load_model(render2d, "./Elements/backwithno_2.png");
np_background.set_scale(0.1, 1, 0.1);
np_background.set_pos(-1.5, 0.1, 0);

Nevertheless, the picture is shown in my panda Window. However, it seems the image resolution is not as good as the original .png file, which looks not very good.

Is there any reason?

From the manual:

By default, Panda3D will automatically rescale any texture image down to the nearest smaller power of two when you read it from disk, so you usually don’t have to think about this–but your application will load faster if you scale your textures properly in the first place.

If you would like Panda3D to rescale your images up to the next larger power of two instead of down to the next smaller power of two, use:

textures-power-2 up

In your config file. The default is:

textures-power-2 down

This could be causing the loss of resolution.

Or you can disable the rescaling entirely by setting it to none, assuming the driver supports it (most drivers do nowadays).

Thank you, but I have some problem in changing my config.prc file.
I use
load_prc_file_data("", "direct-gui-edit 1");

However, it seems not work at all. I can use it in python, but I don’t why in C++ it is wrong.
Besides, I use
textures-power-2 up
it seems no change occurred.

I don’t ensure if I have changed the config successfully.

Besides, I use
load_prc_file_data("", "fullscreen true");

it is worked as expected.

Finally, I directly open the Config.prc file as .txt file, and modify it, but only the fullscreen true is effective. direct-gui-edit seems not work even I have changed its value to 1 in the Config.prc file.

You need to ensure that it is called before the first window is opened. I think you will want to try setting it to none to see if the scaling is the issue here at all.

direct-gui-edit has no effect in C++ because DirectGui is a Python-only feature, sorry.

thank you rgb, I’m sure that load_prc_file_data is called before the first window.

But I don’t ensure what do you mean that setting what to none?
(I’m sorry actually I can try it, but I worry that I can’t distinguish whether the error is caused by my codes or some configurations)
can you tell me the specific codes?
Is that
load_prc_file_data("", "textures-power-2 none"); ?

Thanks in advance

Yes, that setting will tell Panda not to rescale the textures.

It works now! Thanks for your help !