I decide to divide the screen into several part. One part is to draw a GUI. Another part is to draw the camera view.
Usually, if I want to add the GUI to on top on the camera view, I can add a small window (like the one in tutorial "MeshViewer").
Howerver, I don't want to do so since I don't want the window frame appear in my game. Therefore, I would like to add a panel and put all the menu or items on top of the panel.
How can I do so?
3D scene and GUI in the same view
Look in the IGUIEnvironment class, or some of the tutorials have some use of the GUI stuff, such as Hello World or the Mesh Viewer. You can create a window which can then have items added to it, or you dont even need to use a window in fact, just add items to the root GUI node and they'll appear on the screen.
Actually, I have read through all the tutorials related to the GUI already.JP wrote:Look in the IGUIEnvironment class, or some of the tutorials have some use of the GUI stuff, such as Hello World or the Mesh Viewer. You can create a window which can then have items added to it, or you dont even need to use a window in fact, just add items to the root GUI node and they'll appear on the screen.
But it seems that they can't help me solve my problem.
The main point is that I hope 3D scence and GUI(2D) needs to be drawn in the same view/panel.
(It seems that MeshViewer tutorial is similar to that. However, I don't want to GUI like a window which have window frame and cover upon the 3D scene.What I need is the panel is divided to 2 parts. One is 3D scene and one is GUI. The area GUI occpies and area the 3D sciene ocupies have certain ratio.)
I would like to ask if I want to do such thing, do I really need to change the source code myself or are there any functions which can give me helping hand?
Yes, I know the SplitScreen Tutorial has talked about that.JP wrote:I think someone else has asked for a similar thing, to have the 3D scene take up only part of the screen, so look through the beginners and advanced forums for something like that, i think one of the threads was called something about having a second camera view overlaid onto the main scene.
Nonetheless, I seems doesn't give any help to my problem.
In the tutorial, it saids
"After Render all objects (view of 4 cameras)
If you have a GUI:
Set the viewport the whole screen
Display the GUI
End scene "
But it doesn't work.
In my case, I try to set there is one camera only and use viewport to set the area that display the 3D scene in the panel. After render the objects in 3d scene, I disply the GUI. But don't know why only the 3D scence can be shown but no GUI I have added.
Have I done something wrong?
Code: Select all
gui::IGUITabControl* tabctrl = 0;
gui::IGUITab* optTab = 0;
gui::IGUITab* aboutTab = 0;
while(device->run()) {
//Set the viewpoint the the whole screen and begin scene
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
driver->beginScene(true,true,SColor(0,100,100,100));
driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
//Activate camera
smgr->setActiveCamera(camera);
//Draw scene
smgr->drawAll();
if (!(tabctrl) && !(optTab) && !(aboutTab) ){
tabctrl = env->addTabControl(core::rect<int>(ResX/2,0,ResX,ResY/2), 0, true, true);
optTab = tabctrl->addTab(L"Demo");
aboutTab = tabctrl->addTab(L"About");
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
env->drawAll ();
}
driver->endScene();
//Get and show fps
if (driver->getFPS() != lastFPS) {
lastFPS = driver->getFPS();
wchar_t tmp[1024];
swprintf(
tmp,
1024,
L"Irrlicht SplitScreen-Example (FPS: %d)",
lastFPS);
device->setWindowCaption(tmp);
}
}