i have ever tried to texture the 3d cube in android using opengl es according to the example in c++, but after several times , the result is disappointed!
so i wanna know, who have ever done it before? may you give me some suggestions?
thanks in advance!
Lesson 6 on this page has a well described Android example of showing a textured cube:
http://insanitydesign.com/wp/projects/nehe-android-ports/
Related
OpenGL ES 2.0 is implemented in a project that I have been working on with a couple shader components that define what a texture should look like after modifications from a Bitmap. The SurfaceView will only ever have a single image in it for my project.
While doing several different approaches and looking through code in the past 24 hours, just hoping for a quick response or two from the community. Not looking for solutions, I'll do that research.
It sounds as though since we are using shaders, that in order to do scaling and movements in the texture based on touch events, that I will have have to use the Matrix utilities and OpenGL translations or movements with the camera to get the same effect as what is currently done within an ImageView. Would this be the appropriate approach? Perhaps even modify the shader code so that I have some additional input variables?
I don't believe that I can use anything on the Android side that would get the same effect, such as modifying the canvas of the SurfaceView or altering dimensions of the UI in some other fashion that would achieve the same effect?
Thanks. Again, solutions for zooming and moving around aren't necessary, just trying to get a grasp on intermixing OpenGL and Android appropriately for the task.
Why does it seem that several elements in 1.0 are easier than 2.0; ease of use should improve between releases.
Yes. You will need to use an ortho projection and adjust the extents to zoom. See this link here. To pan, you can simply use a glTranslatef.
If you would like to do this entirely in the pixel shader, you can use the texture matrix stack with glScalef and glTranslatef.
I'm writing a simple 2D game on Android using OpenGL ES. The problem is that, instead of actual image for some textures only white bar is rendered.
There was neither error during loading textures nor during binding them. All the textures have power of 2 size.
I'm using extension glDrawTexfOES to draw textures.
I suspect that I might be running out of GPU memory, but how do I check that? Any other ideas?
You should enhance the code in two ways:
Set tex parameters
Set crop parameters
The analogous Android call is
((GL11) gl).glTexParameteriv(GL10.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, new int[]{0,0,100,100},0);
Amongst loads of other answers, there is one stating to just setup everything for 2D projection and draw a quad.
I'm working on a little game demo using OpenGL ES 1 and using a "BufferPool", which essentially is just a fancy interface for a direct ByteBuffer which I store all the vertex, color, and texcoord data in. I'm having some issues getting it to draw properly. I must be setting up the opengl state wrong, but I'm fairly new to OpenGL and can't tell what it is. I'd appreciate any help muchly :)
code: http://pastebin.com/bw3eM0TW
I've put it up on pastebin as there's a fair amount of code related to the BufferPool and rendering.
Hey all,
I'm writing a little 3D engine for android to better learn the platform and opengl. I hope to eventually use it as a base for little 3D games.
I'm trying to implement lighting right now, and generally following the NeHe opengl android port tutorials. I have a simple spinning cube and 1 light that should not change position. Upon rendering my scene on a device the light appears to "dim" and re-lighten as cube rotates.
This is a swf video of the behavior:
http://drop.io/obzfq4g
The code for my "engine" is located here: http://github.com/mlasky/Smashout-Android-3D-Engine/
The relevant bits are:
http://github.com/mlasky/Smashout-Android-3D-Engine/blob/master/src/com/supernovamobile/smashout/SmashoutGLRenderer.java
this is where I'm initializing opengl and setting up my scene.
and
http://github.com/mlasky/Smashout-Android-3D-Engine/blob/master/src/com/supernovamobile/smashout/SMMesh.java
this is the code for actually rotating / drawing the cube mesh.
I wish I could formulate a better question; but I'm very stuck/confused and can't even think of an intelligent question to ask besides "does anyone know what might cause the kind of behavior I'm seeing?"
Thanks for any help you can provide.
Edit: Also the slowness / choppyness of the animation in the video is a result of the screencap software. It's smooth throughout the whole rotation on the emu.
From the video it looks like your normals are incorrect.
For an axis-aligned cube the normals in cube.xml seem off. They should be axis-aligned, not whatever they are. Where did you get the model?
This answer may also be related if mVNormalsBuffer is empty.
You are using
gl.glNormalPointer(3, GL10.GL_FLOAT, mVNormalsBuffer);
wrong.
It should be:
gl.glNormalPointer(GL10.GL_FLOAT,0, mVNormalsBuffer);
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.