PDA

View Full Version : can framebuffer object used without egl initialization?



qzhua
12-21-2011, 07:29 AM
I'm a newcomer to the opengl programming. I want to use opengles 2.0 to do some post-processing of images. I find that the FBO seems to be a good choice. My question is how can I use the FBO and should I use the EGL API to create a display,context,surface before that? I found that I cannot use glGetIntegerv or glGenFramebuffer until a window/pbuffer surfface is created. Is there any better ways to do the same thing?

qzhua
12-21-2011, 08:19 PM
My code is like this, when egl initialization presents the code can run, but when removed it seems any function begin with gl* will fail.


#include "./gl2.h"
#include "./gl2ext.h"
#include "./gl2extimg.h"
int main(int argc, char **argv)
{
// Fragment and vertex shaders code
const char* pszVertShader =
"attribute vec4 a_position; \n"
"void main() \n"
"{ \n"
" gl_Position = a_position; \n"
"} \n";

const char* pszFragShader =
"precision mediump float; \n"
"void main() \n"
"{ \n"
" gl_FragColor = vec4(0.5, 0.3, 0.1,1.0);\n"
"} \n";
GLuint uiFragShader, uiVertShader; // Used to hold the fragment and vertex shader handles
GLuint uiProgramObject; // Used to hold the program handle (made out of the two previous shaders
// Create the fragment shader object
uiFragShader = glCreateShader(GL_FRAGMENT_SHADER);

Nayan Kumar K
01-13-2012, 02:23 AM
Even I am looking for an answer for the exactly same problem. I think you need to create EGLContext as it is necessary for maintaining the OpenGL ES state (hope I am not wrong here), but I am not sure if creating pBuffer surface is required as you are planning to render onto a FBO object. However, if you don't create pBuffer surface, then I am not sure what needs to be passed as argument to eglMakeCurrent!

Please let me know if you found what you were looking far!

Thanks,

debinair
04-25-2012, 04:34 AM
ASFIK , you can not make any gl call before creating eglContext . Create a eglContext first and then you can proceed with FBOs no need to initialize shaders' stuff.

qzhua
04-25-2012, 08:09 PM
Thank you for you reply. I know glContext is necessary,but what about surface. Logically speaking I think it not necessary, but in fact FBO will not work if you do not create a surface.

krikit
04-26-2012, 01:50 AM
Hi,

i use the context without showing any surface on the screen. Im using iOS so i don't know if this is available on your platform, but maybe it helps you. It's necessary to create a rectangle where the OpenGL ES context can render the images. But i don't use it from the main screen. I think you only search for a rendering solution without showing the image on the screen?

My solution for this:

I've created a OpenGLESManager which holds the context.
The initialization looks like the following code sniped:



if((_instance = [super initWithFrame:CGRectMake(0.0f, 0.0f, 2000, 2860)]))
{
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

if(!context || ![EAGLContext setCurrentContext:context])
{
[self release];
return nil;
}

[self createFramebuffer];
}


After this i can use the opengl methods and rendering stuff. But i don't need to show it on the screen.

For the context maybe it helps you to understand. The OpenGL ES Api is developed like a client server structure. And with the creating of the context you can set some messages or stats to the server. (<- This is from a OpenGL ES book and it helps me to understand the stuff of the OpenGL ES)

jpilon
05-22-2012, 11:40 AM
Spec currently requires an egl surface/context be made current in your thread, even if you just want to render to an FBO.