Canvas.drawText in combination with OpenGL|ES 1.0

Problems with Canvas, OpenGL, etc...

Canvas.drawText in combination with OpenGL|ES 1.0

Postby LukasBanana » Tue Mar 08, 2011 9:10 pm

Hi folks,
I'm new here since I'm creating my first serious Android App using OpenGL|ES 1.0. I'm actually comming from C++ with OpenGL 2.0, Direct3D9 etc. on PCs.
So my first question is about the drawText of the Canvas class using in combination with GL10.
Actually it looks pretty good but only on the emulator. On my Galaxy S the text is not visible, just the rectangular area in the color, the text is to be drawn.
This is my code, maybe I did something wrong so that it only runs correct on the emulator.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. /* Initialization */
  2. int width = 256;
  3. int height = 32;
  4. String text = "Test string";
  5. int size = 32;
  6. int[] textureName = new int[1];
  7.  
  8. /* ... generate OpenGL texture etc. ... */
  9.  
  10. /* Create an empty, mutable bitmap */
  11. Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  12.  
  13. Canvas canvas = new Canvas(bitmap);
  14. bitmap.eraseColor(0);
  15.  
  16. /* Create the paint object */
  17. Paint paint = new Paint();
  18.  
  19. /* Draw transparent background */
  20. paint.setColor(Color.TRANSPARENT);
  21. paint.setStyle(Style.FILL);
  22. canvas.drawPaint(paint);
  23.  
  24. /* Draw the text */
  25. paint.setColor(Color.WHITE);
  26. paint.setTextSize(size);
  27. paint.setAntiAlias(true);
  28. canvas.drawText(text, 0, (float)size, paint);
  29.  
  30. /* Create the texture finally */
  31. gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName[0]);
  32. gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
  33. gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
  34.  
  35. GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
  36.  
  37. bitmap.recycle();
  38.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


I hope you can help me :)
greetings,
Lukas
LukasBanana
Freshman
Freshman
 
Posts: 7
Joined: Tue Mar 08, 2011 9:01 pm

Top

Re: Canvas.drawText in combination with OpenGL|ES 1.0

Postby mohammad_talha » Tue Jul 12, 2011 4:04 pm

Could you figure it out Lukas ? I see nothing on the screen.
mohammad_talha
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jul 12, 2011 4:02 pm

Re: Canvas.drawText in combination with OpenGL|ES 1.0

Postby bxm » Sun Jul 24, 2011 12:09 am

Beyond the fact that I'm assuming you are drawing elsewhere, try shrinking the font some. Perhaps it doesn't like that you are trying to begin drawing on the edge of the bitmap since it goes up.
bxm
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue May 10, 2011 2:51 am

Top

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

Who is online

Users browsing this forum: No registered users and 1 guest