Camera not move

I can not move the camera. I added a variable that increases, objects move but not the view point.
The code:

public void onSurfaceChanged(GL10 gl, int width, int height) {

	if(height == 0) { height = 1; }
	gl.glViewport(0, 0, width, height); 
	gl.glMatrixMode(GL10.GL_PROJECTION);
	gl.glLoadIdentity(); 		
	//Calculate The Aspect Ratio Of The Window
	GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f);
	GLU.gluLookAt( gl,10.0f, 10.0f, 10.0f, 0, 0, 0, 0, 0, 1);
	

	gl.glMatrixMode(GL10.GL_MODELVIEW); 	
	gl.glLoadIdentity(); 			
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
		
	gridVertexBfr = FloatBuffer.wrap(gridCoords);

	gl.glEnable(GL10.GL_TEXTURE_2D);			//Enable Texture Mapping
	gl.glShadeModel(GL10.GL_SMOOTH); 			//Enable Smooth Shading
	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); 	//Black Background
	gl.glClearDepthf(1.0f); 					//Depth Buffer Setup
	gl.glEnable(GL10.GL_DEPTH_TEST); 			//Enables Depth Testing
	gl.glDepthFunc(GL10.GL_LEQUAL); 
	gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); 
	
}

public void onDrawFrame(GL10 gl) {

	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);	
	GLU.gluLookAt( gl,10.0f, 10.0f, 10.0f+k, 0, 0, 0, 0, 0, 1);
	
	// grid
	gl.glLoadIdentity();
	gl.glTranslatef(0, k, 0);
	gl.glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glVertexPointer(2,GL10.GL_FLOAT,0,gridVertexBfr);
    gl.glDrawArrays(GL10.GL_LINES, 0, 88);
	gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		
	k = k + 0.02f;
	
}

Why does not it work?
Thank you.

I tried in this way:

public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

gl.glMatrixMode(GL10.GL_PROJECTION);

gl.glLoadIdentity();//Calculate The Aspect Ratio Of The Window
GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f);
GLU.gluLookAt( gl,10.0f, 10.0f, 10.0f + k, 0, 0, 0, 0, 0, 1);

gl.glMatrixMode(GL10.GL_MODELVIEW);

gl.glLoadIdentity();
gl.glTranslatef(0, k0 0);
gl.glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glVertexPointer(2,GL10.GL_FLOAT,0,gridVertexBfr);
gl.glDrawArrays(GL10.GL_LINES, 0, 88);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
k = k + 0.02f;
}

but I get a black screen.

The camera may be too far from the model for it to be visible. Try moving the camera closer to the model. Are you calling eglSwapBuffers()? That is required.

You might want to start with a sample app from the Android SDK that works, such as the StaticTriangleRenderer. This article will help:

http://software.intel.com/en-us/articles/porting-opengl-games-to-android-on-intel-atom-processors-part-1

Regards, Clay

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.