Android : Objects look like spheres

Started by
5 comments, last by vstrakh 7 years, 2 months ago

Hi all ,

I have this strange problem : When I run the app on a device all of the objects look like spheres.What I do is develop and test it on windows and than porting it to android with ndk is simple.The first test I did on the device was with a quad and I thought .. ok it works.Then after some time when I was done with loading of the models , textures and so on I went to see how it looks on the phone and the models are rendered in the shape of a sphere.The texturing works..

It's like open gl somehow normalizes the position of my vertices.Just for testing I print the max length of the position vectors and It was 3.0f (on windows and adroid).

So I don't know what to do If any you have similar experience please tell.

The app renders with GL ES 2

dgi.

Advertisement

A screen shot will help a lot. I am curious what your models look like and how they are when displayed as spheres. It will certainly help people to help you if they can see it. It sounds to me like you are drawing the sphere each time but with a different texture so I would start by checking your other models are actually being drawn and not just a sphere over and over. Check they are loaded correctly and so on.

Do these models use different shaders? Are you doing any vertex manipulation in your shaders?

Put glGetError thrgouhout your code and investigate any errors it tells you about.

It is unlikely (though certainly not impossible) that OpenGL is turning your models to spheres.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

It just might be that you've mistyped, or messed up with input streams/attribute locations.

Vertex shader gets data for normals as inputs for vertex position.

My guess is that you've accidentally set the 'normalized' flag of glVertexAttribPointer to true.

My guess is that you've accidentally set the 'normalized' flag of glVertexAttribPointer to true.

That can't turn models into spheres. Normalization should only map integer types to [-1;1] or [0;1] ranges, linearly.

It just might be that you've mistyped, or messed up with input streams/attribute locations.

Vertex shader gets data for normals as inputs for vertex position.

Yep that was it.... I didn't call glBindAttribLocation .. I thought it was going to bind them by order but i guess not.

Thanks vstrakh :)

I thought it was going to bind them by order but i guess not.

I had one bug that surfaced only on devices with VideoCore IV gpu.

Wrong shader info was used when binding uniforms, but the bug was masked with the same order of few first uniforms in shaders.

Bug was found when VideoCore gpu driver assigned uniforms locations in reverse order. Mapping was very different then between shaders.

So, driver is free to assign locations (probably any locations, not just uniforms) in whatever way it might see fit.

This topic is closed to new replies.

Advertisement