游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2981|回复: 3

OGRE初级问题,请赐教。

[复制链接]

22

主题

63

帖子

63

积分

注册会员

Rank: 2

积分
63
发表于 2009-3-22 10:19:00 | 显示全部楼层 |阅读模式
遇到如下困惑,请赐教:
一、问题描述
调《Pro OGRE 3D Programming》一书的程序时,出现如下报错信息:
错误行:
        // set up the render window with all default params
                RenderWindow *window = rSys->createRenderWindow(
                        "Manual Ogre Window",        // window title
                        800,                                        // window width, in pixels
                        600,                                        // window height, in pixels
                        false,                                        // fullscreen or not
                        0);                                                // use defaults for all other values
错误提示:
error C2039: “createRenderWindow”: 不是“Ogre::RenderSystem”的成员


错误行:
        Timer *timer = PlatformManager::getSingleton().createTimer();

错误提示:
error C2653: “PlatformManager”: 不是类或命名空间名称
error C2228: “.createTimer”的左边必须有类/结构/联合


出现如下错误后,我在网上找了一些相关资料,其中我想按如下方式试图解决此问题,可问题仍未能解决:
http://203.208.35.101/search?q=cache:eF59R75sVZQJ:bbs.ogre3d.cn/viewthread.php%3Ftid%3D175+%E2%80%9CPlatformManager%E2%80%9D:+%E4%B8%8D%E6%98%AF%E7%B1%BB%E6%88%96%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E5%90%8D%E7%A7%B0&cd=4&hl=zh-CN&ct=clnk&gl=cn&st_usg=ALhdy2-WSVI_jtCXXE0uGw01gmIHwGtEEA
我在“工具》选项》C++目录”下的include和lib选项下分别添加了:
包含文件(OgreSdk的安装目录为):
C:\OgreSDK\include库文件:
C:\OgreSDK\lib

二、我的编码过程:
1、用appwizard创建一个Ogre空项目。
2、新建一个.cpp文件,将如下内容复制到该文件中:
#include "Ogre.h"
#include <iostream>

#if defined(WIN32)
#include <windows.h>
#endif

using namespace Ogre;

#if defined(WIN32)
INT WINAPI WinMain (
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
#else
int main(int argc, char *argv[])
#endif
{

        // tell Root not to load from any plugins or settings file
        Root *root = new Root("", "");

        // Load feature plugins. Scene managers will register
        // themselves for all scene types they support
        root->loadPlugin(&quotlugin_CgProgramManager");
        root->loadPlugin("Plugin_OctreeSceneManager");

        // load rendersystem plugin(s). The order is important in that GL
        // should be available on on platforms, while D3D9 would be available
        // only on Windows -- the try/catch will intercept the exception in this
        // case where D3D9 is not available and continue gracefully.
        try {
                root->loadPlugin("RenderSystem_GL");
                root->loadPlugin("RenderSystem_Direct3D9");
        }
        catch (...) {}

        try {
                // We'll simulate the selection of a rendersystem on an arbirtary basis; normally
                // you would have your own code to present the user with options and select the
                // rendersystem on that basis. Since a GUI is beyond the scope of this example, we'll
                // just assume the user selected OpenGL.
                RenderSystemList *rList = root->getAvailableRenderers();
                RenderSystemList::iterator it = rList->begin();
                RenderSystem *rSys = 0;

                while (it != rList->end()) {
                       
                        rSys = *(it++);
                        if (rSys->getName().find("OpenGL")) {
                       
                                root->setRenderSystem(rSys);
                                break;
                        }
                }

                // check to see if a render system was selected; if we reached the end of the list
                // without selecting a render system then none was found.
                if (rSys == 0) {
                        delete root;
                        std::cerr << "No RenderSystem available, exiting..." << std::endl;
                        return -1;
                }

                // We can initialize Root here if we want. "false" tells Root NOT to create
                // a render window for us
                root->initialise(false);

                // set up the render window with all default params
                RenderWindow *window = rSys->createRenderWindow(
                        "Manual Ogre Window",        // window title
                        800,                                        // window width, in pixels
                        600,                                        // window height, in pixels
                        false,                                        // fullscreen or not
                        0);                                                // use defaults for all other values

                // from here you can set up your camera and viewports as normal
                // get a pointer to the default base scene manager -- sufficient for our purposes
                SceneManager *sceneMgr = root->createSceneManager(ST_GENERIC);

                // create a single camera, and a viewport that takes up the whole window (default behavior)
                Camera *camera = sceneMgr->createCamera("MainCam");
                Viewport *vp = window->addViewport(camera);
                vp->setDimensions(0.0f, 0.0f, 1.0f, 1.0f);
                camera->setAspectRatio((float)vp->getActualWidth() / (float) vp->getActualHeight());
                camera->setFarClipDistance(1000.0f);
                camera->setNearClipDistance(5.0f);

                // Run the manual render loop. Since we are not using a frame listener in this case, we
                // will count to 15 seconds and then instead of exiting, we'll change the render window settings
                // and re-initialize it.
                bool renderLoop = true;
                Timer *timer = PlatformManager::getSingleton().createTimer();
                timer->reset();
                float s = 0.0f;

                while (renderLoop && window->isActive()) {

                        renderLoop = root->renderOneFrame();

                        // accumulate total elapsed time
                        s += (float)timer->getMilliseconds() / 1000.0f;

                        // if greater than 15 seconds, break out of the loop
                        if (s >= 15.0f)
                                renderLoop = false;

                        // we must call the windowing system's message pump each frame to
                        // allow Ogre to process messages
                        //PlatformManager::getSingleton().messagePump();
                }
        }
        catch (Exception &e) {
                std::cerr << e.getFullDescription() << std::endl;
        }

        delete root;
        return 0;
}

22

主题

63

帖子

63

积分

注册会员

Rank: 2

积分
63
 楼主| 发表于 2009-3-22 15:29:00 | 显示全部楼层

Re:OGRE初级问题,请赐教。

http://bbs.gameres.com/showthread.asp?threadid=120683
别人说是版本更新的问题,该如何解决呢?

30

主题

227

帖子

232

积分

中级会员

Rank: 3Rank: 3

积分
232
发表于 2009-3-30 10:51:00 | 显示全部楼层

Re:OGRE初级问题,请赐教。

createRenderWindow应该由Root调
Timer直接new

22

主题

63

帖子

63

积分

注册会员

Rank: 2

积分
63
 楼主| 发表于 2009-4-5 21:59:00 | 显示全部楼层

Re:OGRE初级问题,请赐教。

虽然这个问题还没搞明白,但还是非常感激阁下的回复。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-20 17:26

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表