Panda3D/C++ Noob

Hello there.
I’m new to both C++ and Panda3D and I’m trying to make a small game, and I’ve run into a couple problems.

Problem 1: If I change the “My Panda3D Window” string, the game crashes. If I leave it on My Panda3D Window, it turns into a bunch of seemingly random characters.

Problem 2: I’m not sure how to use TexturePool to draw a main menu background image. :frowning:

int main(int argc, char *argv[]) {
    //open a new window framework
  framework.open_framework(argc, argv);
    //set the window title to My Panda3D Window
  framework.set_window_title("Test");
    //open the window
  WindowFramework *window = framework.open_window();

	PT(Texture) tex;
	tex = TexturePool::load_texture("Menu-0.png");

	CardMaker cm("cardMaker");
	PT(PandaNode) readyCard = cm.generate();
	NodePath path(readyCard);
	path.set_texture( tex ); 
 
    // Run the engine.
    framework.main_loop();
    // Shut down the engine when done.
    framework.close_framework();
    return (0);
}

I’m new to Panda3D, too, so I cannot help you with your problems. But in my experience, it’s crucial to learn the language for at least a half year up to two years (depending on if you have already gain experience in programming) before trying to make a game.
I don’t want to criticize you, I only want to warn you that you might run into a whole bunch of problems and give up programming at all - That would be a pity.

This problem has been reported by some (but not all) Windows 7 users. We haven’t figured it out yet.

Your example code lacks placing the card into the scene graph for rendering:

path.reparent_to(window->get_render_2d());

David

What did you say? :open_mouth:
I used to have exactly the same problem under Windows 7. I managed to solve it, but unfortunatley, I don’t remember how :frowning:
I will tell you, as soon as I recall.

/EDIT @Sam:
By the way, which IDE do you use?

I’m using Visual C++ 2010 Express Edition under XP Professional Edition.

I got a couple different results from two different codes.

Code #1:

NodePath menuBackground;
	menuBackground = window->load_model(window->get_render_2d(), "Menu-0.png");

Result #1:

Code #2:

PT(Texture) tex;
   tex = TexturePool::load_texture("Menu-0.png");

   CardMaker cm("cardMaker");
   PT(PandaNode) readyCard = cm.generate();
   NodePath path(readyCard);
   path.set_texture( tex );
   path.reparent_to(window->get_render_2d());

Result #2:

In the first example, WindowFramework::load_model() creates a card that is the size (1680 x 1027), or whatever size your texture is.

In the second example, the default CardMaker creates a card that is the size (1 x 1).

However, the window itself (render2d) is the size (2 x 2): that is, the coordinates range from -1 to 1 in both dimensions. If your goal is to create a card that exactly fills this space, you will need to create a card that also ranges from -1 to 1 in both dimensions.

There are several ways to do this. One easy way is to use the CardMaker::set_frame() interface:

cm.set_frame(-1, 1, -1, 1)

David

Awesome, I got it working. Thanks guys :smiley:

Tht’s it! I remember how I solved the problem with that crap in the window title. Of course, I don’t know what exactly is the bug, but after trying with Visual C++ 2010 I downloaded Visual C++ 2008 from here - It worked like a charm :smiley:
So this may serve as a temporary bug"fix", until it is really fixed.
Another advantage of using the 2008 edition is that the manual is written for setting up Panda3D with it. Within 2010 they have changed quite a few things and in my opinion it is easier to immedeatley getting started than first having to search how to include libraries with the new IDE.

Hey guys, im trying to do something similar to him, but when i try his ‘Code #1’ (NodePath menuBackground = window->load_model(… etc, my application runs correctly, but the console tells me that the extension of my texture (“texture.PNG”) is unrecognized; cannot load.

Any ideas why?

Case matters. Try naming it “texture.png” instead.

David