Click here to Skip to main content
15,914,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
MIDL
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.
Posted
Updated 6-Oct-10 22:34pm
v2
Comments
Dalek Dave 7-Oct-10 4:34am    
Minor Edit for Readability.

Every time before you render something to the screen, you need to clear the screen first. Otherwise the existing contents in the screen remains.
 
Share this answer
 
Comments
thundersun 7-Oct-10 21:23pm    
You mean that "glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);" can not clear the screen. what function can clear the screen? can you tell me?
MIDL
"glClearColor(0.6f,0.6f,0.6f,0.0f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);"


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);?
 
Share this answer
 
v2
Comments
thundersun 8-Oct-10 7:10am    
Yes,I try "glClearColor(0.6f,0.6f,0.6f,0.0f);glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);" 2 lines,but it does not work. The objects which the first render function displays still appear.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900