PDA

View Full Version : A way to delete the back OR front buffer?



zadeh79
08-23-2006, 04:11 PM
Does anyone know a way to clear a single buffer, back or front, without having to delete both?

RigidBody
08-23-2006, 04:22 PM
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT);

clears the back buffer,

glDrawBuffer(GL_FRONT);
glClear(GL_COLOR_BUFFER_BIT);

clears the front buffer.

but for which reason?

RigidBody
08-23-2006, 04:28 PM
oh, and since i just noticed that the above reply was my post #476, here's a little quiz, easily to solve:

who knows the computer game in which the number 476 had a special meaning?

zadeh79
08-23-2006, 04:32 PM
For the scene's background I used a texture that I loaded and rendered once (I don't want to load AND/OR redraw it more than once because it will slow the fps down a lot). In the front buffer Im trying to draw an animated charachter, because if i draw the charachter to the back buffer it leaves a trail upon calling glswapbuffers().

Korval
08-23-2006, 05:10 PM
I don't want to load AND/OR redraw it more than once because it will slow the fps down a lotTough.

Assuming that the back buffer is copied into the front buffer is a bad idea. OpenGL doesn't define exactly what happens when you swap buffers (note that GL doesn't even have a command for it. SwapBuffers isn't an OpenGL call).

The only way to do what you want is to create a renderbuffer that you draw your background to once, then use the new (and virtually unimplemented) EXT_framebuffer_blit extension to blit that data into the backbuffer before rendering your main stuff.

EXT_framebuffer_blit exists, but nobody implements it yet. So it's not a workable plan as of yet.

In general, on any hardware that you could even consider calling hardware (even Intel on-chip stuff), drawing a textured quad to the screen isn't going to be a big deal performance-wise.

zadeh79
08-23-2006, 08:18 PM
"In general, on any hardware that you could even consider calling hardware (even Intel on-chip stuff), drawing a textured quad to the screen isn't going to be a big deal performance-wise."

Even a 1MB bitmap?

For whatever reason it takes forever to load and draw. Yes, I do have an intel on-board video chip, and it probably isn't too powerful. I had to cut down video acceleration to stop strange screen behaviour. I decided to proceed with the game even with the charachter flickering due to front-buffer rendering. I will keep asking people in hopes of an arcane solution. If someone cares to look at the program, I will send it to them, along with the 1mb texture, and the small image loader.


www.geocities.com/zadeh1979/grass3 (http://www.geocities.com/zadeh1979/grass3)

plasmonster
08-23-2006, 09:12 PM
who knows the computer game in which the number 476 had a special meaning?OK, I give up. What game is it? I remember one but it's the wrong number :)

plasmonster
08-23-2006, 09:15 PM
Yes, I do have an intel on-board video chip, and it probably isn't too powerful.By the way, what flavor is that?

zadeh79
08-23-2006, 09:16 PM
It's..... SNAKE 476.....and it sure looks corny!

http://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2000/wicks/

zadeh79
08-23-2006, 09:22 PM
I honestly don't know if your last comment was a joke Minstrel.

Intel 82945g with updated drivers.
Im running a P4 3.0 with 1mb L2 cache, 512MB SDRAM on an INTEL 945GPM motherboard with VIV technology, SYSTEM BUS = 800MHZ.

plasmonster
08-23-2006, 09:31 PM
No, it wasn't a joke. I was just curious. And thanks for the answer. I never would have figured that one out :)

Yeah, that boards doesn't exactly blister, at least not when compared to some others, but it's not exactly a slouch either.

Korval
08-24-2006, 12:01 AM
For whatever reason it takes forever to load and draw.First, don't private message me with code that should be shown to the forum.

Second, and more importantly, you keep reloading the texture every frame. The whole point of texture objects is that you only load the data once. Then you bind (and unbind) the texture object as needed.

If you're loading 1MB of data off the disc every frame, of course it's going to run slow.

RigidBody
08-24-2006, 01:53 AM
Originally posted by Minstrel:

who knows the computer game in which the number 476 had a special meaning?OK, I give up. What game is it? I remember one but it's the wrong number :) mmmh...ok. if this was my own thread, i would make you suffer a bit longer by giving one more hint :D

but since this thread's not mine, here's a quick answer:

PARADROID

476 was the maintenance robot's number.

Zengar
08-24-2006, 02:28 AM
Zadeh, I don't understand you... Two day ago I send you correct code as you asked in your private message, but you continued on using your own badly written code. Can't you just accept that there are people that use OpenGL for years and have far more exprecience then you do? I personally start to see it as an insult: first you bomard me with pms which I throughtly answered, then you start posting same stuff (with same stupid questions) on the forum. If you don't understand how texturing works then you should read a book. I see really no point in such behaviour. Please do not pm me anymore.

p.s. Sorry everyone, I'm just very annoyed :-/

p.p.s. @Korval: I was ensured by some Nvidia employe that EXT_framebuffer_blit will "appear in next major driver release", whatever this means :-)

plasmonster
08-24-2006, 05:29 AM
PARADROID

476 was the maintenance robot's number.Paranoid? Never heard of it :p

Sorry for the OT folks, but RigidBody is up to some sort of cunning villainy.

zadeh79
08-24-2006, 06:36 PM
"you keep reloading the texture every frame. The whole point of texture objects is that you only load the data once. Then you bind (and unbind) the texture object as needed.
If you're loading 1MB of data off the disc every frame, of course it's going to run slow."

Actually, I am loading (and rendering) the texture only once in the first loop. For whatever reason, if I do not delete the texture immediately after the first cycle through the loop, the game runs really slow (so apparently binding/unbinding the texture object is not an option as well - maybe my image loader, glbmp, isn't good). The present post is in regard to a different problem than the first post. I was trying to find a way to draw the animated charachter over the background scene (which, again, is only loaded/rendered once) and avoid flicker. I haven't found a way to do this and as Korval stated it isn't possible as of now. Thus, I am forced to render directly to the front buffer. This leaves me with a flickering charachter.

ZbuffeR
08-25-2006, 08:32 AM
maybe my image loader, glbmp, isn't goodARGGGHHHHHHH

Indeed that is your problem since day one !
to do only in loader :

GLuint backgroundTexid;
glGenTextures(1,&backgroundTexid);
glBindTexture(GL_TEXTURE_2D,backgroundTexid);
glTexImage2d(...)

GLuint guyTexid;
glGenTextures(1,&guyTexid);
glBindTexture(GL_TEXTURE_2D,guyTexid);
glTexImage2d(...)

----


in main loop :

glBindTexture(GL_TEXTURE_2D,backgroundTexid);
<here draw full screen quad>

glBindTexture(GL_TEXTURE_2D,guyTexid);
<here draw small guy quad>

You'll wont see the guy because it will go too fast :D

zadeh79
09-15-2006, 05:40 PM
Ok. I got a new video card (Geforce 7300 PCIE), and the front buffer flicker went away. I guess it was the onboard intel video that was the culprit. I did change the image loader as well, to further gain some performance.