Draw to offscreen renderbuffer in OpenGL ES (iPhone) -
I am trying to create an offscreen render buffer in OpenGL ES on iPhone. I have created a buffer like this:
glGenFramebuffersOES (1, and offscreen framebuffer); GlobeFramebufferOS (GL_FramMeFoOES, OffscreenFramebuffer); Glenzer BuffersOoS (1, and OffscreenRenderBuffer); GlobindorBufferOS (GL_RENDERBUFFER_OES, OffscreenRenderBuffer); GloFrefrbferferbuffer (GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, OffscreenRenderBuffer);
But I'm confused about how to render the storage. Apple's documentation says that EAGLContext renderBufferStorage: Drainable from: method, but it only for a render buffer (main display) Works. If I use the normal OpenGL function glRenderBufferStorageOES, then I can not seem to display it. Here's the code:
// This is in the initial section: glRenderbufferStorageOES (GL_RENDERBUFFER_OES, GL_RGB8_OES, backingwidth, backingHight); // And this is when I try to attract it and display it: glBindFramebufferOES (GL_FRAMEBUFFER_OES, offscreenframebuffer); Jl float vc [] = {0.0f, 0.0f, 0.0f, 10.0f, 10.0f, 10.0f, 0.0f, 0.0f, 0.0f, -10.0f, -10.0f, -10.0f,}; GlLoadIdentity (); GlEnableClientState (GL_VERTEX_ARRAY); Glitax Pointer (3, GL_ Floa, 0, VC); Glaudrares (GL_line, 0, 4); GlDisableClientState (GL_VERTEX_ARRAY); GlobindorBufferOS (GL_RENDERBUFFER_OES, OffscreenRenderBuffer); [Reference presentationRender buffer: GLINRBFFOOS];
Doing this in such a way, nothing is displayed on the screen However, if I change the buffers created with the RenderBufferStorage method, the references to "Offscreen ... buffer" , Then it works fine.
Any suggestions?
@david Good idea .. what do you need to do? @prideout has said what .. texture Create and present it. And use it every time the texture on the quad ensure that you attract the texture only once, as things happen in your case.
- (zero) Settext buffer {glGenFramebuffersOES (1, and texturebuffer); GlobindFramBuferOS (GL_FrammeboughOoOOS, texturebuffer); // Texture Glangacators (1, and canvetector); GlobIndactations (GL_EditDDD, CanvVictations); GlTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_ UNSIGNED_BYTE, NULL); GlFramebufferTextxture2DOES (GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, CANVATTICTURE, 0); Zelename Stats = glCheckFramebufferStatusOES (GL_FRAMEBUFFER_OES); If (status! = GL_FRAMEBUFFER_COMPLETE_OES) {NSLog (@ "Failed to create full framebuff object% x;", position); } GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GlClearColor (1.0, 1.0, 1.0, 1.0); GlViewport (0, 0, 512, 512); GlClear (GL_COLOR_BUFFER_BIT); } // setTargetToTexture () function glBindFramebufferOES (GL_FRAMEBUFFER_OES, TBFIFR); GlobIndactations (GL_EditEd.D.D., Albrecht); GlViewport (0, 0, 512, 512); // Texture GlViewport (0, 0, BWIDTH, BHEIGHT); Reset Points After Finishing Drawing; GlVertexPointer (2, GL_floyet, 0, canvas); // canvas corner glTexCoordPointer (2, GL_FLOAT, 0, TX); GlobIndactures (GL_EducationADDDD, Bitactactation); // Make a special renderer target glBindFramebufferOES (GL_FRAMEBUFFER_OES, FBF); // Back to normal framebuffer
Comments
Post a Comment