我的技术规范

C/C++, Algorithm
随笔 - 11, 文章 - 7, 评论 - 1, 引用 - 0
数据加载中……

CDC 转 OPENGL坐标系使用习惯


绘图时经常用到坐标范围设置,常常大家不理解坐标系统的建立。
诚然WINDOWS 的坐标系统比较容易把人搞晕,事实上我个人也容易写错。
现在发布一个可以方便转化成 OPENGL坐标系统 使用习惯的类,函数名也保持和 OPENGL相同。
如果你连OPENEL 坐标也不懂,那请查一下相关文档吧。

 1 
 2 class CViewportWapper 
 3 {
 4 public:
 5     CViewportWapper( HDC hdc ) 
 6         : hdc_( hdc )
 7     {
 8     }
 9 
10     void SetViewport( int left, int top, int width, int height)
11     {
12         view_left_ = left;
13         view_top_ = top;
14         view_width_ = width;
15         view_height_ = height;
16     }
17 
18     void SetOrtho( int left, int right, int bottom, int top)
19     {
20         ::SetMapMode( hdc_, MM_ANISOTROPIC );
21 
22         ::SetViewportOrgEx( hdc_, view_left_, view_top_, NULL );
23         ::SetViewportExtEx( hdc_, view_width_, view_height_, NULL);
24 
25         ::SetWindowOrgEx( hdc_, left, top, NULL );
26         ::SetWindowExtEx( hdc_, right - left, bottom - top, NULL );
27     }
28 
29 private:
30     HDC hdc_;
31     int view_left_, view_top_, view_width_, view_height_;
32 };


posted on 2013-07-05 22:48 panchao 阅读(1491) 评论(1)  编辑 收藏 引用

评论

# re: CDC 转 OPENGL坐标系使用习惯  回复  更多评论   

Thanks for article. I am glad to be here. I mean your site.
2013-07-10 22:52 | idealessay.co.uk

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理