The only other code is the main thread where the framework initialises and opens the window and loop.
Heres the only other code…
#include "pandaFramework.h"
#include "cardMaker.h"
#include "texture.h"
#include "texturePool.h"
#include "pandaSystem.h"
#include "PGButton.h"
#include "PGFrameStyle.h"
PandaFramework framework;
//Load our task manager
PT(AsyncTaskManager) taskMgr = AsyncTaskManager::get_global_ptr();
enum controlMode{
Menu,
firstPerson,
thirdPerson,
Camera
};
controlMode curCtrlMode = Menu;
void changeControlMode(controlMode ctrl){
curCtrlMode = ctrl;
}
//This is where the "mainMenu" function is.
int main(int argc, char *argv[]) {
//open a new window framework
framework.open_framework(argc, argv);
//set the window title to My Panda3D Window
//open the window
WindowFramework *window = framework.open_window();
mainMenu(window);
// Run the engine.
framework.main_loop();
// Shut down the engine when done.
framework.close_framework();
return (0);
}
You’re not, by chance, using MSVS 2010, are you? We’ve had other reports of strange behavior by that compiler, particularly when used to compile against the Panda3D dll’s distributed here (which were built with MSVS 2008).
If you build your own Panda from scratch using makepanda, that shouldn’t be an issue.
I don’t know. It depends on what you want to do. The standard advantages of having easy access to the source code in case you want to tinker under the hood, of course.
But as far as the code itself, no, there’s not a big difference between the source code on the trunk and the 1.7.0 version. If you’re not confident you can build the Panda source without headaches, then save yourself the bother and use the pre-built version.
Alright, well I’m using the pre-built version in msvs2008 and everything seems to be working so far.
Just a couple questions about PGUI:
How do I get the button to scale itself according to the texture? I tried using Texture.X / Window.X with set_frame using ints, doubles and a float, but apparently 360/1024 = 0.
Can I get rid of the default label/how do I get rid of it?
If I can’t get rid of the label, how do I change the font colour etc? I tried manipulating button->get_text_node(), but there was no changes
You can scale the button to whatever size you like. Texture.X / Window.X is a reasonable choice. 360/1024 = 0 in C++ (and in Python for that matter), but float(360) / float(1024) = 0.3515625.
If you want a custom button, then you should create the geometry you want to use to render it, in the four different states (ready, depressed, rollover, inactive), and pass those four NodePaths to PGButton::setup(). This will completely replace the default card with whatever you specify.
If you don’t want to go that far, you can change the properties you like on button->get_text_node(), but you have to do this before you call setup().
(float)x is the C way to perform what’s known as a “cast”, to convert the expression x to the type float. This may be necessary in the middle of an expression if you want the expression to be computed using floating-point arithmetic instead of integer arithmetic.
You can call button->set_frame() to the desired size after you have called button->setup(); or you can avoid calling button->setup() in the first place and just attach the desired geometry to each state_def instance yourself.
I don’t know why this would be. Are you scaling the font, instead of the node, or something?