Results 1 to 3 of 3

Thread: confused about redenring cylinder

  1. #1
    Member Newbie
    Join Date
    Jan 2002
    Location
    Rolla , MO USA
    Posts
    36

    confused about redenring cylinder

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


    static int R1=0,R2=45.0,R3=0,R4=0,R5=0,R6=0;
    GLfloat nearView=-10.0;

    void inti(void)
    {
    glClearColor(0.,0.,0.,0.);
    glShadeModel(GL_SMOOTH);
    }

    void display()
    {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glColor3f(1.0,0.0,0.0);
    GLUquadric* pQu;
    pQu=gluNewQuadric();
    gluQuadricDrawStyle(pQu,GLU_FILL);
    gluQuadricNormals(pQu,GLU_SMOOTH);

    glTranslatef(0.0,0.0,-10.0);
    gluCylinder(pQu,0.5,0.5,1.0,2,1);
    glFlush();
    }

    void reshape(int w, int h)
    {
    glViewport(0,0,(GLsizei) w,(GLsizei) h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.0,(GLfloat)w/(GLfloat)h,1.0,100.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0.0,0.0,-10.0);
    }


    int main(int argc, char** argv)
    {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GL_DEPTH) ;
    glutInitWindowSize(500,500);
    glutInitWindowPosition(100,100);
    glutCreateWindow(argv[0]);
    inti();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();
    return 0;
    }


    Why cannot I render the cylinder? any help is most appreciated!

    beet
    Beet

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: confused about redenring cylinder

    In the display function, you translate the cylinder, but you don't reset the transformations before next call. Example, you call the init function, and move the cylinder 10 units. The display function is called, and you move another 10 units. It's now 20 units away. Next time the display function is called, you move it 10 units again, and it's located 30 units away. Next time, it will be 40 units away, and next, 50 units away.

    Try put a glLoadIdentity before the translation in the display function.

    [This message has been edited by Bob (edited 01-24-2002).]

  3. #3
    Member Newbie
    Join Date
    Jan 2002
    Location
    Rolla , MO USA
    Posts
    36

    Re: confused about redenring cylinder

    2 Qes:

    fisrt I reset the model transformation in Redisplay()function;

    second; even like that, when I first run the program, I should get the correct scene with -20 units translation in z direction.

    thanks for your reply
    Beet

Similar Threads

  1. ok now i'm confused ...
    By b2tehrizzo in forum OpenVG
    Replies: 3
    Last Post: 03-03-2007, 03:49 AM
  2. Little confused...
    By in forum OpenGL: User Software
    Replies: 2
    Last Post: 07-12-2005, 03:36 PM
  3. I'm confused
    By M/\dm/\n in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 12-11-2002, 02:01 AM
  4. I'm confused :(
    By TheGecko in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 04-04-2002, 03:34 PM
  5. confused about redenring cylinder
    By beet6 in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-24-2002, 08:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean