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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:03:05+00:00 2026-06-03T08:03:05+00:00

Trying to make a sphere. But it so doesn’t look like 3D, in fact

  • 0

Trying to make a sphere. But it so doesn’t look like 3D, in fact it looks like a flat 2D picture. What am I missing here?

2d sphere
Thankyou

std::vector<GLfloat> ballVerts;

for(int i = 0; i <= 40; i++)
{
    double lat0 = M_PI * (-0.5 + (double) (i - 1) / 40);
    double z0  = sin(lat0);
    double zr0 =  cos(lat0);

    double lat1 = M_PI * (-0.5 + (double) i / 40);
    double z1 = sin(lat1);
    double zr1 = cos(lat1);

    for(int j = 0; j <= 40; j++)
    {
        double lng = 2 * M_PI * (double) (j - 1) / 40;
        double x = cos(lng);
        double y = sin(lng);

        //  normals
        glNormal3f(x * zr0, y * zr0, z0);

        ballVerts.push_back(x * zr0); //X
        ballVerts.push_back(y * zr0); //Y
        ballVerts.push_back(z0);      //Z

        ballVerts.push_back(0.0f); 
        ballVerts.push_back(1.0f); 
        ballVerts.push_back(0.0f); 
        ballVerts.push_back(1.0f); //R,G,B,A

        //  normals
        glNormal3f(x * zr1, y * zr1, z1);

        ballVerts.push_back(x * zr1); //X
        ballVerts.push_back(y * zr1); //Y
        ballVerts.push_back(z1);      //Z

        ballVerts.push_back(0.0f); 
        ballVerts.push_back(1.0f); 
        ballVerts.push_back(0.0f); 
        ballVerts.push_back(1.0f); //R,G,B,A

// Render code
Furthermore, I am rotating this circle, the rotation works fine, since I have light changing and it gives me an idea that, it is rotating and is infact a circle at least

glRotatef(Angle, 1.0f, 0.5f, 0.3f);

glBindBuffer(GL_ARRAY_BUFFER, VertexBufferObject[2]);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 7*4, 0);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 3200);

glBindBuffer(GL_ARRAY_BUFFER, 0);
  • 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-03T08:03:06+00:00Added an answer on June 3, 2026 at 8:03 am

    First off all you need to check if lighting is currently enabled using glGetIntegerv(GL_LIGHTING,&i) and maybe turn it on glEnable(GL_LIGHTING).

    Then setup the glMaterial(...), glLightModel(...), glLight(...), there is tutorial http://www.cse.msu.edu/~cse872/tutorial3.html

    or you can use own GLSL shaders to apply some advanced illumination, some tutorials are here http://www.lighthouse3d.com/opengl/glsl/

    In some trivial cases you can just pass vertex colors via glColor3f(…) instead of using the GL lighting.

    Also normals should be unit vectors or enable normalization glEnable(GL_NORMALIZE).

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

Sidebar

Related Questions

Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make simple minesweeper game in python, but have one problem. I have
Trying to make a toggle button that hides/shows the right window/pane. Here is a
Im trying to make stars on the sky, but the stars distribution isnt even.
im trying make one replace in string from a array but this dont work
I'm trying make one treeView with infinite subgroups. I can add my groups but
I'm trying to make a change to an old appengine application, but now after
Trying to make td elements clickable. Here's my HTML: <td id=A3 class= open-square><a href=/gameplay/A3></a></td>
I am trying make a segue call in a tableview , but the application

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.