Results 1 to 3 of 3

Thread: camera not move

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    2

    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, 8;
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    k = k + 0.02f;

    }


    Why does not it work?
    Thank you.

  2. #2
    Junior Member
    Join Date
    Dec 2012
    Posts
    2

    Re: camera not move

    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, 8;
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    k = k + 0.02f;
    }

    but I get a black screen.

  3. #3
    Member
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    61

    Re: camera not move

    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/arti...cessors-part-1

    Regards, Clay

Similar Threads

  1. move camera with keyboard function
    By marito in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 03-19-2013, 09:28 AM
  2. [Camera] Can't make the camera move appropriately
    By onion_bread in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 12-01-2011, 07:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •