Hello, I’m new to OpenGL ES, so please bear with me.
I’m trying to render to a p-buffer and use it to texture the wall in the Chameleon Man demo that came with the SDK.
So I create my p-buffer and a texture to bind it with like this:
EGLint conflist[] = {EGL_WIDTH, 512, EGL_HEIGHT, 512, EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE, EGL_NONE};
g_PBuffer = eglCreatePbufferSurface(platformBase->gEglDisplay, platformBase->gEglConfig, conflist);
glGenTextures(1, &pbufferTexture);
glBindTexture(GL_TEXTURE_2D, pbufferTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
Then I set my p-buffer as my render target like so and just clear it to red, then switch back:
eglMakeCurrent(platformBase->gEglDisplay, g_PBuffer, g_PBuffer,platformBase->gEglContext);
myglClearColor(f2vt(1.f), f2vt(0.f), f2vt(0.5f), f2vt(0));
eglMakeCurrent(platformBase->gEglDisplay, platformBase->gEglWindow, platformBase->gEglWindow, platformBase->gEglContext);
And finally when I want to use it as my texture I do this:
eglBindTexImage(platformBase->gEglDisplay, g_PBuffer, pbufferTexture);
glBindTexture(GL_TEXTURE_2D, pbufferTexture);
I’m just getting all black for my texture, instead of the red color I cleared to. Is there anything glaringly wrong about my set-up? Or perhaps I’m missing something.
My apologies if I’m missing something really simple, I’m new to this api and really have been having a hard time finding info. If anyone knows any good tutorials and sites, I’d love to check them out.
Thanks,
Benny