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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:58:37+00:00 2026-06-15T09:58:37+00:00

I’m working on just making uniformly colors spheres for a project and I’m running

  • 0

I’m working on just making uniformly colors spheres for a project and I’m running into an issue. The spheres run fine but when I try to color them with glColorPointer they stop appearing. OpenGL isn’t showing any errors when I call glGetError so I’m at a loss for why this would happen.

The code to generate the vertices, colors etc:

void SphereObject::setupVertices()
{
    //determine the array sizes
    //vertices per row (+1 for the repeated one at the end) * three for each coordinate
    //times the number of rows
    int arraySize = myNumVertices * 3;
    myNumIndices = (myVerticesPerRow + 1) * myRows * 2;
    myVertices = new GLdouble[arraySize];
    myIndices = new GLuint[myNumIndices];
    myNormals = new GLdouble[arraySize];
    myColors = new GLint[myNumVertices * 4];

    //use spherical coordinates to calculate the vertices
    double phiIncrement = 360 / myVerticesPerRow;
    double thetaIncrement = 180 / (double)myRows;
    int arrayIndex = 0;
    int colorArrayIndex = 0;
    int indicesIndex = 0;
    double x, y, z = 0;

    for(double theta = 0; theta <= 180; theta += thetaIncrement)
    {
        //loop including the repeat for the last vertex
        for(double phi = 0; phi <= 360; phi += phiIncrement)
        {
            //make sure that the last vertex is repeated
            if(360 - phi < phiIncrement)
            {
                x = myRadius * sin(radians(theta)) * cos(radians(0));
                y = myRadius * sin(radians(theta)) * sin(radians(0));
                z = myRadius * cos(radians(theta));
            }
            else
            {
                x = myRadius * sin(radians(theta)) * cos(radians(phi));
                y = myRadius * sin(radians(theta)) * sin(radians(phi));
                z = myRadius * cos(radians(theta));
            }

            myColors[colorArrayIndex] = myColor.getX();
            myColors[colorArrayIndex + 1] = myColor.getY();
            myColors[colorArrayIndex + 2] = myColor.getZ();
            myColors[colorArrayIndex + 3] = 1;

            myVertices[arrayIndex] = x;
            myVertices[arrayIndex + 1] = y;
            myVertices[arrayIndex + 2] = z;

            if(theta <= 180 - thetaIncrement)
            {
                myIndices[indicesIndex] = arrayIndex / 3; 

                myIndices[indicesIndex + 1] = (arrayIndex / 3) + myVerticesPerRow + 1;

                indicesIndex += 2;
            }

            arrayIndex += 3;
            colorArrayIndex += 4;
        }
    }
}

And the code to actually render the thing

void SphereObject::render()
{
    glPushMatrix();
    glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
    glEnableClientState(GL_COLOR_ARRAY);
    glColorPointer(4, GL_INT, 0, myColors);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_DOUBLE, 0, myVertices);
    glDrawElements(GL_QUAD_STRIP, myNumIndices, GL_UNSIGNED_INT, myIndices);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    glPopClientAttrib();
    glPopMatrix();
}

Any and all help would be appreciated. I’m really having a hard time for some reason.

  • 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-06-15T09:58:38+00:00Added an answer on June 15, 2026 at 9:58 am

    When you use GL_INT (or any integer type) for color pointer, it linearly maps the largest possible integer value to 1.0f (maximum color), and 0 to 0.0f (minimum color).

    Therefore unless your values of RGB and A are in the billions, they will likely appear completely black (or transparent if that’s enabled). I see that you’ve got alpha = 1, which will essentially be zero after conversion to float.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.