资源简介
VS13 MFC工程代码, 示例如何使用glfw通过opengl显示xyz文件以及stl文件. 代码中使用到的glfw是进过稍微修改过后的, 可以直接支持将创建的窗口集成到MFC控件中. 代码结构清晰, 使用示例简单. 详情可以查看博客: http://blog.csdn.net/sunbibei/article/details/51783783
代码片段和文件信息
#include “stdafx.h“
#include “CloudWindow.h“
std::atomic g_cloud_window_scale_ = 1.0;
static void glfwScrollfun(GLFWwindow* window double xoffset double yoffset) {
std::cout << “GLFWscrollfun: “ << xoffset << “ “ << yoffset << std::endl;
g_cloud_window_scale_ = g_cloud_window_scale_ + 0.1*yoffset;
if (g_cloud_window_scale_ < 0) g_cloud_window_scale_ = 0;
}
CloudWindow::CloudWindow() {
this->is_open_ = false;
this->close_window_.clear();
this->lock_data_access_.clear();
this->glfw_points_.clear();
}
CloudWindow::~CloudWindow(){
this->Close();
}
void CloudWindow::Close(){
if (this->IsOpen()){
// Tell window to close
while (this->close_window_.test_and_set()){}
// Wait for window loop to finish processing
while (this->lock_data_access_.test_and_set()){}
// Clear all window data
this->is_open_ = false;
this->glfw_points_.clear();
this->lock_data_access_.clear();
this->close_window_.clear();
}
}
bool CloudWindow::Open(const std::string &title const unsigned int &width const unsigned int &height int hparent) { // Sized empty window
if (!this->IsOpen()){
this->is_open_ = true;
// If width or height equal 0 open fullscreen
if ((width == 0) || (height == 0)){
std::thread window_loop(&CloudWindow::Loop this title true 0 0 hparent);
window_loop.detach();
}
else{
// Open the window to a specific size
std::thread window_loop(&CloudWindow::Loop this title false width height hparent);
window_loop.detach();
}
// Wait 50ms and check that window opened
std::this_thread::sleep_for(std::chrono::milliseconds(50));
if (!this->is_open_) return false;
}
return true;
}
bool CloudWindow::Update(const std::vector& _cloud) {
// Check that window is open and the point cloud has points
if ((!this->IsOpen()) || (_cloud.size() == 0))
return false;
// the number of cloud is same don‘t need to update.
if (glfw_points_.size() == _cloud.size()) {
return true;
}
// Set the flag to copy the data
while (this->lock_data_access_.test_and_set()) {}
// Clear the old data
this->glfw_points_.clear();
// Grab the first point to start the min max calculations
this->limited[_X][_MIN] = _cloud[0].xx;
this->limited[_X][_MAX] = _cloud[0].xx;
this->limited[_Y][_MIN] = _cloud[0].yy;
this->limited[_Y][_MAX] = _cloud[0].yy;
this->limited[_Z][_MIN] = _cloud[0].zz;
this->limited[_Z][_MAX] = _cloud[0].zz;
this->limited[_X][_AVE] = 0;
this->limited[_Y][_AVE] = 0;
this->limited[_Z][_AVE] = 0;
// Find the minimum maximum and average
for (auto pt : _cloud) {
if (this->limited[_X][_MIN] > pt.xx) this->limi
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-08-17 00:34 MFCApplication1\
目录 0 2016-08-16 23:51 MFCApplication1\glfw\
文件 100864 2016-08-05 17:18 MFCApplication1\glfw\glfw3.dll
文件 17966 2016-08-05 17:18 MFCApplication1\glfw\glfw3dll.lib
目录 0 2016-08-16 23:51 MFCApplication1\glfw\include\
目录 0 2016-08-16 23:51 MFCApplication1\glfw\include\GLFW\
文件 82334 2016-06-29 15:52 MFCApplication1\glfw\include\GLFW\glfw3.h
文件 5684 2015-01-28 00:33 MFCApplication1\glfw\include\GLFW\glfw3native.h
目录 0 2016-08-16 23:51 MFCApplication1\glfw\lib-vc2013\
文件 100864 2016-08-05 17:18 MFCApplication1\glfw\lib-vc2013\glfw3.dll
文件 238850 2016-06-02 21:54 MFCApplication1\glfw\lib-vc2013\glfw3.lib
文件 17966 2016-08-05 17:18 MFCApplication1\glfw\lib-vc2013\glfw3dll.lib
文件 242802 2005-10-19 15:55 MFCApplication1\glfw\lib-vc2013\opengl.lib
文件 336274 2005-10-19 15:55 MFCApplication1\glfw\lib-vc2013\OPENGL32.LIB
目录 0 2016-08-17 00:34 MFCApplication1\MFCApplication1\
文件 991 2016-08-16 23:48 MFCApplication1\MFCApplication1.sln
文件 30208 2016-08-17 00:34 MFCApplication1\MFCApplication1.v12.suo
文件 13917 2016-08-17 00:24 MFCApplication1\MFCApplication1\CloudWindow.cpp
文件 1611 2016-08-16 23:56 MFCApplication1\MFCApplication1\CloudWindow.h
目录 0 2016-08-17 00:33 MFCApplication1\MFCApplication1\data\
文件 509183 2016-08-10 11:30 MFCApplication1\MFCApplication1\data\01.xyz
文件 601070 2016-08-10 11:38 MFCApplication1\MFCApplication1\data\02.xyz
文件 429750 2016-08-10 11:39 MFCApplication1\MFCApplication1\data\03.xyz
文件 757449 2016-08-10 11:39 MFCApplication1\MFCApplication1\data\04.xyz
文件 454791 2016-08-10 11:39 MFCApplication1\MFCApplication1\data\05.xyz
文件 947131 2016-08-10 11:40 MFCApplication1\MFCApplication1\data\06.xyz
文件 955730 2016-08-10 11:40 MFCApplication1\MFCApplication1\data\07.xyz
文件 589941 2016-08-10 11:40 MFCApplication1\MFCApplication1\data\08.xyz
文件 488953 2016-08-10 11:40 MFCApplication1\MFCApplication1\data\09.xyz
文件 436933 2016-08-10 11:41 MFCApplication1\MFCApplication1\data\10.xyz
文件 390835 2016-08-10 11:41 MFCApplication1\MFCApplication1\data\11.xyz
............此处省略40个文件信息
相关资源
- TcpView源代码MFC VS2005
- mfc编写的小区住户管理系统
- 原版的鸡啄米网站的MFC编程入门知识
- 连连看 MFC 连连看 mfc 连连看
- mfc树形控件201037
- MFC_波形显示器
- CMFCOutlookBar
- C++ STL参考手册
- MFC 五子棋 VS2013
- c++标准程序库《》侯杰
- MFC中点圆的生成算法
- 传智播客扫地僧C++STL.zip
- Microsoft Visual C++ 2005 Redistributable Pack
- MFC动态折线图
- MFC信息管理系统
- VS2008 opencv MFC 计算米粒的个数及最大
- mfc 画图直线、圆、椭圆
- mfc实现扫雷194704
- MFC基于逆波兰算法的四则运算计算器
- MFC物流订单管理系统
- 深入浅出MFC第二版光盘
- 基于MFC的 数字相册
- IP数据包捕获解析程序
- 纯mfc绘图制做三维仿真图形魔方
- MFC超市管理系统
- 语音识别的算法实现C++
- 基于MFC的流程图绘制工具
- MFC richedit可进行插入图片、表情,有
- VS2010MFC利用TeeChart绘制瀑布图三维图
- MFC实现FTP上传文件的客户端和服务器
评论
共有 条评论