stencil-buffer

Does iOS5 support both GL_STENCIL_INDEX and GL_STENCIL_INDEX8?

不想你离开。 提交于 2019-12-08 06:03:42
问题 With the following code: GLuint viewRenderbuffer, viewFramebuffer, viewDepthbuffer, stencilBuffer; // Create the framebuffer object glGenFramebuffers(1, &viewFramebuffer); glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer); // Create a render buffer and bind it to the FBO. glGenRenderbuffers(1, &viewRenderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer]; glFramebufferRenderbuffer(GL_FRAMEBUFFER,

Visualizing the Stencil Buffer to a texture

有些话、适合烂在心里 提交于 2019-12-06 08:08:52
问题 I'm trying to put the stencil buffer into a texture for use in a deferred renderer. I'm getting other Color and Depth Attachments with glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[color1], 0); and the result is correct. However when I try to attach my stencil buffer to a texture with glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT ,GL_TEXTURE_2D, textures[stencil], 0); I get a garbled result, as if the FBO isn't clearing its buffers. I don

opengl stencil buffer - not quite got it working

房东的猫 提交于 2019-12-06 06:24:23
currently im drawing a background, then a transparent triangle into the stencil buffer, then a blue square where the triangle isnt being drawn. i was hoping the effect would be a blue square with a trianglular hole exposing the background. but all im getting is a black triangle drawn over everything else. i think im getting the desired effect on the square but the stencil is also being applied to the background. my question is how can i adjust the following code to allow the background to be displayed through a triangular hole in the square? static void Draw(void) { glClear(GL_COLOR_BUFFER_BIT

LibGDX Stencil Buffers while using SpriteBatch

浪尽此生 提交于 2019-12-06 06:20:46
This is a continuation of my previous problem and post, seen here . Thanks to the answer I received there I feel I was able to get a little closer to my goal, as well as further my learning of OpenGL, but shortly after figuring out the basics of working with stencil buffers, I've run into a problem. It seems that when I draw a sprite to the stencil buffer, it draws the entire square area, rather than just the pixels that aren't fully transparent as I had ignorantly hoped. I vaguely understand why it happens that way, but I am not sure where the solution lies. I have experimented with the

Render off screen (with FBO and RenderBuffer) and pixel transfer of color, depth, stencil

社会主义新天地 提交于 2019-12-05 05:41:29
问题 I'have to render off screen in OpenGL and then pass the image to a QImage. Plus, just for exercise I'd like to transfer to the CPU also the depth and the stencil buffer. For drawing offscreen I've used Frame Buffer Object with Render Buffer (and not with texture because I don't need the texture). Pixel transfer operation with color buffers (the actual raw image) works.. I see what I'm expecting. But depth and stencil are not working.. strange image for depth and nothing with for the stencil.

Stenciling using OpenGl ES 2.0

假如想象 提交于 2019-12-04 11:04:25
I am trying to figure out a way to cut out a certain region of a background texture such that a certain custom pattern is not rendered on the screen for that background. For example: This square can be any pattern. I am using Frame Buffer Object and Stencil Buffer to achieve this kind of effect. Here is the code: fbo.begin(); //Disables ColorMask and DepthMask so that all the rendering is done on the Stencil Buffer Gdx.gl20.glColorMask(false, false, false, false); Gdx.gl20.glDepthMask(false); Gdx.gl20.glEnable(GL20.GL_STENCIL_TEST); Gdx.gl20.glStencilFunc(GL20.GL_ALWAYS, 1, 0xFFFFFFFF); Gdx

Issue when updating stencil buffer in OpenGL

眉间皱痕 提交于 2019-12-01 11:07:55
I'm having issues when drawing using the stencil test in OpenGL on mac. When I first draw the scene, the stencil works fine. I draw a semi-transparent black rectangle in the middle, with writing to the stencil buffer enabled, and then a larger blue rectangle with writing to the stencil buffer disabled. I get the right result when the window first pops up, which looks like this: However, when I resize the window, and the rendering function gets called again, I get a result which looks like: or Sometimes the weird white space follows the middle rectangle, other times the white snaps between

How does mask affect stencil value according to stencil op?

这一生的挚爱 提交于 2019-11-30 22:39:50
The documentation in OpenGL reference pdf (both OpenGL 3.3 and 4.5 specs) is not much clear about what happens to the stored stencil value when a mask is applied. In example If I have the following mask: glStencilMask( 0x06); and stored in the stencil buffer there is already this value: 0x06 If the stencil operation is GL_INCR_WRAP what should happens when StencilOp is correctly invoked on that pixel? Basically I have the mask: 00000110 and the value 00000110 and I try to increment it, is it wrapped? 00000010 or is it just zeroed? (00000110 + 1) & mask 00000000 derhass Section 17.4.2 "Fine

How to create Stencil buffer with texture (Image) in OpenGL-ES 2.0

痞子三分冷 提交于 2019-11-30 19:59:41
Can I have Stencil prepared with a texture (Image) in OpenGL 2.0 So that some part of the Image will be transparent and as a result it will be transfered as is to Stencil buffer and then will use this use this stencil buffer for further drawing. EDIT by datenwolf to account for OPs question update in a answer: By @InfiniteLoop: @datenwolf thanks a lot for ur reply but no success :( here is my code - (void)render { [EAGLContext setCurrentContext:context]; glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer); glUseProgram(program); glClearColor(0, 104.0/255.0, 55.0/255.0, 1.0); glViewport(0, 0,