opengl渲染有关更改视图的问题? [英] opengl render problem about changing view?

查看:114
本文介绍了opengl渲染有关更改视图的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我有两个不同的渲染函数.

我想使用不同的渲染功能来显示不同的视图.
问题是当我运行程序并更改view函数时,第二个render函数还会显示第一个render函数绘制的对象.

但是在第二个渲染函数中,我不调用第一个渲染函数.

如果然后我更改为第一个渲染函数,它还会显示第二个渲染函数绘制的对象.我不知道为什么

我认为可能不清楚帧缓冲区,我使用

In my code, I have two different render functions.

I want to use different render function to display different view.
The problem is when I run the program and change the view function, the second render function also display the object that the first render function draw.

But in the second render function I don''t call the first render function.

If I then change to the first render function, it also display the object that second render function draw. I don''t know why.

I think it may be not clear the frame buffer, I use

glEnable(GL_DEPTH_TEST);       
glClearColor(0.6f,0.6f,0.6f,0.0f);               
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);


要清除缓冲区,问题仍然存在.
我的英语不好,请原谅我.


to clear buffer, the problem still exist.
my English is not good, please forgive me.

推荐答案

每次在屏幕上呈现内容之前,您都需要先清除屏幕.否则,屏幕上的现有内容将保留.
Every time before you render something to the screen, you need to clear the screen first. Otherwise the existing contents in the screen remains.


"glClearColor(0.6f,0.6f,0.6f,0.0f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);"



这2行应该是您需要清除屏幕的内容.
我不知道您的代码是什么,所以我对此不多透露.
您确定要在第二个渲染功能之前运行以上两行吗?
而且,您是否尝试过glClearColor(0.6,0.6,0.6,1.0);?



These 2 lines should be what you need to clear the screen.
I don''t know what your codes are, so I can''t tell much about it.
Are you sure you are running the above 2 lines before the second render function?
And, did you try glClearColor(0.6, 0.6, 0.6, 1.0);?


这篇关于opengl渲染有关更改视图的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆