Can't initialize opengles Android renderer


Joey

Still Fresh
Joined
Apr 14, 2014
Messages
1
As a beginner, I am following the "Building an OpenGLES environment" docs. I just want to draw a grey screen. I've written every step as suggested but Eclipse still gives me an error in the MyGLSurfaceView class and in MyRenderer class. Here they are

Main activity


package com.example.testopengl;

import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.app.Activity;

public class OpenGLES20Activity extends Activity {

private GLSurfaceView mGLView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


mGLView = new MyGLSurfaceView(this);
setContentView (mGLView);

}


}
MyGLSurfaceView class


package com.example.testopengl;

import android.content.Context;
import android.opengl.GLSurfaceView;

public class MyGLSurfaceView extends GLSurfaceView {


public MyGLSurfaceView (Context context) {
super (context);

setEGLContextClientVersion(2);

setRenderer(new MyRenderer());

setRenderMode (GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}

}
MyGLRenderer class


package com.example.testopengl;

import javax.microedition.khronos.opengles.GL10;

import android.opengl.EGLConfig;
import android.opengl.GLES20;

public class MyGLRenderer implements GLSurfaceView.Renderer {

public void onSurfaceCreated (GL10 unused, EGLConfig config) {
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}

public void onDrawFrame (GL10 unused) {
GLES20.glClear (GLES20.GL_COLOR_BUFFER_BIT);
}

public void onSurfaceChanged (GL10 unused, int width, int height) {
GLES20.glViewport(0, 0, width, height);

}

}

Errors pops in MyGLSurfaceView class at this line setRenderer (new My Renderer())  -->Renderer cannot be resolved to a type

and in MyGLRenderer class at public class MyGLRenderer implements GLSurfaceView.Renderer -->GLSurfaceView.Renderer cannot be resolved to a type.

Where am I going wrong?
 
Errors pops in MyGLSurfaceView class at this line setRenderer (new My Renderer())  -->Renderer cannot be resolved to a type
From the code you posted, it looks like your renderer class is called "MyGLRenderer", and not "MyRenderer", try changing that
and in MyGLRenderer class at public class MyGLRenderer implements GLSurfaceView.Renderer -->GLSurfaceView.Renderer cannot be resolved to a type.
Not 100%, but sounds like you're missing an Import
 
Is this specific to Pandora ? If not, you may be on the wrong forums.
Oh please, you should see some of the posts in Pandora -> General, a lot of stuff doesn't belong in there.

But yeah, might be better posting on an actual Android dev forum
 
Back
Top