Add RajawaliRenderer as a View - android

I'm really new to Rajawali and was hoping to use a lot of their 3D functionality with the Android camera. My goal is to display a 3D object on a camera SurfaceView.
When doing this with a 2D object using native Android, the steps were:
Get camera and a holder
Create SurfaceView for the holder
Display the camera preview
Use a subclass of GLSurfaceView to draw stuff during the onDraw() call
My steps to do this using Rajawali are similar, except step 4. is now a subclass of RajawaliRenderer.
The problem is that the subclass of GLSurfaceView could be added as a child to the preview SurfaceView. RajawaliRendered has a method to getCurrentView(), but this returns null though the object has been constructed.
Any ideas?

Related

How to open camera with GLSurfaceView.Renderer

I'm trying to build a camera view as background.
I want to load my camera inside GLSurfaceView.Renderer class.
My class:
public class ModelRenderer implements GLSurfaceView.Renderer {
...
My question is, is it possible to load camera preview as background in GLSurfaceView.Renderer?
I'm using Android studio.
Well It isn't really adding the preview as a "background" but you certainly can draw the camera preview to the GLSurfaceView and attach a renderer to the surface to do the drawing. There are numerous examples of doing so. I would search around for them but I believe Grafika has what you are looking for.

Simple obj preview with ARCore

is there any way to show obj on glsurfaceview with ARCore but without camera and without implementing whole logic of renderer, I mean only preview of model, and for example after click, show model on camera. For example library that load preview of model and model in AR.
I know that I can use some library for load model to glsurfaceview and ARCore to load model to AR, but I ask if is some library that do all of this.
Prepare two activities. In first one you can make list of models for preview, after taping on the model you can pass some identifier of it to the second activity that will enable the camera and show it in front of the user.
Remember that the fact you`re using ARCore is not forcing you to do it in every single place and activity
I hope this what you had in mind

Draw Here MapsView into a GLSurfaceView

I got a problem with drawing a mapView from the here-api into a glSurfaceView (it should be a glSurfaceView as some external devices requeres it to ensure good performance).
The map draws into a normal SurfaceView just perfectly.
I do the following steps to create the map-view in the GLSurfaceView:
Extend my view from GLSurfaceView:
public class MapView extends GLSurfaceView
Setting the Renderer uppon initialisation in the ctors:
setRenderer(...)
Start rendering after the map has been initialized:
Renderer renderer = new MapOffScreenRenderer(getContext());
renderer.setMap(map); //mapView, not null
updateRendererSize(); //update the render size to the screen size
renderer.start(getHolder(), surfaceUpdatedListener); // HERE COMES THE CRASH
It seems like the MapOffscreenRenderer crashes if i try to tell him to draw the map into the glSurfaceView.
The crash is a generic error: "12291 EGL_BAD_ALLOC during rendering".
If i try to call the renderer.start() func (without the holder param), then everything is fine (the only bad thing is that the map is not being drawn).
The GlSurceView initialisation itself is fine as i am able to draw my own geometries into it.
Thank you very much for you help.
MapOffScreenRenderer internally uses a PBuffer backed surface and its own rendering thread and EGL context. It is not intended to be used to push into another GLSurfaceView surface. If you really want to do this then maybe create an independent OpenGL surface and share it between the GLSurfaceView and the MapOffScreenRenderer.
What use case are you try to accomplish using this type of design?

Camera Preview started in C++ but rendered to a Java surface

In Android, is the following possible (if so, how) :
I'd like to set up a layout in my java and add a view to it where the view contains a surfaceView for rendering the camera preview. But, I dont want to instantiate and start the camera in Java. I just want to set up the view so that I can keep the layout structure.
Then, I have a native C++ component accessed via JNI where I'd like to actually start the camera and have it's preview rendered in the SurfaceView mentioned above.
The reason for this setup is that I'd like to keep the layout that I defined in Java but access the camera and its preview frames in C++. I dont want to handle the preview frames in Java and then pass them to C++ as that is not efficient.
The other option would be to set up my java layout in C++, but not sure if that is even possible ?

How to Use Camera and SurfaceView in Background

iam currently using camera and surfaceview in my app to use Torch etc ... , im using these in an Activity ,
How to use Camera and SurfaceView in Background , ex . : I want to keep Torch/Led Flash On , i saw many Widget that work fine in Background , how they do it ?
Thanks .
Take a look here:
http://developer.android.com/guide/topics/media/camera.html
There is all the code you need to make an activity which shows the camera preview.
As the Camera API:
http://developer.android.com/reference/android/hardware/Camera.html#setPreviewDisplay%28android.view.SurfaceHolder%29
specifies...you need to use a SurfaceHolder for your preview. Thus you can only use a SurfaceView or a derived class for your automatic preview. Otherwise you can use for example a TextureView or an ImageView to draw your preview by yourself. You'll need though to implement the onFramePreview method to grab the frames from the preview and handle them by yourself. By using OpenGL or the ANI API you can also add effects to your frame. This is the only way, I know about, to also add effects directly on your preview, unless these effects can be achieved by overlaying a semi-transparent colored surface above your preview image.

Categories

Resources