I try to send a value from my Activity through a GLSurfaceView to the Renderer, but there are some problems with the object in the SurfaceView class. I think I can't access directly to the Renderer from my Activity, I've tried. I get a null-Exception in my GLView class when I try to set the value.
public class Activity extends Activity implements SeekBar.OnSeekBarChangeListener{
GLSurfaceView mGLView;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_1d);
mGLView = (GLView)findViewById(R.id.surfaceView1D);
mGLView = new GLView(this,10);
// mGLView.mRenderer.var_in_Renderer=10; //Test, but not Working!
}
...
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
mGLView.var_in_Renderer=progress; //Not working
mGLView.setProgress(progress);
}
...
}
class GLView extends GLSurfaceView {
MyGLRenderer mRenderer;
void setProgress(int progress){
mRenderer.var_in_Renderer=progress; //Error!!!!!!!!!!!!!!!!
}
//Empty Constructor don't go, so I filled
public GLView(Context context,int progress){
super(context);
}
public GLView(Context context, AttributeSet attrs) {
super(context,attrs);
// Set the Renderer for drawing on the GLSurfaceView
mRenderer = new MyGLRenderer();
setRenderer(mRenderer);
mRenderer.var_in_Renderer=10; //That would work, but is not what I need
}
}
How can I set a value for the variable in my Renderer?