Results 1 to 5 of 5

Thread: gluSphere (?)

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    gluSphere (?)

    i have a problem with sphere showing up on screen i think there is a problem with glScaled
    Code: #include<gl/glut.h>

    void init(GLvoid)
    {
    glClearColor(0.0f,0.0f,0.0f,0.5f);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);

    }

    void display(void)
    {
    GLUquadricObj* pKocka;
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glPushMatrix();
    glTranslated(200,200,200);
    if(!(pKocka=gluNewQuadric())) exit(1);
    glColor3ui(45,123,204);
    gluSphere(pKocka,50,40,40);
    glPopMatrix();
    glutSwapBuffers();
    glFlush();
    }

    void keyb(unsigned char a,int x,int y)
    {
    if(a=='b') glutPostRedisplay();
    }

    int main(int argc,char **argv)
    {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowPosition(10,10);
    glutInitWindowSize(629,469);
    glutCreateWindow("Gula");
    glClearColor(0.0f,0.0f,0.0f,0.0f);
    init();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glScaled(400,400,400);
    glutKeyboardFunc(keyb);
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
    }

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: gluSphere (?)

    try adding a reshape function

    oid reshape_flir(int w, int h)
    {
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, (GLsizei) w, 0, (GLsizei) h, -10, 10);
    glMatrixMode(GL_MODELVIEW);
    glTranslatef(0.0, 0.0, -4.0);
    }

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

    Re: gluSphere (?)

    glColor3ui(45,123,204);
    If you pass a color as integer types, then you pass values in the range [0, 2^n-1], where n is the number of bits in the type. For unsigned integers, n is usually 32. So 204 in that case corresponds to 0.000000047 when converted to a float. And due to finite precision of a floatingpoint value, this is equal to 0. So, you are passing a pure black color. And the fact that the background color also is black won't make things better if you want to see your sphere.

    Maybe you should replace glColor3ui with glColor3ub.

    And the size of your sphere is maybe a bit too large. The sphere you draw is 50 units in radius. Multiply that with 400, you get 20000 units large with the center located at (200, 200, 200). Since you have the identity matrix as projectipon matrix, every object outside the range x = [-1, 1], y = [-1, 1] and z = [-1, 1] will not be drawn. And your sphere is WAY outside this range.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Re: gluSphere (?)

    so how should i multiple matrix coordinates ? i don't want to use [-1,1] for all axis (maybe that has something to do with MSDN documentation - if you are not english american or somebody like that you won't understand that correctly )

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Re: gluSphere (?)

    Thanks i did work(shrinking ) but i di get some weird colours it should be blue but i get black lines throught the sphere. Any suggestions ?

Similar Threads

  1. gluSphere
    By GreenCat in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-10-2005, 11:26 AM
  2. gluSphere
    By ramana in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-19-2004, 11:49 PM
  3. gluSphere
    By ramana in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-19-2004, 11:49 PM
  4. How do i use gluSphere
    By ShinGouki in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-06-2003, 07:15 PM
  5. gluSphere
    By joey in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-09-2001, 11:30 PM

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