osg Shader 着色器
2024-09-01 09:54:40
#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32 #include <osg/Group>
#include <osg/Camera>
#include <osgDB/ReadFile>
#include <osg/Node> #include <osg/Geometry>
#include <osg/Image>
#include <osg/ShapeDrawable>
#include <osg/Texture2D> #include <osg/MatrixTransform>
#include <osg/AnimationPath> #include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers> #include <osgGA/DriveManipulator>
#include <osgGA/GUIEventHandler>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIActionAdapter> #include <osgGA/AnimationPathManipulator>
#include <osgGA/KeySwitchMatrixManipulator> #include <osgUtil/LineSegmentIntersector> #include <iostream>
using namespace std; //顶点着色器
static const char* vertShader = {
"varying vec4 color;\n"
"void main(void)\n"
"{\n"
"color = gl_Vertex;\n"
"gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex;\n"
"}\n"
}; //片元着色器
static const char* fragShader = {
"varying vec4 color;\n"
"void main(void)\n"
"{\n"
" gl_FragColor = clamp(color,0.1,0.8);\n"
"}\n"
}; int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer1 = new osgViewer::Viewer;
osg::ref_ptr<osg::Group> group1 = new osg::Group;
osg::ref_ptr<osg::Program> program1 = new osg::Program;
//osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\四合院2019.osgb");
osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\obj\\person1.obj"); osg::ref_ptr<osg::StateSet> stateset1 = node1->getOrCreateStateSet(); program1->addShader(new osg::Shader(osg::Shader::VERTEX, vertShader));
program1->addShader(new osg::Shader(osg::Shader::FRAGMENT, fragShader));
stateset1->setAttributeAndModes(program1, osg::StateAttribute::ON); group1->addChild(node1.get());
viewer1->setSceneData(group1);
viewer1->setUpViewInWindow(, , , , ); return viewer1->run();
}
最新文章
- Spring in Action 学习笔记二-DI
- 【教程】CDQ套CDQ——四维偏序问题
- Scrum Meeting 12-20151218
- ASIHTTPRequest实现https双向认证请求
- USB枚举过程(2)
- SPI的工作模式口诀[转]
- 黑马程序员_JavaIO流(四)
- 解决方案:elipse一直loading descriptor for...
- JavaScript实现360度全景图片展示效果
- MySql 如何实现不同数据库同步【2个】
- JBDC工具类
- Java多线程(四)—— synchronized关键字续
- LeetCode--326--3的幂
- Windows 64位系统安装Apache2.4
- element-ui inputNumber、Card 、Breadcrumb组件源码分析整理笔记(三)
- windows10下使用source insight出现";source insight program editor已停止工作";的问题
- Codeforces777D Cloud of Hashtags 2017-05-04 18:06 67人阅读 评论(0) 收藏
- POJ 2242
- Oracle EBS 报错:此责任无可用函数。 更改责任或与您的系统管理员联系。
- [ActionScript 3.0] 通过as3操作web内容