当前位置: 首页 > news >正文

典当网站山东外贸国际网站建设

典当网站,山东外贸国际网站建设,传播建设网站,怎样做科技小制作视频网站建立一个SDI 的MFC工程#xff0c;然后按freeglut 在mfc 下的编译_leon_zeng0的博客-CSDN博客​​​​​​ 一文设置好include lib 路径 在view 中建立这2个函数#xff1a; // Standard OpenGL Init StuffBOOL CmfcOpenglDemoView::SetupPixelFormat() {static PIXELFOR… 建立一个SDI 的MFC工程然后按freeglut 在mfc 下的编译_leon_zeng0的博客-CSDN博客​​​​​​ 一文设置好include lib 路径  在view 中建立这2个函数 // Standard OpenGL Init StuffBOOL CmfcOpenglDemoView::SetupPixelFormat() {static PIXELFORMATDESCRIPTOR pfd {sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd1, // version numberPFD_DRAW_TO_WINDOW | // support windowPFD_SUPPORT_OPENGL | // support OpenGLPFD_DOUBLEBUFFER, // double bufferedPFD_TYPE_RGBA, // RGBA type24, // 24-bit color depth0, 0, 0, 0, 0, 0, // color bits ignored0, // no alpha buffer0, // shift bit ignored0, // no accumulation buffer0, 0, 0, 0, // accumulation bits ignored16, // 16-bit z-buffer0, // no stencil buffer0, // no auxiliary bufferPFD_MAIN_PLANE, // main layer0, // reserved0, 0, 0 // layer masks ignored};int m_nPixelFormat ::ChoosePixelFormat(m_pDC-GetSafeHdc(), pfd);if (m_nPixelFormat 0)return FALSE;return ::SetPixelFormat(m_pDC-GetSafeHdc(), m_nPixelFormat, pfd); }BOOL CmfcOpenglDemoView::InitOpenGL() {TRACE(LInitOpenGL()\n);//Get a DC for the Client Aream_pDC new CClientDC(this);//Failure to Get DCif (m_pDC NULL)return FALSE;if (!SetupPixelFormat())return FALSE;//Create Rendering Contextm_hRC ::wglCreateContext(m_pDC-GetSafeHdc());//Failure to Create Rendering Contextif (m_hRC 0)return FALSE;//Make the RC Currentif (::wglMakeCurrent(m_pDC-GetSafeHdc(), m_hRC) FALSE)return FALSE;// Usual OpenGL stuffglClearColor(0.0f, 0.0f, 0.3f, 0.0f);glClearDepth(1.0f);glEnable(GL_DEPTH_TEST);//glDisable( GL_DEPTH_TEST );//glEnable( GL_TEXTURE_2D );glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);// glDepthMask(GL_FALSE); glLineWidth(1.0f);glPointSize(1.0f);// for testm_RenderScene render;return TRUE; }void CmfcOpenglDemoView::RenderScene() {if (m_RenderScene ! NULL)m_RenderScene((CmfcOpenglDemoDoc*)(GetDocument()));elseglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } 利用class wizard 建立几个message: OnCreate(LPCREATESTRUCT lpCreateStruct) OnDestroy() OnSize(UINT nType, int cx, int cy) OnEraseBkgnd(CDC* pDC) int CmfcOpenglDemoView::OnCreate(LPCREATESTRUCT lpCreateStruct) {if (CView::OnCreate(lpCreateStruct) -1)return -1;// TODO: Add your specialized creation code hereif (!InitOpenGL()){MessageBox(LError setting up OpenGL!, LInit Error!,MB_OK | MB_ICONERROR);return -1;}COLORREF color ::GetSysColor(COLOR_3DFACE);glClearColor(0.0, 0, 0.25, 1.0);glPolygonMode(GL_FRONT, GL_FILL);glPolygonMode(GL_BACK, GL_FILL);glEnable(GL_DEPTH_TEST);// AntialiasingglEnable(GL_LINE_SMOOTH);glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);glLineWidth(1.0);return 0; }void CmfcOpenglDemoView::OnDestroy() {CView::OnDestroy();// TODO: Add your message handler code herewglMakeCurrent(0, 0);wglDeleteContext(m_hRC);if (m_pDC){delete m_pDC;}m_pDC NULL; }void CmfcOpenglDemoView::OnSize(UINT nType, int cx, int cy) {CView::OnSize(nType, cx, cy);// TODO: Add your message handler code hereResize(cx,cy);RenderScene();// OnPaint(); }BOOL CmfcOpenglDemoView::OnEraseBkgnd(CDC* pDC) {// TODO: Add your message handler code here and/or call defaultTRACE(COpem:OnEraseBkgnd--\n);return CView::OnEraseBkgnd(pDC); }void CmfcOpenglDemoView::Resize(int cx,int cy) {// TODO: Add your implementation code here.GLsizei width, height;GLdouble aspect;width cx;height cy;if (cy 0)aspect (GLdouble)width;elseaspect (GLdouble)width / (GLdouble)height;glViewport(0, 0, width, height);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluOrtho2D(-1.0f,1.0,-1.0f,1.0f);//glOrtho(-4.0 * aspect - pDoc-m_transX, 4.0 * aspect - pDoc-m_transX, -4 - pDoc-m_transY, 4 - pDoc-m_transY, -10, 10);//aspectcx/cyglMatrixMode(GL_MODELVIEW);//glMatrixMode( GL_PROJECTION );} Resize 可以参考下面代码设置立体图上面代码只是正面的平面图。 width m_sizeCx;height m_sizeCy;if(m_sizeCy0)aspect (GLdouble)width;elseaspect (GLdouble)width/(GLdouble)height;glViewport(0,0,width,height);glMatrixMode(GL_PROJECTION);glLoadIdentity();if(pDoc-m_ViewSelect0)gluPerspective(45,aspect,1,100.0);else//gluOrtho2D(0.0f,aspect,0.0f,1.0f);glOrtho(-4.0*aspect-pDoc-m_transX, 4.0*aspect-pDoc-m_transX, -4-pDoc-m_transY,4-pDoc-m_transY, -10, 10);//aspectcx/cyglMatrixMode(GL_MODELVIEW); glOtho2D 参看 https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml C Specification void glOrtho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearVal,GLdouble farVal); Parameters left, right Specify the coordinates for the left and right vertical clipping planes. bottom, top Specify the coordinates for the bottom and top horizontal clipping planes. nearVal, farVal Specify the distances to the nearer and farther depth clipping planes. These values are negative if the plane is to be behind the viewer. Description glOrtho describes a transformation that produces a parallel projection. The current matrix (see glMatrixMode) is multiplied by this matrix and the result replaces the current matrix, as if glMultMatrix were called with the following matrix as its argument: 2right-left0002top-bottom000-2farVal-nearVal0001 where -rightleftright-left -topbottomtop-bottom -farValnearValfarVal-nearVal Typically, the matrix mode is GL_PROJECTION, and leftbottom-nearVal and righttop-nearVal specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively, assuming that the eye is located at (0, 0, 0). -farVal specifies the location of the far clipping plane. Both nearVal and farVal can be either positive or negative. Use glPushMatrix and glPopMatrix to save and restore the current matrix stack. Errors GL_INVALID_VALUE is generated if left  right, or bottom  top, or near  far. GL_INVALID_OPERATION is generated if glOrtho is executed between the execution of glBegin and the corresponding execution of glEnd. 在.h 文件中加这几个函数  void SetRenderFunc(void (*func) (CmfcOpenglDemoDoc*)) { m_RenderScene func; }void RenderScene();// Each viewport uses its own context// so we need to make sure the correct// context is set whenever we make an// OpenGL command.void SetContext() { wglMakeCurrent(m_pDC-GetSafeHdc(), m_hRC); }void SwapGLBuffers() { SwapBuffers(m_pDC-GetSafeHdc()); } 添加一个画图函数不是类里的独立的 void render(CmfcOpenglDemoDoc* pdoc) {glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glBegin(GL_TRIANGLE_STRIP);glColor3f(0.0f, 0.5f, 0.0f);glVertex2f(0.0f, -0.0f);glVertex2f(0.0f, 0.3f);glVertex2f(0.4f, 0.0f);glEnd();} 在init里有这一句 m_RenderScene render; 在.h 文件中有 // Attributes public:CmfcOpenglDemoDoc* GetDocument() const;//------------------void (*m_RenderScene) (CmfcOpenglDemoDoc* doc); // void function pointer to the rendering// function. Used to change to easily// change what a viewport displays. protected:HGLRC m_hRC; //Rendering ContextCDC* m_pDC; //Device Context// Operations public:// OpenGL init stuffBOOL SetupPixelFormat();BOOL InitOpenGL(); 这样就构造了一个基本的mfc 下的opengl 工程
http://www.dnsts.com.cn/news/222249.html

相关文章:

  • 中国网站制作 第一个作品集的个人网站怎么做
  • 网站转应用酒店推广平台有哪些
  • 网站代备案公司名称网站输入字符 显示出来怎么做
  • 网站服务器有哪些类型有哪些类型有哪些类型有哪些google网页搜索
  • 网站开发说明养生网站建设免费
  • 做搜狗pc网站软件国内seo服务商
  • 新的seo网站优化排名 网站聊城做网站的公司渠道
  • 电商网站英文品牌网站大全
  • 苗木网站模板简单的logo设计
  • 做网站月薪资多少钱WordPress二维码动态图片
  • 做网站需要什么权限代理网页浏览器
  • 自己做网站挂广告建设企业和建筑企业
  • 企业为什么做网站素材申请注册邮箱163免费注册
  • 慈溪哪里有做网站wordpress能开发商城网站吗
  • 建设银行怎么招聘网站网站建设是怎么收费的
  • 做网站开发背景中移建设 公司 网站
  • 临沧市建设局网站职业生涯规划大赛官网
  • 福建移动网站设计实木餐桌椅移动网站建设
  • wap站点深圳创纪录暴雨19小时
  • 海南中小企业网站建设做太空泥的几分钟网站
  • 西安网站建设设计iis做的网站如何添加播放器
  • 网站设计制作的连接方式app制作开发小程序制作开发
  • 惠州专业网站建设公司哪里有抚州建设银行网站
  • 合肥网站建设q479185700強网站建设冒用身份信息
  • wordpress创业做seo怎么设计网站
  • asp网站伪静态教程施工企业费用预算的编制的内容包括
  • 门户网站建设模式包括网站群和湖南建设厅网站勘查设计
  • 北辰网站建设公司太原网站制作哈尔滨seo关键字优化
  • 网站模板库官网网站策划内容有哪些
  • 上海opencart网站建设做外贸的如何上国外网站