QTOSG框架快速解读

首先,我们简单看下OSG的实现框架

OSG是对OPENGL的高层封装,也就是它的实现是基于 Render Context,在windows平台上,它是关联到 Windows Device Context,也就是Windows DC,这样Opengl的绘制才能在Windows上正常显示。

其次,QT的实现框架;

QT的绘制通道是二维的,它是对Windows GDI的封装。后面出来的QOpenglWidet走的Opengl这个通道,也就是Render Context,所以,在QOpenglWidget中,我们可以直接使用Opengl的API.

最后,QTOSG的实现框架;

有了上面的知识,我们可以很轻松的知道,QTOSG这个库,其实就是基于Opengl的RenderContext绘制的。那么,根据Opengl的特性,Render Context是具有线程特性的,所以不能跨线程。

想要理解源码,上面是绕不开的逻辑。

应用开发:

我们开发OSG应用,常见的就是下面几个类了:

Viewer: holds a single view on to a single scene。

这个类是用户直接面对的类,继承了图形ViewerBase和View,包括上下文、事件队列、键盘、鼠标操作响应机制和数据。

ViewerBase: is the view base class that is inherited by both Viewer and CompositeViewer.

这个类最重要的是聚合了图形上下文。


View:holds a single view on a scene, this view may be composed of one or more slave cameras,maintains a master camera view and a list of slave cameras that are relative to this master camera.

这个类最重要的聚合了 Camer操作、事件队列、事件操作、场景。

从上面来看,一套UI所需要的框架,基本都出现了,显示、操作、响应、数据。这个和大家熟悉的QT/MFC从用户需求上是一致的。

OSG中大部分扩展功能,都是基于Visitor模式进行的。一个复杂的系统设计的好坏,有一个重要的评价标准就是它的扩展性。访问者模式带来的好处是,它可以横向扩展各种图形处理特性。缺点是,每个新增功能特性都是需要这么走一遭,会产生冗余。

GUIActionAdapter: Abstract base class defining the interface by which GUIEventHandlers may request actions of the GUI system in use. These requests for actions should then be honored
by the GUI toolkit of the user's application.

GraphicsContext: Base class for providing Windowing API agnostic access to creating and managing graphics context

EventQueue:implementation for collecting and adapting windowing events

GUIEventHandler :provides a basic interface for any class which wants to handle
a GUI Events.

CameraManipulator :is an abstract base class defining the interface, and a certain
amount of default functionality, for classes which wish to control OSG cameras
in response to GUI events.

GUIEventAdapter: Event class for storing Keyboard, mouse and window events.

Camera contains a Lens class and has a RenderSurface.  Methods
are provided to give the programmer control over the OpenGL PROJECTION
matrix throught the Lens and over the initial MODELVIEW matrix through
the camera's position and attitude.

StateSet:Stores a set of modes and attributes which represent a set of OpenGL state.

Drawable:Pure virtual base class for drawable geometry

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值