OpenGL is not supported by the Canvas.

On Oct 12, 2008 5:11 PM, "sandroid" <[EMAIL PROTECTED]> wrote:


I just found another useful trick.  Originally I wanted to use OpenGL
because the ModelView matrix makes it very easy to rotate objects in
3D.  I found something very similar in android.graphics.camera which
has three different routines for rotating (RotateX, RotateY, and
RotateZ).  Here is the code snippet from my project

// Member variables at top of class
private float mYaw   = 0;        // Set these to whatever you like
private float mRoll  = 0;
private float mPitch = 0;
private Camera mCamera = new Camera();

@Override
protected void dispatchDraw(Canvas canvas) {
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    // Save the current Camera matrix
    mCamera.save();

    // Setup the camera rotations
    mCamera.rotateZ(-mYaw);
    mCamera.rotateY(-mRoll);
    mCamera.rotateX(-mPitch);

    // Output the camera rotations to a matrix
    mCamera.getMatrix(mMatrix);
    mCamera.restore();

    // Perform some other transforms on the matrix
    mMatrix.preTranslate(-getWidth() * 0.5f, -getHeight() * 0.5f);
    mMatrix.postTranslate(getWidth() * 0.5f,  getHeight() * 0.5f);

    // Apply the matrix to the canvas
    canvas.concat(mMatrix);

    // This code is from the MapViewCompassDemo
    mCanvas.delegate = canvas;
    super.dispatchDraw(mCanvas);

    canvas.restore();
}

There you have it.

Romain Guy, do you mean that OpenGL is not supported in the Canvas
class?  Surely it is still useful for rendering textures.

Also, does anyone know what sort of GPU hardware (if any) will be in
the G1?

-Marc

On Oct 12, 4:38 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote: > Rendering 
to OpenGL is a feature t...

> On Oct 12, 2008 4:33 PM, "sandroid" <[EMAIL PROTECTED]> wrote: > > 
Yes, I'm getting some good ...

--~--~---------~--~----~------------~-------~--~----~ You received this 
message because you are subs...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to