更改GLUT调用以与MFC/C ++一起使用

编程入门 行业动态 更新时间:2024-10-24 20:17:11
本文介绍了更改GLUT调用以与MFC/C ++一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用GLUT进行OpenGL渲染的程序.现在,我需要将它放在MFC项目中,以便它可以与其他程序组件一起使用.

I have a program that uses GLUT for its OpenGL rendering. Now I need it to be inside of a MFC project so that it can work with another program component.

我已遵循本教程: www.codeguru/cpp/gm/opengl/openfaq/article.php/c10975__1/Setting-Up-OpenGL-in-an-MFC-Control. htm

我正在调用计时器触发时作为GLUT显示回调的函数,但这不起作用,因为呈现取决于GLUT空闲回调中发生的事情.我不明白在MFC程序中应该在哪里调用GLUT空闲回调.我应该为此做一个单独的事件处理程序吗?如果是,哪个事件?还是我做其他完全错误的事情?我对OpenGL相当熟悉,但这是我第一次使用MFC,因此我可能对此很不理解.

I am calling the function that was the GLUT display callback when the timer fires, but that's not working because the rendering depends on something that happens in the GLUT idle callback. I don't understand where I should call the GLUT idle callback in my MFC program. Is there a separate event handler I should make for it, and if so, which event? Or am I doing something else completely wrong? I'm fairly familiar with OpenGL but this is my first experience with MFC so I am probably erring on that side.

非常感谢您的宝贵时间;对此,我真的非常感激!

Thanks so much for your time; I really appreciate it!

推荐答案

我刚刚浏览了链接到的教程;在第二页上,可以找到以下几行内容(我对代码进行了一些整理):

I just browsed the tutorial you've linked to; on page two, something along the following lines can be found (I cleaned up the code a little bit):

void COpenGLControl::OnTimer(UINT nIDEvent) { if(nIDEvent==1) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); oglDrawScene(); // try to insert your idle function code here SwapBuffers(hdc); } CWnd::OnTimer(nIDEvent); }

因此,基本上,这是本教程建议的glutIdleFunc的替代品.我只是尝试在调用SwapBuffers之前插入在您的空闲函数中调用的代码.

So, basically this is the replacement for glutIdleFunc suggested by the tutorial. I'd simply try to insert the code called in your idle function before the call to SwapBuffers.

我希望能有所帮助.

更多推荐

更改GLUT调用以与MFC/C ++一起使用

本文发布于:2023-11-27 06:38:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636990.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GLUT   MFC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!