上一章节:
十、OSG学习笔记-多线程(OpenThreads)-CSDN博客https://blog.csdn.net/weixin_36323170/article/details/145813221?spm=1001.2014.3001.5501
本章节代码:
OsgStudy/SysInterFac · CuiQingCheng/OsgStudy - 码云 - 开源中国https://gitee.com/cuiqingcheng/osg-study/tree/master/OsgStudy/SysInterFac
一、操作系接口渲染流程
下面是一个osg,创建窗口是示例代码:
/**运用OSG 创建窗口
**/#include <windows.h>
#include <iostream>#include <osgViewer/Viewer>
#include <osgViewer/api/Win32/GraphicsWindowWin32>
#include <osg/GraphicsContext>int main()
{// osgViewer::Viewer, 必须定义,前期准备均在其构造中完成osgViewer::Viewer vierer;// 窗口信息类osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;traits->x = 100;traits->y = 100;traits->width = 800;traits->height = 800;traits->windowDecoration = true;traits->doubleBuffer = true;traits->sharedContext = 0;osgViewer::GraphicsWindowWin32* gw = dynamic_cast<osgViewer::GraphicsWindowWin32*>(osg::GraphicsContext::createGraphicsContext(traits.get()));if (gw != nullptr){gw->realizeImplementation(); // 创建窗口int a;std::cin >> a;}else {std::cout << "gw is null" << std::endl;}return 0;
}
运行结果: