Added stand-alone GUI test, compiles and runs

actorid
Nicolay Korslund 14 years ago
parent 4f170b14ea
commit 3896fd218a

1
.gitignore vendored

@ -18,3 +18,4 @@ resources
mwcompiler
mwinterpreter
clientconsole
MyGUI.log

@ -130,9 +130,9 @@ file(GLOB ESM_HEADER components/esm/*.hpp)
source_group(components\\esm FILES ${ESM_HEADER})
set(OGRE
components/engine/ogre/renderer.cpp)
${CMAKE_SOURCE_DIR}/components/engine/ogre/renderer.cpp)
set(OGRE_HEADER
components/engine/ogre/renderer.hpp)
${CMAKE_SOURCE_DIR}/components/engine/ogre/renderer.hpp)
source_group(components\\engine\\ogre FILES ${OGRE} ${OGRE_HEADER})
set(INPUT
@ -203,7 +203,12 @@ include_directories("."
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre
${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
${PLATFORM_INCLUDE_DIR}
${CMAKE_HOME_DIRECTORY}/extern/caelum/include)
${CMAKE_HOME_DIRECTORY}/extern/caelum/include
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include
)
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR})
add_subdirectory( extern/caelum )
@ -264,6 +269,7 @@ endif (APPLE)
# Other apps and tools
add_subdirectory( apps/clientconsole )
add_subdirectory( apps/mygui_dev )
# Apple bundling
if (APPLE)

@ -0,0 +1,11 @@
add_executable(mygui_test
main.cpp
${OGRE}
${OGRE_HEADER}
)
target_link_libraries(mygui_test
${OGRE_LIBRARIES}
${OIS_LIBRARIES}
MyGUIEngine
MyGUI.OgrePlatform
)

@ -0,0 +1,35 @@
#include <iostream>
using namespace std;
#include <MyGUI.h>
#include <MyGUI_OgrePlatform.h>
using namespace MyGUI;
#include <components/engine/ogre/renderer.hpp>
#include <OgreResourceGroupManager.h>
int main()
{
Render::OgreRenderer ogre;
ogre.configure(false, "plugins.cfg", false);
ogre.createWindow("MyGUI test");
ogre.createScene();
// Disable MyGUI logging
LogManager::initialise();
LogManager::setSTDOutputEnabled(false);
// Set up OGRE connection to MyGUI
OgrePlatform *platform = new OgrePlatform();
platform->initialise(ogre.getWindow(), ogre.getScene());
// Create GUI
Gui *gui = new Gui();
gui->initialise();
// Add the Morrowind windows resources
Ogre::ResourceGroupManager::getSingleton().
addResourceLocation("resources/mygui/", "FileSystem", "General");
return 0;
}

@ -15,22 +15,7 @@ using namespace Ogre;
MWScene::MWScene(Render::OgreRenderer &_rend)
: rend(_rend)
{
Root *root = rend.getRoot();
RenderWindow *window = rend.getWindow();
// Get the SceneManager, in this case a generic one
sceneMgr = root->createSceneManager(ST_GENERIC);
// Create the camera
camera = sceneMgr->createCamera("PlayerCam");
camera->setNearClipDistance(5);
// Create one viewport, entire window
vp = window->addViewport(camera);
// Alter the camera aspect ratio to match the viewport
camera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
camera->setFOVy(Degree(55));
rend.createScene("PlayerCam", 55, 5);
// Set default mipmap level (NB some APIs ignore this)
TextureManager::getSingleton().setDefaultNumMipmaps(5);
@ -43,10 +28,7 @@ MWScene::MWScene(Render::OgreRenderer &_rend)
// the screen (when x is to the right.) This is the orientation that
// Morrowind uses, and it automagically makes everything work as it
// should.
SceneNode *rt = sceneMgr->getRootSceneNode();
SceneNode *rt = rend.getScene()->getRootSceneNode();
mwRoot = rt->createChildSceneNode();
mwRoot->pitch(Degree(-90));
// For testing
sceneMgr->setAmbientLight(ColourValue(1,1,1));
}

@ -21,9 +21,6 @@ namespace MWRender
class MWScene
{
Render::OgreRenderer &rend;
Ogre::SceneManager *sceneMgr;
Ogre::Camera *camera;
Ogre::Viewport *vp;
// Root node for all objects added to the scene. This is rotated so
// that the OGRE coordinate system matches that used internally in
@ -33,10 +30,10 @@ namespace MWRender
public:
MWScene(Render::OgreRenderer &_rend);
Ogre::Camera *getCamera() { return rend.getCamera(); }
Ogre::SceneNode *getRoot() { return mwRoot; }
Ogre::SceneManager *getMgr() { return sceneMgr; }
Ogre::Camera *getCamera() { return camera; }
Ogre::Viewport *getViewport() { return vp; }
Ogre::SceneManager *getMgr() { return rend.getScene(); }
Ogre::Viewport *getViewport() { return rend.getViewport(); }
};
}

@ -5,6 +5,8 @@
#include "OgreLogManager.h"
#include "OgreLog.h"
#include <assert.h>
using namespace Ogre;
using namespace Render;
@ -53,6 +55,26 @@ bool OgreRenderer::configure(bool showConfig,
void OgreRenderer::createWindow(const std::string &title)
{
assert(mRoot);
// Initialize OGRE window
mWindow = mRoot->initialise(true, title, "");
}
void OgreRenderer::createScene(const std::string camName, float fov, float nearClip)
{
assert(mRoot);
assert(mWindow);
// Get the SceneManager, in this case a generic one
mScene = mRoot->createSceneManager(ST_GENERIC);
// Create the camera
mCamera = mScene->createCamera(camName);
mCamera->setNearClipDistance(nearClip);
mCamera->setFOVy(Degree(fov));
// Create one viewport, entire window
mView = mWindow->addViewport(mCamera);
// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
}

@ -12,6 +12,9 @@ namespace Ogre
{
class Root;
class RenderWindow;
class SceneManager;
class Camera;
class Viewport;
}
namespace Render
@ -20,11 +23,14 @@ namespace Render
{
Ogre::Root *mRoot;
Ogre::RenderWindow *mWindow;
Ogre::SceneManager *mScene;
Ogre::Camera *mCamera;
Ogre::Viewport *mView;
bool logging;
public:
OgreRenderer()
: mRoot(NULL) {}
: mRoot(NULL), mWindow(NULL), mScene(NULL) {}
~OgreRenderer() { cleanup(); }
/** Configure the renderer. This will load configuration files and
@ -36,6 +42,12 @@ namespace Render
/// Create a window with the given title
void createWindow(const std::string &title);
/// Set up the scene manager, camera and viewport
void createScene(const std::string camName="Camera",// Camera name
float fov=55, // Field of view angle
float nearClip=5 // Near clip distance
);
/// Kill the renderer.
void cleanup();
@ -50,6 +62,15 @@ namespace Render
/// Get the rendering window
Ogre::RenderWindow *getWindow() { return mWindow; }
/// Get the scene manager
Ogre::SceneManager *getScene() { return mScene; }
/// Camera
Ogre::Camera *getCamera() { return mCamera; }
/// Viewport
Ogre::Viewport *getViewport() { return mView; }
};
}

@ -463,16 +463,6 @@ extern "C" void gui_showHUD()
extern "C" void gui_setupGUI(int32_t debugOut)
{
ResourceGroupManager::getSingleton().
addResourceLocation("media_mygui", "FileSystem", "General");
// Enable/disable logging to stdout
MyGUI::LogManager::initialise();
MyGUI::LogManager::setSTDOutputEnabled(debugOut);
mGUI = new MyGUI::Gui();
mGUI->initialise(mWindow);
int mWidth = mWindow->getWidth();
int mHeight = mWindow->getHeight();

@ -1,12 +0,0 @@
#include <MyGUI.h>
// The global GUI object
MyGUI::Gui *mGUI;
// This is used to determine if we are displaying any gui elements
// right now. If we are (and guiMode > 0), we redirect mouse/keyboard
// input into MyGUI.
int32_t guiMode = 0;
#include "../gui/cpp_mygui.cpp"
#include "../terrain/cpp_terrain.cpp"
Loading…
Cancel
Save