Jump to content
  • Advertisement
Sign in to follow this  

My object isn't entirely drawn

This topic is 2597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am doing simple experiments with GL on Android. I want to draw a Monkey (it's a Blender's primitive), without colors, lighting, etc only the triangles. Here is what I get

Uploaded with ImageShack.us

I turned backface culling off, but nothing changes. If I draw a cylinder, only the two faces are drawn - actually not entirely, they seem Pacman head
Can somebody explain this? I can give the code, even if it's very simple and it's Android specific

Share this post

Link to post
Share on other sites

This happens if I draw a cube or a cylinder. Please help me

Short anwser : backface culling.
Try to add this before rendering : "glDisable(GL_CULL_FACE);"

Share this post

Link to post

This happens if I draw a cube or a cylinder. Please help me

Ok, I replied a bit to quickly, didn't see that you already disabled backface culling ^^'
If you post the piece of code which renders your models, I think it'll be easier for people to spot what might go wrong.

Share this post

Link to post
Share on other sites
[color=#666666][font=Arial, Helvetica, sans-serif]Here is the whole Eclipse project[/font]

This is the renderer code. Quite basic. Obviusly this is specific to Java language and Android development

public class TwoRobotsRenderer implements Renderer {
ShortBuffer mIndexBuffer;
FloatBuffer mVertexBuffer;
int triangleCount;
float seek;

public TwoRobotsRenderer(Context ctx) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(ctx.getAssets().open("two_robots.txt")));
int vertsLines = Integer.parseInt(in.readLine());
int indicesLines = Integer.parseInt(in.readLine());
triangleCount = indicesLines;
float[] vertsArray = new float[vertsLines * 3];
for (int i = 0; i < vertsLines; i++) {
String[] lines = in.readLine().split("\\s+");
vertsArray[i * 3] = Float.parseFloat(lines[0]);
vertsArray[i * 3 + 1] = Float.parseFloat(lines[1]);
vertsArray[i * 3 + 2] = Float.parseFloat(lines[2]);
ByteBuffer bb = ByteBuffer.allocateDirect(vertsArray.length * 4);
mVertexBuffer = bb.asFloatBuffer();
mVertexBuffer = FloatBuffer.wrap(vertsArray);
short[] indicesArray = new short[indicesLines * 3];
for (int i = 0; i < indicesLines; i++){
String[] lines = in.readLine().split("\\s+");
indicesArray[i * 3] = Short.parseShort(lines[0]);
indicesArray[i * 3 + 1] = Short.parseShort(lines[1]);
indicesArray[i * 3 + 2] = Short.parseShort(lines[2]);
bb = ByteBuffer.allocateDirect(indicesArray.length * 2);
mIndexBuffer = bb.asShortBuffer();
mIndexBuffer = ShortBuffer.wrap(indicesArray);

float mAngle = 0.0f;
float mAngleX = 0.0f;
float mAngleY = 0.0f;
float mAngleZ = 0.0f;
public void onDrawFrame(GL10 gl) {
gl.glTranslatef(0, 0, seek);
gl.glRotatef(mAngle += 6, mAngleX += 5, mAngleY +=7, mAngleZ += 10);


// Draw calls
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
gl.glDrawElements(GL10.GL_TRIANGLES, triangleCount, GL10.GL_UNSIGNED_SHORT, mIndexBuffer);

public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);

* Set our projection matrix. This doesn't have to be done
* each time we draw, but usually a new projection needs to
* be set when the viewport is resized.

float ratio = (float) width / height;
gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
* By default, OpenGL enables features that improve quality
* but reduce performance. One might want to tweak that
* especially on software renderer.

* Some one-time OpenGL initialization can be made here
* probably based on features of this particular context



Attached is the same Eclipse project if someone has problems accessing Filefactory

Share this post

Link to post
Share on other sites
In the code pasted cull facing isn't disabled, but I can assure I played with it and nothing changes. Obviously there could be something wrong with my Blender exporter or my model importer; but actually how can one test it?

The code is GL ES 1.x (fixed pipeline)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!