1

This is my final technology issue that i have to complete my 4 month of work on my app.

I will try to be simple as i can,because i need specify solution.

My problem:

In short: i need the stretch my glSurfaceView
I am using custom glsurfaceView,that implement OnMeasure method to set the actual width and height to the surface.
I set the width and height for 1280 and 720 for instance.
then i use openGL and get that pixels with glReadPixel() method to encode video
so far so good.

i add the view in that way :

this.addContentView(this.mRenderSurfaceView, BaseGameActivity.createSurfaceViewLayoutParams());  

when :

  protected static LayoutParams createSurfaceViewLayoutParams() {
    final LayoutParams layoutParams = new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    return layoutParams;
}

Thats what i tried so far:

I want the glsurface to be the actucal pixels that i set in OnMeasure, that's mean the glReadPixel() function will get the same pixels as i set, but,I want to scale this surface,without changing to actucal pixels.

when i try this:

this.mRenderSurfaceView.setPivotX(0.0));
this.mRenderSurfaceView.setScaleX(2.0));

It just copy the surface to another place in the screen,without any scale.

What i do wrong?

Please,I don't need to change the actual width and height of this surface.i need it as is-but i have to scale it that the user will see it bigger then the real pixel that i set with onMeasure method.

**i encode the surface to video so any change in width/height will change the pixel that i get in glReadpixel-so just scale is needed.

Community
  • 1
  • 1
yarin
  • 543
  • 1
  • 5
  • 18
  • I think you want to be using `SurfaceHolder#setFixedSize()` to set the size of the GL surface. – fadden Feb 28 '14 at 17:40
  • sound good:) .i try to implement it with : this.getHolder().setFixedSize(2600, 700); but with no change,where should i add this code line? the createSurfaceViewLayoutParams() that called when add the View,is not override it? – yarin Feb 28 '14 at 18:10
  • when i set this,the only change is the touch event which scaled or something,but still the surface not scaled – yarin Feb 28 '14 at 19:51
  • If you run the "Hardware scaler exerciser" in Grafika (https://github.com/google/grafika) you can get a sense for what `setFixedSize()` does. It sets the size of the Surface to a fixed value (which is what you want for video). The Surface is scaled up or down by the GPU before being displayed in the View. This is most apparent when you select the "tiny" surface size in the demo. – fadden Feb 28 '14 at 20:00
  • Thank You Fadden.it seems like complicate example,i will try to exercise it.but for meanwhile,you have any idea how to implement it easily ? i'm usind custom glsurfaceView (this one:https://github.com/nicolasgramlich/AndEngine/blob/GLES2/src/org/andengine/opengl/view/RenderSurfaceView.java) from game engine.there is no simple whay to stretch this surface without building all again from scratch? – yarin Feb 28 '14 at 20:15
  • BTW,my app using glsurfaceView and not surfaceView as Grafika use – yarin Feb 28 '14 at 20:20
  • `GLSurfaceView` is just `SurfaceView` with some of the details (threading, EGL surface creation) handled for you. You can get the `SurfaceHolder` with `getHolder()` and set the fixed size. I'm not suggesting that you change your code to work like Grafika; I'm just using it as an example to show the effect that `setFixedSize` has. – fadden Feb 28 '14 at 20:25
  • OK,it is look like it make the job:) i set the layout param to be bigger then the setfixedSize,and it what im looking for.to only problem is the touch event on this surface is totally distorted.so maybe i will handle the event from other view on top of it – yarin Feb 28 '14 at 20:49

0 Answers0