Order of operations with OpenGL FrameBuffer Object (FBO)

Special thanks

Special thanks to Dominik Goddeke's GPGPU tutorials. Home Page.

Order of operations.

glGenFramebuffersEXT(...); //generates new framebuffers
glBindFramebuffer(...); //sets framebuffer in active state.

glMatrixMode(...); //sets matrix mode
...
glViewPort(...); //sets sizes of viewport

glGenTextures(...); //generates new textures
glBindTexture(...); //sets texture in active state
glTexParameter(...); //sets texture parameters (magnification and minification filtering and so on)
...
glTexImage(Target, 0, IntFmt, Sx, Sy,Fmt, GL_FLOAT, 0); // sets texture type, format and size

glBindTexture(...); //sets texture in active state
gltexSubImage2D(Target, 0, 0, 0, Sx, Sy, Fmt, GL_FLOAT, Ptr); //fills with data our texture and upload them to GPU memory
... glTexEnvi(...); //sets pixel replacing method

glCreateProgramObject(...); //creates GLSL program
glCreateShaderObject(...); //creates GLSL shader (in our case this is fragment shader)
glAttachObject(Prg, Shader); //attaches shader to program
glShaderSource(...); //sets source for shader
glCompileShader(Shader, ...); //compiles our shader
glLinkProgram(Prg); // Links our program
glgetUniformLocation(...); //gets addresses of uniform variables in program (UniLoc).

glFrameBufferTexture2DEXT(..., RenderTarget, ...); //sets texture as render target
glUseProgramObject(Prg); //sets our program as active program
...
glActiveTexture(GL_TEXTURE0 + Index); //sets Index multitexture as active
glBindTexture(tex); //sets texture as active
glUniform1i(UniLoc, Index); //sets uniform sampler in our program
...
glDrawBuffer(RenderTarget); //set render destination
...
glPolygonMode(GL_FRONT, GL_FILL); //sets polygon mode
drawRectangle(...); //draws rectangle with correct texture coords and position.

glReadBuffer(RenderTarget); //sets buffer for reading from
glReadPixels(..., Buf); //Reads computed values into allocated Buffer


Generated on Thu Mar 5 22:36:42 2009 for gpucalc by  doxygen 1.5.6