Hi!
I was using QT 4.4 and Ogre3D 1.4.9 to create a level editor in visual studio 8. I was able to get an Ogre window up and running as a widget and got some more features working. However, this morning all of a sudden it started giving me some MOC errors on the Ogre widget cpp file out of nowhere. I retraced my steps and took out the new changes but the error did not seem to go away.
Just for the heck of it, I started a project from scratch and pasted a fresh block of code (just to get basic ogre window up and running, this worked the last time) and I keep getting similar error. I checked the Ogre log and it is blank...which means Ogre never initialized at all.
Here are the errors I am getting:
1>------ Build started: Project: WorldBuilder, Configuration: Debug Win32 ------
1>Moc'ing ogrewidget.h...
1>Uic'ing d:\My Documents\Projects\Ogre3D\WorldBuilder\WorldBuilde r\worldbuilder.ui...
1>Moc'ing worldbuilder.h...
1>Compiling...
1>main.cpp
1>worldbuilder.cpp
1>ogrewidget.cpp
1>Generating Code...
1>Compiling...
1>moc_ogrewidget.cpp
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(37) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(37) : error C2039: 'staticMetaObject' : is not a member of 'Ogre'
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(42) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(42) : error C2039: 'metaObject' : is not a member of 'Ogre'
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(43) : error C2270: 'metaObject' : modifiers not allowed on nonmember functions
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(47) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(47) : error C2039: 'qt_metacast' : is not a member of 'Ogre'
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(51) : error C2673: 'qt_metacast' : global functions do not have 'this' pointers
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(52) : error C2352: 'QWidget::qt_metacast' : illegal call of non-static member function
1> c:\qt\4.4.0\src\gui\kernel\qwidget.h(122) : see declaration of 'QWidget::qt_metacast'
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(55) : error C3083: 'OgreWidget': the symbol to the left of a '::' must be a type
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(55) : error C2039: 'qt_metacall' : is not a member of 'Ogre'
1>d:\my documents\projects\ogre3d\worldbuilder\worldbuilde r\generatedfiles\debug\moc_ogrewidget.cpp(57) : error C2352: 'QWidget::qt_metacall' : illegal call of non-static member function
1> c:\qt\4.4.0\src\gui\kernel\qwidget.h(122) : see declaration of 'QWidget::qt_metacall'
1>Build log was saved at "file://d:\My Documents\Projects\Ogre3D\WorldBuilder\WorldBuilde r\Debug\BuildLog.htm"
1>WorldBuilder - 12 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here ar ethe only two files that I have added to the basic QT project: (then I created a widget in the .ui file and promoted it to OgreWidget)
OgreWidget.h
#ifndef OGREWIDGET_H_
#define OGREWIDGET_H_
#include <QWidget>
#include <Ogre.h>
{
Q_OBJECT
public:
~OgreWidget();
protected:
void refresh();
private:
Ogre::Root* root;
Ogre::SceneManager* sceneManager;
Ogre::RenderWindow* window;
Ogre::Camera* cam;
};
#endif /*OGREWIDGET_H_*/
#ifndef OGREWIDGET_H_
#define OGREWIDGET_H_
#include <QWidget>
#include <Ogre.h>
class OgreWidget : public QWidget
{
Q_OBJECT
public:
OgreWidget(QWidget* parent);
~OgreWidget();
protected:
void paintEvent(QPaintEvent* evt);
void resizeEvent(QResizeEvent* evt);
void timerEvent(QTimerEvent* evt);
void refresh();
private:
Ogre::Root* root;
Ogre::SceneManager* sceneManager;
Ogre::RenderWindow* window;
Ogre::Camera* cam;
};
#endif /*OGREWIDGET_H_*/
To copy to clipboard, switch view to plain text mode
OgreWidget.cpp
#include "ogrewidget.h"
#include <QMouseEvent>
OgreWidget
::OgreWidget(QWidget* parent
) : QWidget(parent, Qt
::MSWindowsOwnDC){
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoBackground);
root = 0;
sceneManager = 0;
window = 0;
cam = 0;
}
OgreWidget::~OgreWidget()
{
}
{
if(!window)
{
using namespace Ogre;
Ogre::NameValuePairList params;
WId wid = winId();
params["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)wid);
// This doesn't actually work anymore. Look at the Qt Ogre model viewer for how to do this.
#if !defined(Q_WS_WIN)
char buf[64];
sprintf(buf, "SDL_WINDOWID=0x%1x", wid);
putenv(buf);
#endif
root = new Ogre::Root();
root->loadPlugin("RenderSystem_GL_d");
Ogre::RenderSystemList *list = root->getAvailableRenderers();
Ogre::RenderSystemList::iterator i = list->begin();
while (i != list->end())
{
if ((*i)->getName() == "OpenGL Rendering Subsystem")
{
root->setRenderSystem(*(i));
break;
}
i++;
}
root->initialise(false);
window = root->createRenderWindow("OgreWindow", width(), height(), false, ¶ms);
sceneManager = root->createSceneManager(Ogre::ST_GENERIC);
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
cam = sceneManager->createCamera("Cam");
window->addViewport(cam)->setBackgroundColour(Ogre::ColourValue::Black);
cam->setPosition(0, 150, 100);
cam->lookAt(0, 150, 0);
startTimer(60);
}
refresh();
}
{
if(window)
{
window->resize(width(), height());
window->windowMovedOrResized();
cam->setAspectRatio(Ogre::Real(window->getViewport(0)->getActualWidth()) / Ogre::Real(window->getViewport(0)->getActualHeight()));
}
}
{
refresh();
}
void OgreWidget::refresh()
{
Ogre::Root::getSingleton()._fireFrameStarted();
window->update();
Ogre::Root::getSingleton()._fireFrameEnded();
}
#include "ogrewidget.h"
#include <QMouseEvent>
OgreWidget::OgreWidget(QWidget* parent) : QWidget(parent, Qt::MSWindowsOwnDC)
{
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoBackground);
root = 0;
sceneManager = 0;
window = 0;
cam = 0;
}
OgreWidget::~OgreWidget()
{
}
void OgreWidget::paintEvent(QPaintEvent* evt)
{
if(!window)
{
using namespace Ogre;
Ogre::NameValuePairList params;
WId wid = winId();
params["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)wid);
// This doesn't actually work anymore. Look at the Qt Ogre model viewer for how to do this.
#if !defined(Q_WS_WIN)
char buf[64];
sprintf(buf, "SDL_WINDOWID=0x%1x", wid);
putenv(buf);
#endif
root = new Ogre::Root();
root->loadPlugin("RenderSystem_GL_d");
Ogre::RenderSystemList *list = root->getAvailableRenderers();
Ogre::RenderSystemList::iterator i = list->begin();
while (i != list->end())
{
if ((*i)->getName() == "OpenGL Rendering Subsystem")
{
root->setRenderSystem(*(i));
break;
}
i++;
}
root->initialise(false);
window = root->createRenderWindow("OgreWindow", width(), height(), false, ¶ms);
sceneManager = root->createSceneManager(Ogre::ST_GENERIC);
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
cam = sceneManager->createCamera("Cam");
window->addViewport(cam)->setBackgroundColour(Ogre::ColourValue::Black);
cam->setPosition(0, 150, 100);
cam->lookAt(0, 150, 0);
startTimer(60);
}
refresh();
}
void OgreWidget::resizeEvent(QResizeEvent* evt)
{
if(window)
{
window->resize(width(), height());
window->windowMovedOrResized();
cam->setAspectRatio(Ogre::Real(window->getViewport(0)->getActualWidth()) / Ogre::Real(window->getViewport(0)->getActualHeight()));
}
}
void OgreWidget::timerEvent(QTimerEvent* evt)
{
refresh();
}
void OgreWidget::refresh()
{
Ogre::Root::getSingleton()._fireFrameStarted();
window->update();
Ogre::Root::getSingleton()._fireFrameEnded();
}
To copy to clipboard, switch view to plain text mode
contents of moc_ogrewidget.cpp
/****************************************************************************
** Meta object code from reading C++ file 'ogrewidget.h'
**
** Created: Tue Aug 12 02:00:54 2008
** by: The Qt Meta Object Compiler version 59 (Qt 4.4.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../Source/ogrewidget.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'ogrewidget.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 59
#error "This file was generated using the moc from 4.4.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Ogre__OgreWidget[] = {
// content:
1, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0 // eod
};
static const char qt_meta_stringdata_Ogre__OgreWidget[] = {
"Ogre::OgreWidget\0"
};
const QMetaObject Ogre
::OgreWidget::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_Ogre__OgreWidget,
qt_meta_data_Ogre__OgreWidget, 0 }
};
const QMetaObject *Ogre
::OgreWidget::metaObject() const {
return &staticMetaObject;
}
void *Ogre::OgreWidget::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Ogre__OgreWidget))
return static_cast<void*>(const_cast< OgreWidget*>(this));
return QWidget::qt_metacast(_clname
);
}
int Ogre
::OgreWidget::qt_metacall(QMetaObject::Call _c,
int _id,
void **_a
) {
_id
= QWidget::qt_metacall(_c, _id, _a
);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
/****************************************************************************
** Meta object code from reading C++ file 'ogrewidget.h'
**
** Created: Tue Aug 12 02:00:54 2008
** by: The Qt Meta Object Compiler version 59 (Qt 4.4.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../Source/ogrewidget.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'ogrewidget.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 59
#error "This file was generated using the moc from 4.4.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Ogre__OgreWidget[] = {
// content:
1, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0 // eod
};
static const char qt_meta_stringdata_Ogre__OgreWidget[] = {
"Ogre::OgreWidget\0"
};
const QMetaObject Ogre::OgreWidget::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_Ogre__OgreWidget,
qt_meta_data_Ogre__OgreWidget, 0 }
};
const QMetaObject *Ogre::OgreWidget::metaObject() const
{
return &staticMetaObject;
}
void *Ogre::OgreWidget::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Ogre__OgreWidget))
return static_cast<void*>(const_cast< OgreWidget*>(this));
return QWidget::qt_metacast(_clname);
}
int Ogre::OgreWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
To copy to clipboard, switch view to plain text mode
I'd greatly appreciate any help at all!
Bookmarks