Android :: Easiest Way To Draw Texture With OpenGL ES?
Feb 6, 2010the draw_texture function is the fastest and VBO is 2nd faster. But I don't understand how to use it(the draw_texture method or the VBO way).
View 2 Repliesthe draw_texture function is the fastest and VBO is 2nd faster. But I don't understand how to use it(the draw_texture method or the VBO way).
View 2 RepliesI'm having great difficulty getting basic textures to work in an OpenGL ES app on my Droid (2.1-update1). I trying to render a simple textured quad - four vertices, two faces, with normals and texture coords. When rendered, the texture is garbled and full of static, similar to TV noise. The basic colors from the texture map are there, but obviously the texture isn't being read or applied correctly. My texture load sequence is simple : int[] textures = new int[1]; gl.glGenTextures(1, textures, 0); Bitmap bmp = BitmapFactory.decodeResource(cx.getResources(), R.drawable.img); gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);...
View 2 Replies View RelatedI took the source from API demos (TriangleRenderer.java) Here's the code on how textures are loaded in onSurfaceCreated():.....................
View 3 Replies View RelatedI have a texture with 8 equally sized stripes that I am using as a wall with OpenGL. On my Nexus One it scales it properly However, in emulators and on a G1 (and probably on other hardware), it does not scale properly, as the stripes remain the same width, while the height scales as it should. Is there an option that I need to set that is set to default on my nexus one but not on other platforms?
View 3 Replies View RelatedI'm trying to set the transparency of a texture on a quad in opengl, playing with the blend functions didn't help neither did anything on google.
View 2 Replies View RelatedI am writing a small app that at the moment generates a random map of textures. I am drawing this map as a 10 x 15 group of "quads" which are infact all triangle strips. I use the "map" to grab an int which I then take as the location of the texture for this square in the textureAtlas. so for example 0 is the bottom left "tile". The atlas is 128 x 128 and split into 32 pixel tiles.
However I seem to be getting some odd artifacts where the texture from the one tile is creeping in to the next tile. I wondered if it was the image itself but as far as I can tell the pixels are exactly where they should be. I then looked at the texture coords I was specifying but they all look exact (0.0, 0.25, 0.5, 0.75, 1.0 - splitting it into the 4 rows and columns I would expect). The odd thing is if I run it on the emulator I do not get any artifacts.
Is there a setting I am missing which would cause bleeding of 1 pixel? It seemed to only be vertical too - this could be related to on the phone I am "stretching" the image in that direction as the phone's screen is larger than normal in that direction..............
The following is piece of code in which I'm trying to draw 3 pieces of my background using glDrawTexfOES. The 3 pieces should look like green grass.
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glFrontFace(GL10.GL_CW);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glBindTexture(GL10.GL_TEXTURE_2D, grass);
gl.glColor4x(0x10000, 0x00000, 0x10000, 0x10000);
((GL11Ext) gl).glDrawTexfOES(0.0f, 0.0f, -8.0f, 32, 32);
((GL11Ext) gl).glDrawTexfOES(32.0f, 0.0f, -8.0f, 32, 32);
((GL11Ext) gl).glDrawTexfOES(64.0f, 0.0f, -8.0f, 32, 32);
}
why my textures won't display correctly would be most appreciated! On a related note, for building a simple 2D tiled game is glDrawTexfOES the most efficient method for generating the tiled background?
I've googled around everywhere, but cannot find much for rendering strings to textures and then displaying that texture on a quad on the screen. Can someone provide a run-down on the process or provide good resources that describe how? Is rendering strings to textures even the best method for displaying text in an Android OpenGL ES app?
Okay, so LabelMaker interferes with alpha blending, the texture (created from a PNG with a transparent background) now has a solid black background, rather than a transparent background. If I comment out all the LabelMaker-related code, it works fine.
UPDATE:
Nevermind. I took a look at the code to find that LabelMaker was disabling blending after drawing the labels.
I'm trying to create a 1024x1024 texture in OpenGL. I'm trying to do this with Bitmap bmp = Bitmap.createBitmap(1024, 1024, Bitmap.Config.ARGB_8888); GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0); But I can't actually create a 1024x1024 Bitmap - I get an out of memory exception.
I want to generate the texture, then use texSubImage2D to copy on various smaller bitmaps, but it seems that I need to somehow define that the texture is 1024x1024 before I can do that. Is there a function that lets me define the size/argb settings without just copying in a blank bitmap?
I'm converting an app I've written from Canvas to OpenGL, and not having too hard of a time yet. However, I've run into one snag that I can't seem to get around. My old app was threading image loads, because there are a ton of them, however, it looks like the OpenGL implementation protects itself to a single thread. I have a basic loadBitmap() function as follows:...............
View 4 Replies View RelatedI'm drawing 5 rectangles with OpenGL. They are texture mapped, and use the following parameters/binding:
..................
When I start the activity, the shapes all flash as if the textures were supposed to wrap (ie, i see more than one texture per shape), then the screen quickly corrects itself. Is there some manual buffering I'm supposed to do while the textures get mapped and unwrapped?
I have an Android application that displays VGA (640x480) frames using OpenGL ES. The application reads each frame from a movie file and updates the texture accordingly. My problem is that, it is taking almost 30 ms. to draw each frame using OpenGL. Similar test using the Canvas/drawBitmap was around 6 ms on the same device. I'm following the same OpenGL calls that VLC Media Player is using, so I'm assuming that those are optimized for this purpose.
View 1 Replies View RelatedI am very new to OpenGL ES. I am implementing some demo app to load multiple textures on the screen. For demo purpose I have loaded 2 textures in 2 different locations on the screen using glTranslatef() and glBindTextures() twice. Now I am able to see 2 different images on the screen. Now I want to move one particular texture across the screen using mouse.
View 2 Replies View RelatedI'm using OpenGL ES to display some objects exported from Blender. Blender provides a list of vertices, a list of the face indices and a list of the 2d texture co-ordinates. Within Blender, and I believe generally in OpenGL, the texture co-ordinates map to each vertex described in the index array.
I suppose I have two questions:
I'm given to understand(see the "Applying Textures" section) that in OpenGL ES the texture co-ordinates map to the vertex buffer only, not the index buffer. Is this the case or is there a way of binding the texture co-ords to the index buffer instead?
If the above is true, is there anything to be gained from using an index buffer at all? After all to properly map the textures one will need to write out the vertex buffer with all the redundancy that would have been saved with the index buffer. Is there still a performance increase to be gained or are index buffers redundant for textured data?
I'm having a problem with textures in my live wallpaper. I think its something I'm doing or not doing in blender when I bake my UV images... I get the app running just fine. But the textures are scrambled up on my model in the live wallpaper app... Here's a tester live wallpaper I built to show the problem I'm having... Three UV sphere the top one is post to be blue, the middle green, and the bottom is red inside blender. But after baking, this is what they turn out like in my live wallpaper... Here's a link to snap shots to the live wallpaper with the three sphere's..URL....
View 9 Replies View RelatedI've run into a very strange problem regarding OpenGL texture outputs, which only occurs when the app is resumed (particularly when leaving after pressing Home, and going back into the app).I'm not sure how or why, but it appears to be that it's reading bitrate of the pixels incorrect, or something else entirely. Furthermore, this issue only occurs on the device itself (testing on my G1/Dream), not on the emulator.Code as well as example screenshots in the zip file show exactly what I'm talking about. And to completely replicate the issue I've included the 2D sprite object framework I've developed for OpenGL so the situation is exactly the same as what I've run across when developing my game, so if it's somehow an issue in my framework you may be able to spot it.
View 6 Replies View RelatedIn my application, I have a NDK native code that uses OpenGL 1.0 to apply a texture to a rectangle in order to draw an image on the screen. It is working fine on the emulator, but when I test it on the HTC HERO android device, it only draws a white rectangle without texture. Anybody else had the same problem? Did anybody find a solution?
Here is how I initialize openGL in native code:
CODE:............
And here is how I draw the frame in native code:
CODE:..................
Working through some OpenGL-ES tutorials, using the Android emulator. I've gotten up to texture mapping and am having some trouble mapping to a cube. Is it possible to map a texture to all faces of a cube that has 8 vertices and 12 triangles for the 6 faces as described below?
// Use half as we are going for a 0,0,0 centre.
width /= 2;
height /= 2;
depth /= 2;
float vertices[] = { -width, -height, depth, // 0
width, -height, depth, // 1
width, height, depth, // 2......................
I'm developing an openGL-enabled live wallpaper and it seems to work fine on the Nexus but I've had someone tell me that on their Milestone (basically a GSM Droid), all the textures are white. I only have a Nexus to test with. I've done lots of Googling on the issue and the big thing that seems to come up most is having power of two sized textures - which I have. I also put them in the /res/drawable-nodpi folder and set my manifest to all screen sizes/densities. At one point, I thought maybe it was the way I was implementing mipmaps so I turned them off. No dice. I'm sure it's something simple that I'm overlooking but my brain is completely fried at this point.
My texture loader:................
All the textures I create from my resource files are fine, but when I create a texture in the following way... <code> mOverlay = Bitmap.createBitmap((int)mWidth, (int)mHeight, Bitmap.Config.ARGB_4444); mOverlay.eraseColor(0); mOverlayCanvas = new Canvas(mOverlay);
...
Canvas c = mOverlayCanvas; c.drawColor(Color.argb(0, 0, 0, 0)); Paint p = new Paint(); p.setColor(Color.RED); c.drawCircle(160, 240, 10, p);
....................
I'm developing on Android with OpenGL ES, I draw some cubes and I change their colors with glColor4f. Now, what I want is to give a more realistic effect on the cubes, so I create a monochromatic 8bit depth, 64x64 pixel size PNG file. I loaded on a texture, and here is my problem, which is the way to combine the color and the texture to get a colorized and textured cubes onto the screen?
I'm not an expert on OpenGL, I tried this:
On create:...................................
I'm mapping a texture from my texture atlas to a square on a cube. For some reason, the t axis is inverted with 0 being at the top and 1 being at the bottom. Any ideas why this is happening? Also, I have to specify the texture coordinates in clockwise order rather than counter-clockwise. I am using counter-clockwise windings. The vertices, indices and texture coordinates I'm using are below.
float vertices[] = {
// Front face
-width, -height, depth, // 0
width, -height, depth, // 1
width, height, depth, // 2
-width, height, depth, // 3...............
I'm trying to get the preview images of the android Camera onto a opengl texture. I have been successful so far, it works most of the times. Though sometimes I will just get a black screen when starting/ resuming the application. I have been debugging for days, not finding any clue. When debugging I noticed that both the camera callback and the onDrawFrame are called in such situations. the bytearray of the camera does contain data.
View 10 Replies View RelatedI'm having great difficulty getting basic textures to work in an OpenGL ES app on my Droid (2.1-update1). I trying to render a simple textured quad - four vertices, two faces, with normals and texture coords. When rendered, the texture is garbled and full of static, similar to TV noise. Here's a pic showing the original texture map image, and then a screencap from my droid of the rendered textured quad. The basic colors are there, but obviously the texture isn't being read or applied correctly.
View 1 Replies View RelatedI have a byte array of RGB values, just like the contents(without header) of a *.bmp file. What I want to do is, draw the corresponding bitmap on Android, using OpenGL.
It seems that OpenGL ES doesn't have a single API that will do, it true?
If true, how can I do this?
Actually, I can draw it in JAVA code, but it's too slow and costs too much CPU time. So I want to try drawing it with OpenGL. Is there any other advises? Or maybe OpenGL can't be the right answer?
I'm currently developing a small OpenGL game for the Android platform and I wonder if there's an easy way to render text on top of the rendered frame (like a HUD with the player´s score etc). The text would need to use a custom font also. I've seen an example using a View as an overlay, but I don't know if I want to do that since I might want to port the game to other platforms later.
View 4 Replies View RelatedIs it possible to draw a png image and then to run opengl operations on it with android? Is this the right forum to ask this? where can i get more information on doing such stuff?
View 2 Replies View RelatedHow to draw different types of lines like thick line, dashed line etc using opengl android?
View 6 Replies View RelatedHow I can draw a sphere with opengl es in android?
View 1 Replies View RelatedI'm making a game for android where I need to draw a lot of points that change position every frame. I use the ndk to get faster processing performance of the math/physics section of the game, so I need to use OpenGL to get the fastest performance. Right now, I make a texture every frame out of an array that holds the colors of every pixel. I am only able to get ~10 frames per second with this method. Is there anyway I could speed this up? ...
View 2 Replies View Related