查看: 2421|回复: 10

OSG与MYGUI结合的问题

[复制链接]

该用户从未签到

发表于 2013-12-1 13:33:16 | 显示全部楼层 |阅读模式
按照锐哥在ANN工程中的例子,自己也模仿者把MYGUI和OSG结合起来,MYGUI也编译过了,相应的环境也配置好了。什么链接库和头文件的也配置过了。但是编译后依然提示一系列的连接错误
很多人都会认为是我没有加入lib库,但是我确实加入了。
  1. #ifdef _DEBUG
  2. #pragma comment(lib,"osgd.lib")
  3. #pragma comment(lib,"osgDBd.lib")
  4. #pragma comment(lib,"osgViewerd.lib")
  5. #pragma comment(lib,"osgGAd.lib")
  6. #pragma comment(lib,"OpenThreadsd.lib")
  7. #pragma comment(lib,"MyGUIEngine_d.lib")
  8. #pragma comment(lib,"MyGUI.OpenGLPlatform_d.lib")
  9. #pragma comment(lib,"Plugin_StrangeButton_d.lib")
  10. #pragma comment(lib,"Common_d.lib")
  11. #else
  12. #pragma comment(lib,"osg.lib")
  13. #pragma comment(lib,"osgDB.lib")
  14. #pragma comment(lib,"osgGA.lib")
  15. #pragma comment(lib,"osgViewer.lib")
  16. #pragma comment(lib,"OpenThreads.lib")
  17. #pragma comment(lib,"MyGUI.OpenGLPlatform.lib")
  18. #pragma comment(lib,"MyGUIEngine.lib")
  19. #pragma comment(lib,"Plugin_StrangeButton.lib")
  20. #pragma comment(lib,"Common.lib")
  21. #endif
复制代码

  1. MyGUI.OpenGLPlatform_d.lib(glew.obj) : error LNK2019: 无法解析的外部符号 __imp__wglGetProcAddress@4,该符号在函数 _wglewContextInit 中被引用
  2. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glTexImage2D@36,该符号在函数 "public: void __thiscall MyGUI::OpenGLTexture::createManual(int,int,struct MyGUI::TextureUsage,struct MyGUI::PixelFormat,void *)" (?createManual@OpenGLTexture@MyGUI@@QAEXHHUTextureUsage@2@UPixelFormat@2@PAX@Z) 中被引用
  3. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glTexParameteri@12,该符号在函数 "public: void __thiscall MyGUI::OpenGLTexture::createManual(int,int,struct MyGUI::TextureUsage,struct MyGUI::PixelFormat,void *)" (?createManual@OpenGLTexture@MyGUI@@QAEXHHUTextureUsage@2@UPixelFormat@2@PAX@Z) 中被引用
  4. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glGenTextures@8,该符号在函数 "public: void __thiscall MyGUI::OpenGLTexture::createManual(int,int,struct MyGUI::TextureUsage,struct MyGUI::PixelFormat,void *)" (?createManual@OpenGLTexture@MyGUI@@QAEXHHUTextureUsage@2@UPixelFormat@2@PAX@Z) 中被引用
  5. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glPixelStorei@8,该符号在函数 "public: void __thiscall MyGUI::OpenGLTexture::createManual(int,int,struct MyGUI::TextureUsage,struct MyGUI::PixelFormat,void *)" (?createManual@OpenGLTexture@MyGUI@@QAEXHHUTextureUsage@2@UPixelFormat@2@PAX@Z) 中被引用
  6. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glGetIntegerv@8,该符号在函数 "public: void __thiscall MyGUI::OpenGLTexture::createManual(int,int,struct MyGUI::TextureUsage,struct MyGUI::PixelFormat,void *)" (?createManual@OpenGLTexture@MyGUI@@QAEXHHUTextureUsage@2@UPixelFormat@2@PAX@Z) 中被引用
  7. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glDeleteTextures@8,该符号在函数 "public: virtual void __thiscall MyGUI::OpenGLTexture::destroy(void)" (?destroy@OpenGLTexture@MyGUI@@UAEXXZ) 中被引用
  8. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glGetTexImage@20,该符号在函数 "public: virtual void * __thiscall MyGUI::OpenGLTexture::lock(struct MyGUI::TextureUsage)" (?lock@OpenGLTexture@MyGUI@@UAEPAXUTextureUsage@2@@Z) 中被引用
  9. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glTexSubImage2D@36,该符号在函数 "public: virtual void __thiscall MyGUI::OpenGLTexture::unlock(void)" (?unlock@OpenGLTexture@MyGUI@@UAEXXZ) 中被引用
  10. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLRTTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glGetTexLevelParameteriv@16,该符号在函数 "public: __thiscall MyGUI::OpenGLRTTexture::OpenGLRTTexture(unsigned int)" (??0OpenGLRTTexture@MyGUI@@QAE@I@Z) 中被引用
  11. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLRTTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glClear@4,该符号在函数 "public: virtual void __thiscall MyGUI::OpenGLRTTexture::begin(void)" (?begin@OpenGLRTTexture@MyGUI@@UAEXXZ) 中被引用
  12. 1>MyGUI.OpenGLPlatform_d.lib(MyGUI_OpenGLRTTexture.obj) : error LNK2019: 无法解析的外部符号 __imp__glViewport@16,该符号在函数 "public: virtual void __thiscall MyGUI::OpenGLRTTexture::begin(void)" (?begin@OpenGLRTTexture@MyGUI@@UAEXXZ) 中被引用
复制代码

该用户从未签到

发表于 2013-12-2 11:18:05 | 显示全部楼层
几乎一眼就可以看出,您没有添加opengl32.lib这个依赖库

该用户从未签到

 楼主| 发表于 2013-12-2 15:04:21 | 显示全部楼层
array 发表于 2013-12-2 11:18
几乎一眼就可以看出,您没有添加opengl32.lib这个依赖库

锐哥好眼力,果然是缺少这个
#pragma comment(lib,"opengl32.lib")

该用户从未签到

 楼主| 发表于 2013-12-2 15:08:57 | 显示全部楼层
array 发表于 2013-12-2 11:18
几乎一眼就可以看出,您没有添加opengl32.lib这个依赖库

锐哥,我在看你主持的ANN工程中的MYGUI与OSG结合的demo,结合成功了,但是却发现,加载图片的那个函数中
  1. void* MYGUIManager::loadImage( int& width, int& height, MyGUI::PixelFormat& format, const std::string& filename )
  2. {
  3.         [color=Red]std::string fullname = MyGUI::OpenGLDataManager::getInstance().getDataPath( filename );[/color]
  4.         osg::ref_ptr<osg::Image> image = osgDB::readImageFile( fullname );
  5.         void* result = NULL;
  6.         if ( image.valid() )
  7.         {
  8.                 width = image->s();
  9.                 height = image->t();
  10.                 if ( image->getDataType()!=GL_UNSIGNED_BYTE || image->getPacking()!=1 )
  11.                 {
  12.                         format = MyGUI::PixelFormat::Unknow;
  13.                         return result;
  14.                 }

  15.                 unsigned int num = 0;
  16.                 switch ( image->getPixelFormat() )
  17.                 {
  18.                 case GL_LUMINANCE: case GL_ALPHA: format = MyGUI::PixelFormat::L8; num = 1; break;
  19.                 case GL_LUMINANCE_ALPHA: format = MyGUI::PixelFormat::L8A8; num = 2; break;
  20.                 case GL_RGB: format = MyGUI::PixelFormat::R8G8B8; num = 3; break;
  21.                 case GL_RGBA: format = MyGUI::PixelFormat::R8G8B8A8; num = 4; break;
  22.                 default: format = MyGUI::PixelFormat::Unknow; return result;
  23.                 }

  24.                 unsigned int size = width * height * num;
  25.                 unsigned char* dest = new unsigned char[size];
  26.                 image->flipVertical();
  27.                 if ( image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA )
  28.                 {
  29.                         // FIXME: I don't an additional conversion here but...
  30.                         // MyGUI will automatically consider it as BGR so I should do such stupid thing
  31.                         unsigned int step = (image->getPixelFormat()==GL_RGB ? 3 : 4);
  32.                         unsigned char* src = image->data();
  33.                         for ( unsigned int i=0; i<size; i+=step )
  34.                         {
  35.                                 dest[i+0] = src[i+2];
  36.                                 dest[i+1] = src[i+1];
  37.                                 dest[i+2] = src[i+0];
  38.                                 if ( step==4 ) dest[i+3] = src[i+3];
  39.                         }
  40.                 }
  41.                 else
  42.                         memcpy( dest, image->data(), size );
  43.                 result = dest;
  44.         }
  45.         return result;
  46. }
复制代码


中红色那条语句返回值总是为“”,不知道是怎么回事儿?
最终的运行结果是这样的。

QQ图片20131202150732.jpg
麻烦锐哥再指点下。

该用户从未签到

发表于 2013-12-3 17:03:19 | 显示全部楼层
array 发表于 2013-12-2 11:18
几乎一眼就可以看出,您没有添加opengl32.lib这个依赖库

该用户从未签到

发表于 2013-12-5 09:48:38 | 显示全部楼层
1、唯一的可能就是资源路径没有指定,您完全可以自己设置一下传递给mygui或者直接传入函数参数
2、我不知道什么叫做ANN工程,我的工程叫做osgRecipes。我能想到您这么描述它的名字的唯一理由是我曾经发的公告贴写了[ANN]的抬头,不过我认为英语有一点基础的人都应该能理解这是announcement的意思

该用户从未签到

 楼主| 发表于 2013-12-5 20:10:56 | 显示全部楼层
array 发表于 2013-12-5 09:48
1、唯一的可能就是资源路径没有指定,您完全可以自己设置一下传递给mygui或者直接传入函数参数
2、我不知 ...

不好意思让锐哥见笑了

该用户从未签到

发表于 2013-12-16 12:34:18 | 显示全部楼层
楼主,想请教一下在这篇帖子上附的图片的问题怎么解决的

该用户从未签到

 楼主| 发表于 2013-12-21 10:58:25 | 显示全部楼层
748616434 发表于 2013-12-16 12:34
楼主,想请教一下在这篇帖子上附的图片的问题怎么解决的

是MYGUi编译时没编译好,重新编译一下MYGUI就好了

该用户从未签到

发表于 2013-12-23 16:04:01 | 显示全部楼层
你好 能把源码发我一份么?我现在正在做mygui和osg结合。没有思路。谢谢。邮箱gyhgyh2007@126.com

该用户从未签到

 楼主| 发表于 2014-10-8 16:02:51 | 显示全部楼层
huihui123 发表于 2013-12-23 16:04
你好 能把源码发我一份么?我现在正在做mygui和osg结合。没有思路。谢谢。邮箱

这个事直接参考的锐神的osg与mygui结合的demo,你可以直接参考
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

联系我们

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