查看: 3774|回复: 6

drawable派生类的错误!!急

[复制链接]

该用户从未签到

发表于 2008-3-20 11:50:19 | 显示全部楼层 |阅读模式
代码如下:
// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "iostream"
using namespace std;
#include <osg/Node>
#include <osg/Geometry>
#include <osg/Drawable>
#include <osg/Notify>
#include <osg/MatrixTransform>
#include <osg/Texture2D>
#include <osg/Billboard>
#include <osg/LineWidth>
#include <osgText/Text>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/BoundingBox>
#include <osg/Shape>
#include <osg/BufferObject>
#include <osg/PrimitiveSet>
#include <osg/RenderInfo>

class DrawLine :public osg:rawable
{
public:
DrawLine();
void drawImplementation(osg::RenderInfo& renderInfo) const
{};
Object* clone(const osg::CopyOp&) const
{};
Object* cloneType() const
{};
};
int main(int, char**)
{
    // construct the viewer
    osgViewer::Viewer viewer;
osg::Drawable *dr=new DrawLine();
    osg::Group* root = new osg::Group();
    // set the scene to render
    viewer.setSceneData(root);

    // run the viewers frame loop
    return viewer.run();
}
为什么总是有这样一个错误?
1>test.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall DrawLine::DrawLine(void)" ([email=??0DrawLine@@QAE@XZ]??0DrawLine@@QAE@XZ[/email]),该符号在函数 _main 中被引用

该用户从未签到

发表于 2008-3-20 12:02:04 | 显示全部楼层
osgd.lib osgDBd.lib osgGAd.lib osgViewerd.lib

该用户从未签到

 楼主| 发表于 2008-3-20 12:06:05 | 显示全部楼层
我在项目-〉属性-〉链接依赖库里加入了上述几个lib文件了,但是仍旧是那个错误

该用户从未签到

发表于 2008-3-20 12:19:17 | 显示全部楼层
不是那个问题,继承得不对~~~~~你看一下osgteapot的例子好了~~~~~~


class Teapot : public osg:rawable
{
    public:
        Teapot() {}

        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
        Teapot(const Teapot& teapot,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
            osg::Drawable(teapot,copyop) {}

        META_Object(myTeapotApp,Teapot)


        //

the draw immediate mode method is where the OSG wraps up the drawing of
        // of OpenGL primitives.
        virtual void drawImplementation(osg::RenderInfo&) const
        {
            // teapot(..) doens't use vertex arrays at all so we don't need to toggle their state
            // if we did we'd need to something like following call
            // state.disableAllVertexArrays(), see src/osg/Geometry.cpp for the low down.
        
            // just call the OpenGL code.
            teapot(14,GL_FILL);
        }
        
        
        // we need to set up the bounding box of the data too, so that the scene graph knows where this
        // objects is, for both positioning the camera at start up, and most importantly for culling.
        virtual osg::BoundingBox computeBound() const
        {
        }

    protected:
   
        virtual ~Teapot() {}
        
};

该用户从未签到

发表于 2008-3-20 13:17:33 | 显示全部楼层
DrawLine的构造函数定义了但没有实现,而且这个类并非虚基类,这个函数也并非虚函数,所以会报错。
这样写应该就行了:
DrawLine:: DrawLine() {}
  • TA的每日心情
    开心
    2019-11-11 10:36
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 2008-3-20 13:19:01 | 显示全部楼层
    哈哈

    该用户从未签到

     楼主| 发表于 2008-3-20 13:28:22 | 显示全部楼层
    高人就是高人,谢谢楼上各位了~!~~
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    OSG中国官方论坛-有您OSG在中国才更好

    网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

    联系我们

    • 工作时间:09:00--18:00
    • 反馈邮箱:1315785073@qq.com
    快速回复 返回顶部 返回列表