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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:54:24+00:00 2026-06-05T03:54:24+00:00

When I try to draw a torus,nothing is displayed, but the code runs perfectly

  • 0

When I try to draw a torus,nothing is displayed, but the code runs perfectly on my friends PC.
I don’t have problems when drawing cubes or other simple shapes.
Did I forget something or what could be the problem?

Code:

#include <GL/glut.h>
#include <stdio.h>


GLint width = 600;
GLint height = 600;

GLdouble eyex = 3.0, eyey = 0.0, eyez = 5.0;
GLdouble atx = 0.0, aty = 0.0, atz = 0.0;
GLdouble vupx = 0.0, vupy = 1.0, vupz = 0.0;

GLdouble fovy = 120.0, aspect = 1.0, Znear = 1.0, Zfar = 10.0;

GLfloat position[] = {10.0, 0.0, 1.5, 10.0 };


static void display(void)
{

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.5,0.1,1.1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyex, eyey, eyez, atx, aty, atz, vupx, vupy, vupz);
glColor3f(1.0,0.0,0.0);


glutSolidTorus(1.0,2.0,100,100);
glFlush();

}


void init(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_FLAT);
}


void reshape(int winw, int winh) {
glViewport(0,0,winw,winh); //Otvor
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fovy, aspect, Znear, Zfar);

}

static void key(unsigned char key, int x, int y)
{
switch (key)
{
    case 27 :
        exit(0);
        break;
}
}

void mouse(int button, int state, int x, int y)
{

if (button == GLUT_LEFT_BUTTON)
{
    glPushMatrix();
glRotatef(60,0.0,5.0,0.0);;

glLightfv(GL_LIGHT0,GL_POSITION,position);
glPopMatrix();
glFlush();
}
}


int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(width,height);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

glutCreateWindow("Light");
init();

glutDisplayFunc(display);
glutReshapeFunc(reshape);
glLightfv(GL_LIGHT0,GL_POSITION,position);


glutKeyboardFunc(key);
glutMainLoop();

//return EXIT_SUCCESS;
//return exit_success;
}
  • 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-05T03:54:26+00:00Added an answer on June 5, 2026 at 3:54 am

    Request a depth buffer:

    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
    

    And make sure to clear it:

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to draw some lines with different colors. This code tries to draw
When i try to draw single pixel black line with the following code: context.strokeStyle
in this code i'm try to draw simple olympic ring and rotate it... the
I try to draw a string in this texture: http://picasaweb.google.it/lh/photo/LkYWBv_S_9v2d6BAfbrhag?feat=directlink but the green numbers
i try to draw arc in view i use this code. - (void)viewDidLoad {
I'm making a drawing board, and I have a few questions. Whenever I try
I try to draw rain and snow as particle system using Core Graphics .
I try to draw a table on a panel in C# Windows Form by
I try to draw a sequence of pattern images (different repeated patterns in one
I am using the pictureBox_Paint event to try and draw an overlay onto the

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.