Do I need the stencil buffer for this?

Hey all!

First of all I’m really new to this scene. I know Java, but hardly know OpenGL / Game Development.
Today I spent a lot of time reading several tutorials about libgdx.

Now I wanted to create an effect that looks like this:

http://img14.imageshack.us/img14/4600/skfh.jpg

I got 2 players and a simple background image.
Now I want to use these players as alpha map for my background.
So the players could move, but the background does not move.
Like an “inverted” world.

Do I have to use the stencil buffer for this?
Or may be there better options?
Is it just a simple (combined) alpha map?

Hope you can help me!
Thanks!

Maybe an frame buffer.

  • Bind buffer

  • Draw characters

  • Unbind Buffer

  • Bind shader

  • Draw Texture

  • Unbind shader

Give this a try:


*draw background*
GL14.glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO);
*draw both these fighters*
GL11.glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
*draw a white quad surrounding both these fighters*

Hope it works.

Thanks RobinB, I will take a closer look at the FrameBuffer.

And as soon as I add this line:

Gdx.gl20.glBlendFuncSeparate(GL20.GL_ZERO, GL20.GL_ONE, GL20.GL_SRC_COLOR, GL20.GL_ZERO);

I get a NullpointerException.

Any ideas? :confused:

You need to enable GL20 to use Gdx.gl20.

http://badlogicgames.com/forum/viewtopic.php?p=42087#p42087

Just render white pixels if they are not fully translucent in the texture sample.