Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7041129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:00:03+00:00 2026-05-28T02:00:03+00:00

Im trying to make a basic shape ( Hexigon ) to start and learn

  • 0

Im trying to make a basic shape ( Hexigon ) to start and learn some basics about OpenGL on the Android platform and i have a little problem.

I have successfully made a pointy Hexagon, but when i convert it into a flat Hexygon it doesnt render correctly. Here is some code, for you guys to figure out the problem ( probably a easy fix.. )

vertices / indices

//flat hexagon
private float verticesFlat[] = {     
    0.0f,   0.0f, 0.0f,    //center
    -0.5f,   1.0f, 0.0f,    // left top
    0.5f,   1.0f, 0.0f,    // right top
    1.0f,   0.0f, 0.0f,    // right
    0.5f,   1.0f, 0.0f,    // right bottom
    -0.5f,  -1.0f, 0.0f,    // left bottom
    -1.0f,   0.0f, 0.0f,     // left
};

private short[] indices = { 0, 1, 2, 3, 4, 5, 6, 1 };

standard vertex / index Buffers..

// a float is 4 bytes, therefore we multiply the number if
// vertices with 4.
ByteBuffer vbb = ByteBuffer.allocateDirect(verticesFlat.length * 4);
vbb.order(ByteOrder.nativeOrder());
vertexBuffer = vbb.asFloatBuffer();
vertexBuffer.put(verticesFlat);
vertexBuffer.position(0);

// short is 2 bytes, therefore we multiply the number if
// vertices with 2.
ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
ibb.order(ByteOrder.nativeOrder());
indexBuffer = ibb.asShortBuffer();
indexBuffer.put(indices);
indexBuffer.position(0);

The onDraw(GL10 gl):

gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();

GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);    

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glDrawElements(GL10.GL_TRIANGLE_FAN, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

The result im getting is illustrated in the image below:

Wrong rendering of hexagon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:00:04+00:00Added an answer on May 28, 2026 at 2:00 am

    Should be

    private float verticesFlat[] = {     
        0.0f,   0.0f, 0.0f,    //center
        -0.5f,   1.0f, 0.0f,    // left top
        0.5f,   1.0f, 0.0f,    // right top
        1.0f,   0.0f, 0.0f,    // right
        0.5f,   -1.0f, 0.0f,    // right bottom (notice sign)
        -0.5f,  -1.0f, 0.0f,    // left bottom
        -1.0f,   0.0f, 0.0f,     // left
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make my own website and only know some basic HTML,
I'm just trying to make sense of a basic Android navigation-related question, namely How
I am trying to make LDAP queries via Visual Basic. I don't have administrator
Hey, I'm trying to make a basic hockey style game. I have the basic
I am trying to make a basic java console based menu system. I have
I have just started developing in Android and I am trying to make a
I've been trying to make a basic XOR header file for use in some
So I'm currently trying to make a project using ravendb. And some basic moving
I'm trying to make a basic multiprocessing task and this is what I have.
I have a problem with understanding of some basic OOP concepts. I'll try to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.