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 1067181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:07:22+00:00 2026-05-16T20:07:22+00:00

Is there a way to draw a cube like this and as a result,

  • 0

Is there a way to draw a cube like this and as a result, only upload 8 verticies and 24 indicies to the graphics card? If so how could this be done?

Thanks

I currently do it like this:

boxdims.x = w;
    boxdims.y = h;
    boxdims.z = d;
    center = c;

    GLfloat vboverticies[72];
    GLfloat vbonormals[18];
    Vertex3f verticies[24];

    //Top face
    verticies[0] = Vertex3f(-boxdims.x / 2.0f,boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[1] = Vertex3f(-boxdims.x / 2.0f,boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[2] = Vertex3f(boxdims.x / 2.0f,boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[3] = Vertex3f(boxdims.x / 2.0f,boxdims.y / 2.0f, -boxdims.z / 2.0f);


    //Bottom face
    verticies[4] = Vertex3f(-boxdims.x / 2.0f,-boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[5] = Vertex3f(boxdims.x / 2.0f,-boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[6] = Vertex3f(boxdims.x / 2.0f,-boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[7] = Vertex3f(-boxdims.x / 2.0f,-boxdims.y / 2.0f, boxdims.z / 2.0f);


    //Left face
    verticies[8] = Vertex3f(-boxdims.x / 2.0f,-boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[9] = Vertex3f(-boxdims.x / 2.0f,-boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[10] =Vertex3f(-boxdims.x / 2.0f,boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[11] =Vertex3f(-boxdims.x / 2.0f,boxdims.y / 2.0f, -boxdims.z / 2.0f);


    //Right face
    verticies[12] =Vertex3f(boxdims.x / 2.0f,-boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[13] =Vertex3f(boxdims.x / 2.0f,boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[14] =Vertex3f(boxdims.x / 2.0f,boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[15] =Vertex3f(boxdims.x / 2.0f,-boxdims.y / 2.0f, boxdims.z / 2.0f);

    //Front face
    verticies[16] =Vertex3f(-boxdims.x / 2.0f,-boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[17] =Vertex3f(boxdims.x / 2.0f,-boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[18] =Vertex3f(boxdims.x / 2.0f,boxdims.y / 2.0f, boxdims.z / 2.0f);
    verticies[19] =Vertex3f(-boxdims.x / 2.0f,boxdims.y / 2.0f, boxdims.z / 2.0f);

    //Back face
    verticies[20] =Vertex3f(-boxdims.x / 2.0f,-boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[21] =Vertex3f(-boxdims.x / 2.0f,boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[22] =Vertex3f(boxdims.x / 2.0f,boxdims.y / 2.0f, -boxdims.z / 2.0f);
    verticies[23] =Vertex3f(boxdims.x / 2.0f,-boxdims.y / 2.0f, -boxdims.z / 2.0f);




    for(int i = 0; i < 24; i++)
    {
        verticies[i].x += center.x;
        verticies[i].y += center.y;
        verticies[i].z += center.z;
    }


    int count = 0;
    for(int i = 0; i < 24; ++i)
    {
        vboverticies[count] = verticies[i].x;
        count++;
        vboverticies[count] = verticies[i].y;
        count++;
        vboverticies[count] = verticies[i].z;
        count++;
    }

    //glNormal3f(0.0, 1.0f, 0.0f);
    //glNormal3f(0.0, -1.0f, 0.0f);
    //glNormal3f(-1.0, 0.0f, 0.0f);
    //glNormal3f(1.0, 0.0f, 0.0f);
    //glNormal3f(0.0, 0.0f, 1.0f);
    //glNormal3f(0.0, 0.0f, -1.0f);
    vbonormals[0] = (0.0);
    vbonormals[1] = (1.0);
    vbonormals[2] = (0.0);

    vbonormals[3] = (0.0);
    vbonormals[4] = (-1.0);
    vbonormals[5] = (0.0);

    vbonormals[6] = (-1.0);
    vbonormals[7] = (0.0);
    vbonormals[8] = (0.0);

    vbonormals[9] = (1.0);
    vbonormals[10]= (0.0);
    vbonormals[11]= (0.0);

    vbonormals[12]= (0.0);
    vbonormals[13]= (0.0);
    vbonormals[14]= (1.0);

    vbonormals[15]= (0.0);
    vbonormals[16]= (0.0);
    vbonormals[17]= (-1.0);



    //Create the VBO
    glDeleteBuffers(1, &vboID);
    glGenBuffersARB(1, &vboID);
    glBindBufferARB(GL_ARRAY_BUFFER, vboID);
    glBufferDataARB(GL_ARRAY_BUFFER, (72 * sizeof(GLfloat)) + 
        (18 * sizeof(GLfloat)) , NULL, GL_STATIC_COPY);

    glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, 72 * sizeof(GLfloat), vboverticies);
    glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 72 * sizeof(GLfloat),
        18 * sizeof(GLfloat), vbonormals);


}
  • 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-16T20:07:23+00:00Added an answer on May 16, 2026 at 8:07 pm

    The answer is no.

    If you need normals, you’ll have to have 24 vertices, as no face shares normals. Note that the example provided by shk does not handle normals.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to draw text in a DisplayObject or Shape using only
Is there a way to do a mysql database query in Corel Draw 13(X3)?
Is there way in next piece of code to only get the first record?
Is there a way to enforce constraint checking in MSSQL only when inserting new
Is there a way to draw an arc using points in JavaScript?? I need
Is there a way to draw smooth animation in javascript? In directx I'm using
Is there any way to draw on the desktop background in WIN32 and also
Is there a way to draw a line on a graph (or at least
is there a way to draw mixed-formatted text in .Net 2.0? I'm looking for
Is there a way to draw many filled circles using one vertex array. Is

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.