🔒 Locked
Do not clear screen
Advertisement
Original Post
It done by drawing over every thing in the screen every time you draw a frame this is done in most games. like halflife for instance and you can even see that it is done if you use a "noclip" cheat and go outside of the acctaul level things start blinking and it will keep the same stuff on the screen and it will look very bad.
The important thing is making sure the entire screen is updated.
that is why glclear slows stuff down why do you need to draw over the whole screen twice when you cover the entire thing once with the things you draw.
The important thing is making sure the entire screen is updated.
that is why glclear slows stuff down why do you need to draw over the whole screen twice when you cover the entire thing once with the things you draw.
Well, Half-Life, Quake III and many other games use this method. Clearing the screen is basically like rendering to it, but only replacing what''s there already with the current clear colour. This can slow down your program quite a bit. However, what you''ll find with the above mentioned games is that they check to see if your level is completely solid (ie. has no gaps) when your level is compiled.
The other way you can do it is to completely encapsulate the level inside a skybox, and render the skybox every frame. This guarantees that every part of the screen, no matter which direct you''re looking in, will be filled. Therefore, no crappy overdraw...
Movie Quote of the Week:
"You''ve been eating retard sandwiches again."
- Birdman, Beautiful Girls.
Try http://uk.geocities.com/mentalmantle. Seriously. It''s brilliant.
And I just completely redesigned it so it looks even better.
DarkVertex Beta 0.8 available soon!
The other way you can do it is to completely encapsulate the level inside a skybox, and render the skybox every frame. This guarantees that every part of the screen, no matter which direct you''re looking in, will be filled. Therefore, no crappy overdraw...
Movie Quote of the Week:
"You''ve been eating retard sandwiches again."
- Birdman, Beautiful Girls.
Try http://uk.geocities.com/mentalmantle. Seriously. It''s brilliant.
And I just completely redesigned it so it looks even better.
DarkVertex Beta 0.8 available soon!
sometimes rendering a sky box (all 6 sides) may cause massive overdraw just as the clear screen would its better to only draw what is required if you plan on clearing, drawing your level then drawing a skybox then by all means don''t clear but if your goal is very good speed its good not too do a large surrounding skybox if its not needed.
In which case, why does MSDN say:
OpenGL Performance Tips
...
Use a single glClear call per frame, if possible. Do not use glClear to clear small subregions of the buffers; use it only to clear the buffer completely or nearly completely.
...
[edited by - -thork- on September 28, 2002 9:39:19 AM]
OpenGL Performance Tips
...
Use a single glClear call per frame, if possible. Do not use glClear to clear small subregions of the buffers; use it only to clear the buffer completely or nearly completely.
...
[edited by - -thork- on September 28, 2002 9:39:19 AM]
Do NOT clear the screen, only clear the z-buffer and render again. I know no professional AAA game that uses glClear or that doesn't have a function to disable clearing the screen. But there shouldn't be gaps in the level, like iNsAn1tY said, because else it will filicker and look crappy.
The glClear function can be quite slow depending on the graphics card and its memory speed.
EDIT:
Use
glClear(GL_DEPTH_BUFFER_BIT);
conQuest: Interplanetary Wars
http://www.terradesign.ws
[edited by - Daywalker313 on September 28, 2002 11:28:43 AM]
The glClear function can be quite slow depending on the graphics card and its memory speed.
EDIT:
Use
glClear(GL_DEPTH_BUFFER_BIT);
conQuest: Interplanetary Wars
http://www.terradesign.ws
[edited by - Daywalker313 on September 28, 2002 11:28:43 AM]
One common trick for Z-buffers used to be switching what sign you use for your depth buffer and changing from less than to greater than comparisons every frame so you could avoid clearing the buffer... I don''t know if this is applicable to OpenGL or not, however (I suspect it''s not because Nvidia and ATI have went to great lengths to make z-buffer clearing a fast operation).
I''m fairly new to OpenGL, so this will most likely sound idiotic - what is to be done when you need to draw free objects without a skybox or solid level around them? glClear(GL_DEPTH_BUFFER) should be recognized as a proper technique in these cases, but if you are drawing object surrounded by nothing, not clearing the color buffer will yield poor results on screen.
I saw someone mention rendering a quad (with a picture or solid color) over the entire screen with depth buffer disabled after clearing the depth buffer itself. Is this as wrong as it sounds to me?
I saw someone mention rendering a quad (with a picture or solid color) over the entire screen with depth buffer disabled after clearing the depth buffer itself. Is this as wrong as it sounds to me?
Xori: I saw someone mention rendering a quad (with a picture or solid color) over the entire screen with depth buffer disabled after clearing the depth buffer itself. Is this as wrong as it sounds to me?
If you''re going to have a constant image for your background which is very visible, that''s probably a good idea to do. In case you don''t understand how it works, the pseudocode would be something like this:
clear the depth buffer
disable depth buffer testing
render the background image
enable depth buffer testing
There''s no point in having the depth buffer enabled for an image which everything will draw over because it''ll just slow down the video card as it tests the depth and writes to the z-buffer. If you''re going to have a solid color, I think it''d be better to set the clear colour and then use a single glClear call to clear both the colour and depth buffers.
If you''re going to have a constant image for your background which is very visible, that''s probably a good idea to do. In case you don''t understand how it works, the pseudocode would be something like this:
clear the depth buffer
disable depth buffer testing
render the background image
enable depth buffer testing
There''s no point in having the depth buffer enabled for an image which everything will draw over because it''ll just slow down the video card as it tests the depth and writes to the z-buffer. If you''re going to have a solid color, I think it''d be better to set the clear colour and then use a single glClear call to clear both the colour and depth buffers.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement