Render 2d image

Hi,

I am fairly new to panda3d and i have a problem with image rendering.

I try to render a 2D image to the screen. I tried this code:

 CardMaker cardmaker("cardMaker");
 PT(Texture) tex;
 tex = TexturePool::load_texture("source/image/cursor.PNG");
 tex->set_magfilter(Texture::FT_nearest);
 tex->set_minfilter(Texture::FT_nearest);
 NodePath cursor(cardmaker.generate());
 cursor.set_texture(tex); 
 cursor.reparent_to(window->get_render_2d());

The programm load and display the image, but the size of the image isn´t correct.I work with a 800x600 fullscreen mode, and the image is 32x32 in size, but the program scaled the image about half of the screen!?I dont scaled it or do any other transformations, just use the code about.

Does anyone know what i do wrong, or have a c++ example for display 2d images?

I tried the forum search(like many times before), but i found nothing about this problem).

I would be glad if you could help me.

Thanks!

-Skabus

Hi, welcome to the forums!

This is normal behaviour, that you can expect in any 3D engine. The texture coordinates are always transformed to 0…1 range.

If you don’t want this, reparent it to pixel2d and set the scale appropriately (to 32, 32 probably). But you probably don’t want that either, because that means that when your window is rescaled, your image won’t rescale with it. So you’ll probably just want to scale down the cursor image uniformly.

Thanks for you answer :slight_smile:

The problem is, that i dont want to rescale all the images,i want to show,manually.

There have to be a possibility to show an image on the screen in a usual way.

But i have no idea how to do this.

Where could i find informations about pixel2d? In c++ this rendernode dont exist, I thought…?

-Ska

This is the “usual” way to show images in a 3D engine. I don’t think pixel2d is available in C++ at the moment, so you’ll need to manually rescale your texture to make the size on the screen be 32x32.