opengl-es

In opengl, How can I get relation between pixels and gl.gltranslatef(floatx,y,z)?

Hi all, I am trying to learn opengl stuff on Android. In the gl.gltranslatef(x,y,z) call, I am shifting my texture by some units in the +ve x direction. But I am unable to find the number of pixels does 1 unit of x belong to? Here is what I am doing: I call gl.glviewport(0,0,width,height); // This will set my rectangle with 0,0 as lowe...

Offsets for per vertex data interleaved in OpenGL ES on Android

Is it possible to use per vertex data interleaved in OpenGL ES on Android? I'm unable to get the correct offset pointers for the normal and color members. In C++ I would do something like this: struct ColoredVertexData3D{ Vertex3D vertex; Vector3D normal; ColorRGBA color; }; const ColoredVertexData3D vertexData[] ...

Easiest, fastest way to render UIImage/PNG using OpenGL on iPhone?

I've written an iPhone application that takes input from a user and updates a bitmap context based on the input. After the update, it then updates the display of a UIView. I am accomplishing such by implementing drawRect in a UIView subclass. Currently I am using Quartz 2D. Given that the updates are occurring multiple times per second,...

Most efficient way to draw multiple identical objects?

I would like to make a game out of many cubes and am planning on putting it on mobile platforms and also on the web using webgl. My problem is when I make a drawelements call per cube I take a hit on the frame rate. Is there a way I can make a single draw call to opengl es to draw them? The only difference between the cubes would be pos...

Rotate individual polygons in an Open GL vertex array?

I am working on a game for Android using OpenGL ES, and I have run into a performance problem. What I am trying to do: I have a bunch of objects on screen that all share the same mesh, but all have individual rotations and translations. You could compare it to Asteroids where you have a bunch of asteroids moving around on screen. The a...

Mapping textures to a sphere OpenGL ES

Hi All, Right i am just getting into OpenGL ES, and if i am honest it is very daunting. Just need a little guidance to point me in the right direction for my current challenge. I have some code that produces a 3D sphere, that has a texture mapped on to it (A Globe). I can get the touch co-ordinates on the sphere, and have a handle o...

Problem with OpenGL and bitmap

I'm loading a bitmap into OpenGL on Android with texImage2D. The problem is that I have to create a new bitmap, and paint the old bitmap into the new one, before I load it. See the example to get a better feel for what i mean. Generating the bitmap in this way doesn't work: Bitmap bitmap = BitmapFactory.decodeResource(context....

efficient sprite rendering opengl es 2.0

Hi there! I am working on ipad app that renders hundreds of sprites (2d images) each frame. I am using modified drawing method taken from sdk's opengl template but problem is, I got only 3fps and I am not even rendering everything I need. I tried simple optimization methods like using texture atlases, minimizing number of state change...

Rotating textures when using glDrawTexiOES

I created a little texture drawing class from observing the LabelMaker example in the Android SDK. One thing I can't find however is how to rotate textures drawn with glDrawTexiOES. is it possible? I've just tried glRotatef but it has no effect. ...

How to set background colour on Open GL ES Android

I am currently playing about with lesson 08 here http://insanitydesign.com/wp/projects/nehe-android-ports/ I would like to change the background colour from black to white. In order to do this at the start of onDrawFrame() I have called gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f); This does indeed set a white background screen, but als...

How would you pass an OBJ files face definitions to openGL

I've written an OBJ loader which parses the vertices, texture coords, and normals, each are stored in a FloatBuffer, and passed to opengl: gl.glVertexPointer(3, GL10.GL_FLOAT, 0, fbVertices); gl.glNormalPointer(GL10.GL_FLOAT, 0, fbNormals); However I am stumped as to how i am supposed to pass my index buffer to glDrawElements, I've re...

Spinning globe in Opengl-es

I found this code to generate a sphere in Opengl es. I am unable to understand the logic, could someone please give me some insights on this. private void generateData() { slicesBuffers = new FloatBuffer[slices]; normalsBuffers = new FloatBuffer[slices]; texCoordsBuffers = new FloatBuffer[slices]; ...

How to texture an image onto a sphere without distortion

I have drawn a sphere and I am able to rotate it using java and opengl libraries for an android application. This part works perfectly. Now I am trying to texture a globe image onto the sphere. The image covers the entire sphere but then the continents are compressed and appear as a single line. What do I have to do to get the image prop...

Color picking on android - glReadPixels rounding errors

I am using color picking in opengl es on android and i am calculating a color key to compare it to the values i get from glReadPixels: ByteBuffer PixelBuffer = ByteBuffer.allocateDirect(4); PixelBuffer.order(ByteOrder.nativeOrder()); gl.glReadPixels(x, y, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, PixelBuffer); byte b[] = new byte[4]; P...

How do I get the size of a VBO in OpenGL-ES?

I was sending vertex arrays (of 32 bit floats) to the GPU every time I wanted to draw them, but this wasn't efficient, so I switched to Vertex Buffer Objects to cache my vertex arrays in the GPU. It's working, but I was wondering if there's a way to determine the size of a given VBO later on without going back to the original vertex ar...

How do you use OpenGLES to open an image file, do some work, then save the image file, in the background (offline)?

So I'd like to create a class that accepts a CGImage from an image file I just read from disk, does work on that image texture (color transformations) then returns the texture as a CGImage and does all this in the background w/out drawing to screen. I've looked at Apple's demo app on GLImageProcessing but it draws all the processing to ...

Image Resource aren't rotated in Landscape with Android

Hi all this one surely is a simple one but I haven't made sense of is yet. I'm working on an app in opengl es on android everything goes well except when I load the textures. I manage to open load and create all the textures without any problem, but the image displays itself rotated of 90. it looks as if the application does not cons...

2D graphics on iPhone

What I want to achieve: Drawing png files with alpha exactly as it appears originally, without transforming any pixel. This is because the image is very detailed and I don't want to lose any bit of information. Animating those images by rotating them and moving. No scaling. Actually I don't want to use any 3rd party libraries like c...

Android GLSurfaceView with drawable background

I have a GLSurfaceView with a drawable as background, however only the background is visible when rendered without surfaceView.setZOrderOnTop(true) I need to avoid using setZOrderOnTop(true) because there are static TextView's being used on top of the GLSurfaceView. Any suggestions for getting this to work? ...

Drawing a smaller texture on a larger OpenGL texture on iPhone

I am very new to OpenGL and this is what my goal is... Load a texture from an image. Load another texture which is much smaller than the first one. Now keep drawing the smaller texture on the larger one on some chain of events, like painting on the larger texture. Can somebody point me to some material which might help do this? I lo...