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

  • SEARCH
  • Home
  • 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 4594548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:50:37+00:00 2026-05-21T22:50:37+00:00

EDIT SOLUTION: A cylinder in openGL ES: ///Storing a cylinder in a VBO int

  • 0

EDIT SOLUTION:
A cylinder in openGL ES:


///Storing a cylinder in a VBO
int verticesCyl = 60;
int indicesCyl = verticesCyl + 2;
float cylHeight = .2f;

void initCylinder(GL10 gl) {
        GL11 gl11 = (GL11) gl;
        FloatBuffer vertBuffer = ByteBuffer.allocateDirect(verticesCyl * 3 * 
                4).order(ByteOrder.nativeOrder())
                .asFloatBuffer();
        ShortBuffer indexBuffer = ByteBuffer.allocateDirect(indicesCyl *               2).order(ByteOrder.nativeOrder())
                .asShortBuffer();

        float vertices[] = new float[verticesCyl * 3];
        short indices[] = new short[indicesCyl];
        for (int j = 0; j < verticesCyl*3 ; j+=3) {
            vertices[j] = (float) (Math.cos(theta));
            vertices[j+1] = (float) (Math.sin(theta));
            vertices[j+2] = j % 2 == 0 ? cylHeight : -cylHeight;
            theta += 2 * Math.PI / (verticesCyl);
        }

        for (int j = 0; j < indicesCyl; j++) {
                indices[j] = (short) (j % verticesCyl) ;
        }

        indexBuffer.put(indices);
        vertBuffer.put(vertices);
        indexBuffer.flip();
        vertBuffer.flip();

        int[] buffer = new int[1];

        gl11.glGenBuffers(1, buffer, 0);
        vertexPointerCyl = buffer[0];
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, vertexPointerCyl);
        gl11.glBufferData(GL11.GL_ARRAY_BUFFER, vertBuffer.capacity() * 4, vertBuffer, GL11.GL_STATIC_DRAW);
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
        gl11.glGenBuffers(1, buffer, 0);
        indexPointerCyl = buffer[0];
        gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, indexPointerCyl);
        gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.capacity() * 2, indexBuffer, GL11.GL_STATIC_DRAW);
    }

////////////Draw the cylinder
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, vertexPointerCyl);
        gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, indexPointerCyl);
        gl11.glVertexPointer(3, GL10.GL_FLOAT, 0, 0);
        gl11.glPushMatrix();
        gl11.glColor4f(shadowColor,shadowColor,shadowColor, alpha);
        gl11.glTranslatef(mainX, mainY, 0);
        gl11.glScalef(scaleFactor, scaleFactor, 0);
        gl11.glRotatef(rotateCylinder, mainX, mainY, 0);
        gl11.glDrawElements(GL11.GL_TRIANGLE_STRIP, indicesCyl, GL11.GL_UNSIGNED_SHORT, 0);
        gl11.glPopMatrix();

  • 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-21T22:50:38+00:00Added an answer on May 21, 2026 at 10:50 pm

    Points to consider:

    1. Are you “flushing” the graphics context? (I guess you are using Android, but I don’t know the exact API to call)
    2. Did you load the buffer with “glBufferData”?
    3. Did you enabled the vertex client state with “glEnableClientState(GL_VERTEX_ARRAY)”?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT : proper solution: void add(Student s) { if(root == null) root = new
Solution Edit: Turns out you can't use the PHP SDK to return the correct
Intro: EDIT: See solution at the bottom of this question (c++) I have a
[edit] Found the solution. Reinstall EVERYTHING - xcode, mono, monodevelop and monotouch. Now it
(Edit: put possible solution at end) I'm a C/C++ programmer who is learning Objective
Edit: I've got the solution and have described it a bit more at the
My current solution will suck sometimes EDIT For those who don't understand,see this example:
EDIT: solved, look below for my solution. first of all, this is my very
EDIT: Solution...email is a function within Validate which is a class so you need
Edit: solution added. Hi, I currently have some working albeit slow code. It merges

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.