How to draw 2d and 3d text using opengl in android? - android

First up all sorry for my English.
I started learning the opengl in android by reffering following link
http://developer.android.com/guide/topics/graphics/opengl.html
and also about drawing shapes by refering these
links
http://developer.android.com/training/graphics/opengl/draw.html
http://obviam.net/index.php/opengl-es-android-displaying-graphical-elements-primitives/
Now i turned to drawing 2d and 3d text using opengl in android but coluld not foun an perfect link for providing solution for drawing 2d and 3d text.

If you want the text outside your OpenGL viewing area, you can place your GLSurfaceView within a layout, with the text in the other controls. This is the simplest option.
To place text within the GLSurfaceView, you either draw the individual characters as 3D ojbects and place them appropriately, or create a bitmap with the text you want and use it as the texture for a flat surface which you draw as part of your scene.

Related

Android OpenGL ES - ingame scoreboard

I am currently working on an Android OpenGL ES 2.0 2D game and I need to implement scrolling scoreboard, something like this:
but when there are so many players they overflow from the specified region (white). When I implement scrolling (using Matrix translation), the same problem happens on top of the list. Anyone can help me?
One approach is to use the scissor test to limit where drawing occurs. Set the scissor with glScissor(), enable it with glEnable(GL_SCISSOR_TEST), draw the text, and disable it with glDisable(GL_SCISSOR_TEST).
Note the scissor is specified in window coordinates.
Another approach would be to arrange the drawing such that the blue border is drawn on top of the text, either by setting the depth or drawing it last. (This assumes you're not drawing it with glClear().)

How to project a picture onto a bubble surface programmatically

I want to implement an effect that, showing a picture on a bubble surface with the picture looks like surrounding the bubble surface. But I don't know how to do this kind of things...
I am doing it in Android platform, should I use OpenGL ES for this ? Or just some 2D transformation can achieve this effect ?
One more question is, I want to create many interesting graphics effects like the PhotoShop's various filter, is there any books/articles I can refer for this kind of things ? Is this kind of work belongs to the "Digital Image Processing" field or some other computer graphics related fields ?
Or just some 2D transformation
This effect is a nonlinear transformation, so doing through the 2D (linear) transformations being available will not work. You can do it using OpenGL by numerous ways. I'm currently thinking about some easy to understand way to convey, what you need to do. Basically you need to implement some kind of refraction or nonlinear radial warp.
Say p is the center of your bubble (in 2D), and r the position relative to p, then the undistorted picture is given by r+p. Now you want to distort it toward the edges. A parabolic distortion comes to mid, i.e. instead of r+p you'd show the pixel r + (|p|^2)*p/|p|

Drawing a 3d object inside a 3d object using java opengl1.0 for android

I have a 3D cube created using GL_TRIANGLE_STRIP.Is it possible to draw points(using GL_POINTS) or a triangle (using GL_TRIANGLE) on/inside my 3D Cube?How could that be achieved?
If you want to draw something directly of the face of another object (by using the exact same vertex coordinates), you will need to use glPolygonOffset to prevent stitching. There is a chapter in the Red Book that explains it.
If by inside you mean to draw something in the volume of the cube, than there is nothing stopping you. You just need to get the alpha values and blending right to actually see through the cube. Look for some generic tutorial on transparency in OpenGL.
But maybe I'm horribly mistaken and what you are looking for a textures.
If I understand you correctly you could just generate the appropriate texture with the points and apply it to the cube.

Android: how to have an animation on top of a background image

What I'm trying to do is have a background image, for sake of simplicity, lets say it's a picture of the front of a house. Then, I want to have a red ball move from window to window.
**I want to have a background picture, and a picture on top of it.
**I then want to be able to tell the top picture EXACTLY where to go.
How can I do this?
I'm just beginning to learn about animations in Android, and have not yet run across any way to do this.
There are two routes to animation in android: Canvas and OpenGL ES.
I would recommend OpenGL for anything requiring smoothness and speed, like a moving ball.
You should create a view using the helper class GLSurfaceView
http://android-developers.blogspot.com/2009/04/introducing-glsurfaceview.html, and implement a Renderer.
I assume you have the images saved in your res/drawable folders, in a format like png and the ball file contains an alpha channel.
You can see many tutorials online, but basically you need to load your background image and your ball resource at onSurfaceCreated and store it in a texture using GLUtils.texImage2D.
In the onDrawFrame method, you should set up a 2D projection such as glOrtho2D, then draw the background.
Then just before you draw the ball texture, you can use the glTranslate(x,y,0) function to move the ball over the house. Use an alpha blend for the ball:
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ONE_MINUS_ALPHA);
glEnable(GL_BLEND);
Unfortunately writing in OpenGL isn't as straightforward as you might hope. Everything is done with 3D coordinates, despite the fact you want only a 2D image. But hopefully this gives you enough info to google for good exmaples, which are abundant!

Changing texture brightness on Android in Opengl-es

Firstly I must say I'm green as grass in opengl subject.
I'm writing simple 2-d game for android using opengl-es. I use GL11Ext.glDrawTexfOES() to draw the textures (just like in one sample code named 'sprite-method-test'), and gl.glColor4f to color them (and set transparency). But I'm completely helpless if I need apply some brightness or contrast to the rendering texture.
I really appreciate any help.

Categories

Resources