Hi there,
i’m working on a c++ application under windows 10 for live-animation-arts, using OpenGL for rendering and wxWidgets for controlling. The program is just in a basic state, which means that wxWidgets-part (the window-management, and most of the module-linking and unlinking) is working fine. But with OpenGL i’m just doing the first steps - not only in this program, also concerning my own skills.
The concept is simelar to a moduar synthesizer. So modules like eg. a small window (however) definig a texture or one, defining a position and a rotation can be added / renmoved and linked to other modules defining eg. a 3d-object or a light-souce while the program is running.
I also want modules with “2d-functions”.
The idea is to manipulate textures inside of the graphic-memory by eg. merging them using the blending-functions. So my project needs a lot of offscreen-rendering. In fact i want to render everyting in memory, which means that every 2d-module (even those who render 3d-objects have a 2d output, while my display has two dimensions;)) is generating a texture first and one of them can be drawn to the output in a second step, while othes are used as sorces for the module-chain. So requirements for 2d-modules are:
a) a 2d-module is associated with exact one output-texture (but may have 0 to x source-textures)
b) it can be added or deleted, which should generate or delete the associated texture-pointer (glGenTextures(1, &texptr) / glDeleteTextures(1, &texptr))
c) associated textures may change size without removing the module.
d) not every 2d-module (texture) will be updated per frame. Some may be updated only on a trigger-signal.
Now i have some basic questions concerning offscreen-rendering. because something is going wrong like eg. flickering since i konsequently implemneted it (- used some slow workarounds for testing in before).
Are the following points correct:
-
A framebufferobject just “redirects” the rendering-target to another address. It does not allocate memory itself?
-
Deleteng a framebufferobject will not free the texure-memory?
-
If there is no depth or (at least) no object will be hidden by another one, a depthbuffer is not needed?
-
A renderbufferobject is an object which links eg. a depth- or a stencilbuffer to the process, so if i don’t need them, i also don’t need to create a renderbuffer. In this case it will be sufficient to create a framebuffer, to render to a texture?
-
As already said, currently i’m creating a texture-pointer (glGenTextures(1, texptr)) when i create the module. The texture itself i generated just before drawing to it (wich is not in every case per frame) by:
glBindTexture (GL_TEXTURE_2D, texptr);
glTexImage2D(GL_TEXTURE_2D, 0, [internalFormat], w, h, …);
Is this also correct? -
If a module is deleted, i call glDeleteTextures(1, &texptr);. There is no call needed to free the memry?
-
If a texture-memory should have anoter size in a later frame (not the textue-image, which will be replaced completely afterwards - so it may be discarted) i just need to call another glBindTexture-glTexImage2D-combination with the new size. The previously used memory is given free automaticly?
-
As long as i don’t do delete (=> point 5) or “recreate” (=> point 6), the texture will be kept in memory?
-
Concerning parameters of:
void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * data);
Is it right that “internalFormat” means, how the data is stored in the graphich-memory, while “format” and “type” are only used to interpret *data, so for *data = NULL they are indifferent? -
What means the index in GL_COLOR_ATTACHMENT[x]?
-
What i basicly do per calulation-step of a module is:
- bind target-texture
- create fbo
- create depthbuffer etc. and renderbuffer if depht etc. are needed
- bind source-texture
- process rendering
- delete backwards: renderbuffer, depth- & stencil-textue etc.
- delete fbo
- call glActiveTexture (GL_TEXTURE0);
Is this correct?
11b. glBindFramebuffer (GL_FRAMEBUFFER, 0); is just needed when i want to render to an output?
Thanks a lot for reading all this
Regards,
Frank