Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Find everything you need for the Galaxy S5 and discuss it in our S5 forum!
Have you seen that OnePlus One's awesome camera?? The forum is over here!

test: Reply
LinkBack Thread Tools
Old August 28th, 2011, 06:04 AM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Aug 2011
Posts: 2
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Arrow OpenGL GLU.gluLookAt() makes blank screen??

Why isn't my camera moving at all???
I want my camera to move along the x-axis, but it doesn't move along any axis. Not even when I set cameraX,Y,Z to different values manually!

Please help me.. all code below!

	public boolean OnTouchEvent(final MotionEvent event) {
		cameraX += 0.2f;
		cameraY += 0.2f;
		cameraZ += 0.2f;
		return true;
	public void onSurfaceChanged(GL10 gl, int width, int height) {
		if (height == 0) height = 1;   // To prevent divide by zero
	      float aspect = (float)width / height;
	      // Set the view port (display area) to cover the entire window
	      gl.glViewport(0, 0, width, height);
	      // Setup perspective projection, with aspect ratio matches view port
	      gl.glMatrixMode(GL10.GL_PROJECTION); // Select projection matrix
	      gl.glLoadIdentity();                 // Reset projection matrix
	      // Use perspective projection
	      GLU.gluPerspective(gl, 45.0f, aspect, 0.1f, 100.0f);
	      gl.glMatrixMode(GL10.GL_MODELVIEW);  // Select model-view matrix
	      // Reset
	      // Your OpenGL|ES display re-sizing code here
	      // ......
	public void onDrawFrame(GL10 gl) {
		// Clear color and depth buffers using clear-value set earlier
	    //gl.glLoadIdentity();  // Reset model-view matrix
	    //gl.glTranslatef(0.0f, 0.0f, -6.0f);   // Translate into the screen
	    GLU.gluLookAt(gl, cameraX, cameraY, cameraZ, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
	    for(int i = 0; i < quadAmount; i++) {
	    	gl.glTranslatef(quadx[i], 0.0f, quadz[i]);
	    	if(quadz[i] > 2.0f) {
	    		quadz[i] = (float) (-20 - rand.nextInt(10));
	    			quadx[i] = (float) (Math.random() * 15);
	    			quadx[i] = (float) (Math.random() * -15);
	    	quadz[i] += 0.2f;
	    cameraX += 1.0f;
	    // Your OpenGL|ES rendering code here
	    // ......
EDIT: Now I've tried setting gluLookAt() in the bottom of the draw class, which is after gl.LoadIdentity() has been called, but no changes.

AndroidJobo is offline  
Last edited by AndroidJobo; August 28th, 2011 at 06:26 AM.
Reply With Quote
sponsored links
android, camera, glu, glulookat, java, move, opengl, perspective, translate

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 09:08 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.