# OpenGL Need help with offscreen buffers

## Recommended Posts

Hi, tis' me first post on this lovely site and I'm a bit of a newbie so please bare with me. I'm making an old-school-gradius-style 2D shootemup in C++ using OpenGL and GLFW. My problem is that I want to use Postprocessing effects to create some nice picture distortions (water for example). What I'd really like to do is render the whole screen on to a 320x240 offscreen buffer and then use that to draw the screenbuffer. Also it would be nice if it were platform independent. I'd like to know if there's a good way to do this. Now, i didn't come rushing here at the first sight of trouble so, I did try solve this problem myself. So, I tried just copying my whole rendered scene to an ordninary texture(512*256) and then back on screen. This works fine when in native resolution but if I want to enlarge the window to, say 640x480, I'll have to make a larger texture (1024*512) and copy a larger portion of the screen on to it. It feels like a waste of resources to copy a section 4 times the size of the one I need when all I want is to have a larger window. My next try was to always set my viewport to native resolution before the render loop (no matter my window size), store the finished scene on a texture, do the postprocessing, restore the viewport and then draw the buffer to fit the window. This works pretty well but is slow and if for some reason, my window happens to be smaller than native res I can't render the scene properly. Using shaders have occured to me, but having never dealt with them I harldy know what they do and if they can be of any help at all. As you might have noticed, I'm a tad stumped over this and would be truly grateful for any help I can get. Thanks in advance! /Mekanikles (sorry for repost, this was in Beginners forum so I moved it)

##### Share on other sites
The GL_EXT_framebuffer_object (FBO) extension is just what you're looking for. If you need some more help with it besides just the spec googling it will return lots of info.

##### Share on other sites
Wow, thanks!, it really looks like just what I need

But, and I feel i might need to crawl back to beginner's section here, what exactly is an OGL Extension and how do you use it? (yes, i tried looking for the answer but either I'm retarded or my question is ^^)

I googled around abit on the extension you mentioned and found some source code for msvc but i couldn't compile it.
I got a lot of errors like:
"error C2501: 'glFramebufferTexture1DEXT' : missing storage-class or type specifiers"

I don't know what to include/link and would be even more grateful for som further advise :)

[Edited by - Mekanikles on June 9, 2006 4:46:49 PM]

##### Share on other sites
I will look into it right away, though I have just made the decision to stick to strictly old-school graphics (think Cave Story), I will most certainly use extensions like these in my upcoming project.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627662
• Total Posts
2978519
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 10
• 10
• 12
• 22
• 13