osgDB.ObjectGLenum
是OpenSceneGraph的一个枚举类型,表示不同的对象类型。
下面是osgDB.ObjectGLenum
枚举类型中的常量及其含义。
OBJECT_INVALID
:无效对象。OBJECT_UNKNOWN
:未知对象。OBJECT_FILE
:文件对象。OBJECT_IMAGE
:图像对象。OBJECT_SHADER
:着色器对象。OBJECT_PROGRAM
:程序对象。OBJECT_VERTEX_BUFFER
:顶点缓冲对象。OBJECT_INDEX_BUFFER
:索引缓冲对象。OBJECT_TEXTURE
:纹理对象。OBJECT_VIDEO_BUFFER
:视频缓冲对象。以下代码演示了如何使用osgDB.ObjectGLenum
枚举类型。
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <iostream>
int main()
{
osg::ref_ptr<osgDB::ReaderWriter::Options> options = new osgDB::ReaderWriter::Options;
osg::ref_ptr<osgDB::ReaderWriter> reader = osgDB::Registry::instance()->getReaderWriterForExtension("obj");
osg::ref_ptr<osgDB::ReaderWriter::ReadResult> result = reader->readNode("model.obj", options.get());
if (result.valid())
{
osg::ref_ptr<osgDB::ObjectWrapper> objectWrapper = result->getObjectWrapper();
if (!objectWrapper.valid())
{
std::cout << "No object wrapper found" << std::endl;
}
else
{
osgDB::ObjectWrapper::Type type = objectWrapper->getType();
switch (type)
{
case osgDB::ObjectWrapper::Type::File:
std::cout << "Object type: FILE" << std::endl;
break;
case osgDB::ObjectWrapper::Type::Image:
std::cout << "Object type: IMAGE" << std::endl;
break;
case osgDB::ObjectWrapper::Type::Shader:
std::cout << "Object type: SHADER" << std::endl;
break;
case osgDB::ObjectWrapper::Type::Program:
std::cout << "Object type: PROGRAM" << std::endl;
break;
case osgDB::ObjectWrapper::Type::VertexBuffer:
std::cout << "Object type: VERTEX BUFFER" << std::endl;
break;
case osgDB::ObjectWrapper::Type::IndexBuffer:
std::cout << "Object type: INDEX BUFFER" << std::endl;
break;
case osgDB::ObjectWrapper::Type::Texture:
std::cout << "Object type: TEXTURE" << std::endl;
break;
case osgDB::ObjectWrapper::Type::VideoBuffer:
std::cout << "Object type: VIDEO BUFFER" << std::endl;
break;
case osgDB::ObjectWrapper::Type::Unknown:
default:
std::cout << "Object type: UNKNOWN" << std::endl;
break;
}
}
}
else
{
std::cout << "Reading file failed" << std::endl;
}
return 0;
}