Closest thing to Canvas c = new Canvas(GL.createGL())?

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Closest thing to Canvas c = new Canvas(GL.createGL())?

Postby ferose333 » Sun Jan 03, 2010 3:23 am

Hello android developers, I have a noobish question to ask about OpenGL. I'm not even sure if there is an answer.

The pseudocode below draws on a Bitmap that gets drawn to the screen:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Bitmap bitmap = new Bitmap.createBitmap();
  3.  
  4. Canvas bitmapCanvas = new Canvas(bitmap);
  5.  
  6. bitmapCanvas.drawSomething();
  7.  
  8. ...
  9.  
  10. canvas.drawBitmap(bitmap);
  11.  
  12.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


What would be the easiest way to make the drawing take place in openGL?
Something like this would be great, but I'm not too sure how openGL works yet:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. GL gl = new GL.createGL();
  3.  
  4. Canvas glCanvas = new Canvas(gl);
  5.  
  6. glCanvas.drawSomething();
  7.  
  8. ...
  9.  
  10. canvas.draw(gl);
  11.  
  12.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
ferose333
Freshman
Freshman
 
Posts: 5
Joined: Sun Aug 30, 2009 2:50 am

Top

Postby hardcoras » Sun Jan 03, 2010 1:05 pm

Canvas and opengl are two different beasts.

These is a lot of code how to draw a sprite in opengl. Take a look at http://code.google.com/p/apps-for-android/ a program called SpriteMethodTest. It contains 3 different methods to draw a sprite.
hardcoras
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Sat Nov 14, 2009 2:31 pm
Location: Lithunia

Postby ferose333 » Mon Jan 04, 2010 1:45 am

hardcoras wrote:Canvas and opengl are two different beasts.

These is a lot of code how to draw a sprite in opengl. Take a look at http://code.google.com/p/apps-for-android/ a program called SpriteMethodTest. It contains 3 different methods to draw a sprite.


Thanks for the reply. I imported the source for SpriteMethodTest using CVS. When I try running it with eclipse as an Android Applciation, I get an error saying:
An internal error occurred during: "Launching SpriteMethodTest"

The Error Log says:
java.lang.NullPointerException
ferose333
Freshman
Freshman
 
Posts: 5
Joined: Sun Aug 30, 2009 2:50 am

Postby hardcoras » Mon Jan 04, 2010 4:18 pm

Hi,

I compiled and ran this app a few weeks ago. No problems at all.

Don't be lazy to debug yourself. Or at least provide a stack trace where the error occurred.

Good luck.
hardcoras
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Sat Nov 14, 2009 2:31 pm
Location: Lithunia

Postby ferose333 » Thu Jan 07, 2010 10:07 pm

hardcoras wrote:Hi,

I compiled and ran this app a few weeks ago. No problems at all.

Don't be lazy to debug yourself. Or at least provide a stack trace where the error occurred.

Good luck.


The problem was with my device, it works now though. Thanks :)
ferose333
Freshman
Freshman
 
Posts: 5
Joined: Sun Aug 30, 2009 2:50 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests