PDA

View Full Version : how to render in the viewport display of more than?



Argonaft
06-19-2014, 01:48 PM
GLES20 Android

Hi all,

how to render in the viewport display of more than? for example GLES20.glViewport (0, 0, 5000, 5000);

carsten neumann
06-20-2014, 08:06 AM
I think the wiki page (http://www.opengl.org/wiki/Framebuffer_Object) on Frame Buffer Objects is what you are looking for, they allow you to render to textures where the size is independent of the application window size (but still subject to certain size limits).
If that is not what you are looking for, please provide more details on what you are trying to do and where you are running into problems.

Argonaft
06-20-2014, 10:23 AM
I think the wiki page (http://www.opengl.org/wiki/Framebuffer_Object) on Frame Buffer Objects is what you are looking for, they allow you to render to textures where the size is independent of the application window size (but still subject to certain size limits).
If that is not what you are looking for, please provide more details on what you are trying to do and where you are running into problems.

GLES20
I need to use to get the picture and glReadPixels​ 5000 to 5000, without the use of textures

like this

wi=5000;
he=5000;

GLES20.glViewport(0, 0, wi, he);
Matrix.orthoM(mProjMatrix, 0, -wi/2,wi/2 , -he/2, he/2, 1, 10);
frame = new int[1];
GLES20.glGenFramebuffers(1, frame, 0);
int fboId = frame[0];
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboId);
int[] renderbuffers = new int[1];
GLES20.glGenRenderbuffers(1, renderbuffers, 0);
GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, renderbuffers[0]);
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFE R, GLES20.GL_RGBA4 , wi,he);
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBU FFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, renderbuffers[0]);

//render...

//mPixelBuf - Houses the picture 5000x5000

GLES20.glReadPixels(0, 0,wi, hi, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, mPixelBuf);

carsten neumann
06-21-2014, 01:17 AM
Please use
around source code to preserve formatting, thanks.

Your FBO only has a depth attachment, you also need a color attachment where the actual picture you are rendering is stored - before calling glReadPixels() use glReadBuffer() to select your color attachment as the source.

reto.koradi
06-21-2014, 12:30 PM
The renderbuffer allocated in the code has format RGBA4, so it would not be valid as a depth attachment. This renderbuffer was probably supposed to be attached as a color attachment. The second argument to glFramebufferRenderbuffer() will have to be GL_COLOR_ATTACHMENT0 instead of GL_DEPTH_ATTACHMENT in this case.

If a depth attachment is needed as well, that one will have to be allocated with a format of GL_DEPTH_COMPONENT16.

Also, 5000x5000 is a large size. Since ES 2.0 is used, I figure we're talking about mobile devices. Many of them will have size limits on the render target that are smaller than this.

Argonaft
06-25-2014, 09:54 AM
Thank you all. It works