Android OpenGL ES image filters - android

I found this example and I am making some filters on realtime camera. When I use GlassSphereFilter or SphereRefractionFilter I get sphere on black background, and I want to achieve something like this. Can anyone help me?
Here is part of the code:
view = new FastImageProcessingView(this);
pipeline = new FastImageProcessingPipeline();
view.setPipeline(pipeline);
setContentView(view);
input = new CameraPreviewInput(view);
filter = new SphereRefractionFilter(new PointF(0.43f, 0.5f), 0.25f, 0.71f, 0.5f);
screen = new ScreenEndpoint(pipeline);
input.addTarget(screen);
filter.addTarget(screen);
pipeline.addRootRenderer(input);
pipeline.startRendering();
Is there a way ti show two surfaceViews with camera in same time? One to show normal image and other to show sphere?

I think you should use this library :
https://github.com/CyberAgent/android-gpuimage

Related

How to Rotate a TextField at Libgdx Android App?

Hi im developing a game with libgdx for android. My problem is that code:
button = new TextButton("SEND", skin);
button.setPosition(300,200);
button.setSize(200, 40);
button.setTransform(true);
button.setRotation(90);
user = new TextField("", skin);
user.setPosition(300,250);
user.setSize(200, 40);
user.setRotation(90);
user isnt rotating with setRotation. I would like to rotate this textfield. thanks for every suggestion
You need to call setTransform(true) on Actors to enable rotation. If Textfield doesn't have that method, wrap it in a Group.

GearVRf - SceneObject not visible with GVSphere Image

I am trying to show a dot/pointer on GVRSphereSceneObject in GearVR. But, only the GVRSphereSceneObject is showing where as scene object hides once the texture image becomes visible. If I add both sphere and object using addSceneObject, then image is shown on one side and rest of view is blacked out.
I couldn't find any issue regarding this and tried samples also. Any help will be greatly appreciated.
Here is the code for adding object over sphere.
Future<GVRTexture> texture = gvrContext.loadFutureTexture(new GVRAndroidResource(gvrContext, R.raw.pano));
GVRMaterial material = new GVRMaterial(gvrContext);
material.setMainTexture(texture);
boom = new GVRSphereSceneObject(gvrContext, 18, 36, false, material);
Pointer = new GVRSceneObject(gvrContext,
new FutureWrapper<>(gvrContext.createQuad(0.05f, 0.05f)),
gvrContext.loadFutureTexture(new GVRAndroidResource(this.gvrContext, R.drawable.target)));
Pointer.getRenderData().getMaterial().setColor(Colors.RED[0], Colors.RED[1], Colors.RED[2]);
Pointer.getTransform().setPosition(0.0f, 0.0f, -1.0f);
Pointer.setName("Pointer");
boom.addChildObject(Pointer);
scene.addSceneObject(boom);
If anyone is struggling with this. Please have a look at this issue.
Pointer.getRenderData().setDepthTest(false);
Pointer.getRenderData().setRenderingOrder(SXRRenderData.SXRRenderingOrder.OVERLAY);

Opengl - Creating a mini map from a gl view

I want to create a map from some opengl code that I wrote :
In order to do that I though about taking a screen shot of the upperview of the gl screen.
Yet I cant seem to find how to do that...
any suggestions?
Similar problem has been solved in OSG example code here.
First you need to set your view such that you are looking at center from the TOP VIEW.
osg::Vec3 center = scene->getBound().center();
double radius = scene->getBound().radius();
view->getCamera()->setViewMatrixAsLookAt( center - lookDir*(radius*3.0), center, up );
view->getCamera()->setProjectionMatrixAsPerspective(
30.0f, static_cast<double>(width)/static_cast<double>(height), 1.0f, 10000.0f );
Then, you need to use some OS specific API to do similar to logic below:
osgViewer::ScreenCaptureHandler* scrn = new osgViewer::ScreenCaptureHandler();
osgViewer::ScreenCaptureHandler::WriteToFile* captureOper = new osgViewer::ScreenCaptureHandler::WriteToFile(tmpStr.m_szBuffer, "png");
scrn->setCaptureOperation(captureOper);
scrn->captureNextFrame(*_viewer);
_viewer->frame();
Of course if you are not using OSG then you need to find equivalent APIs (of library you are using) to achieve the same task.

Libgdx mask by shader with different textures

I'm following this tutorial
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson4
to create mask technique in libgdx. Everything works fine as the example code.
But the example code only use
a set of (background, mask, foreground) texture. When applying in my case with different set of textures, I cannot get it works unless
using batch.flush() after batch.draw(tex0,...).
The cycle is:
batch.begin()
tex1 = foreground1;
tex2 = mask1;
tex1.bind(1);
tex2.bind(2);
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
batch.draw(tex0, ...)
batch.flush();
tex1 = foreground2;
tex2 = mask2;
tex1.bind(1);
tex2.bind(2);
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
batch.draw(tex0, ...)
batch.flush();
batch.end();
If I don't use batch.flush(), all masks and foregrounds will be identical. But using batch.flush() severely reducing performance when I test on my Android phone.
Thanks in advance, any help is highly appreciated

Why NinePatch dont work in LibGDX?

I have a backround for message item, I want to make it stretched depending on the text. But when i make this:
Drawable drawableButtonMessageUp = new TextureRegionDrawable(new TextureRegion(new Texture("data/message_my_g.9.png")));
ButtonStyle buttonStyleMessage = new ButtonStyle();
buttonStyleMessage.up = drawableButtonMessageUp;
Button buttonMessage = new Button(buttonStyleMessage);
Label labelMessage = new Label("", new LabelStyle(game.fonts[0], new Color(0, 0, 0, 1)));
buttonMessage.add(labelMessage);
Background does not NinePath, it strached like a normal picture:
My result:
I want (example):
Backround for item:
I checked the nine patch picture in Android SDK, and this work good, how i can do this in libGDX?
It's because you're not using a NinePatch, you're using a TextureRegion
you probably are going to want to change the line
Drawable drawableButtonMessageUp = new TextureRegionDrawable(new TextureRegion(new Texture("data/message_my_g.9.png")));
to something like
Drawable drawableButtonMessageUp = new NinePatchDrawable(new NinePatch(new Texture("data/message_my_g.9.png"), 1, 1, 1, 1));
Note that the number "1" here is a placeholder. You may need to play around with those numbers to get the ninepatch to look right.
For more information, please take a look at the documentation, particularly the section on instantiating ninepatches

Categories

Resources