Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: blank screen

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    10

    blank screen

    hi,

    does anybody know the problem?
    i always get one frame with the sphere, then a blank screen.

    the code:

    ---------------------------------------
    GLint displayList;

    void main(int argc, char **argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowSize(screenWidth, screenHeight);
    glutInitWindowPosition(100,100);
    glutCreateWindow("OpenGL");

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    displayList = glGenLists(1);
    glColor4f(0.2f, 0.2f, 0.2f, 0.75f);

    glNewList(displayList, GL_COMPILE);
    glutSolidSphere(1,10,10);
    glEndList();

    glutPassiveMotionFunc(mouseMotion);
    glutIgnoreKeyRepeat(false);
    glutKeyboardFunc(processNormalKeys);
    glutSpecialFunc(pressSpecialKey);
    glutSpecialUpFunc(releaseSpecialKey);
    glutDisplayFunc(renderScene);
    glutIdleFunc(renderScene);
    glutReshapeFunc(changeSize);
    glutMainLoop();
    }

    void renderScene(void)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glCallList(displayList);

    gluLookAt(0, 1, 10,
    0, 0, 0,
    0.0f, 1.0f, 0.0f);

    glutSwapBuffers();
    }

    void changeSize(int scrWidth, int scrHeight)
    {
    screenWidth = scrWidth;
    screenHeight = scrHeight;

    if(scrHeight == 0)
    scrHeight = 1;

    ratio = 1.0f * scrWidth / scrHeight;

    glViewport(0, 0, scrWidth, scrHeight);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPerspective(45, ratio, 1, 1000);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: blank screen

    You are doing your lookat AFTER you draw your data with a call list, this is the wrong order.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    10

    Re: blank screen

    this doesn't work also....

    _________________________

    void renderScene(void)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    gluLookAt(0, 1, 10,
    0, 0, 0,
    0.0f, 1.0f, 0.0f);

    glCallList(displayList);

    glutSwapBuffers();
    }

  4. #4
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: blank screen

    The sphere might be too dark, try something that isn't dark charcoal, how about white for a test, you probably have gamma 1 from your video and won't see a thing at .2 brightness. The color is not in the display list either (not mandatory but just a warning for the future). Your alpha of 0.75 will have no effect unless you blend, just another point of caution.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Nov 2001
    Location
    Malaysia
    Posts
    112

    Re: blank screen

    How about putting glViewport after glMatrixMode and glLoadIdentity.

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    10

    Re: blank screen

    first of all, thx for your answers!
    now it works, here the solution:
    ________________________________

    void renderScene(void)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glCallList(displayList);

    // glMatrixMode(GL_MODELVIEW) not necessary !
    // !!!!! VERY IMPORTANT !!!
    glLoadIdentity();
    gluLookAt(...);

    glutSwapBuffers();
    }

    void changeSize(int scrWidth, int scrHeight)
    {
    if(scrHeight == 0)
    scrHeight = 1;

    ratio = 1.0f * scrWidth / scrHeight;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glViewport(0, 0, scrWidth, scrHeight);

    gluPerspective(45, ratio, 1, 1000);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // necessary??? but it works...
    gluLookAt(...);
    }

    ____________________________________

    very simple ;-)

  7. #7
    Intern Newbie
    Join Date
    Jan 2005
    Location
    CA, USA
    Posts
    44

    Re: blank screen

    These codes work in my computer(win2000)

    Originally posted by thisPointer:
    this doesn't work also....

    _________________________

    void renderScene(void)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    gluLookAt(0, 1, 10,
    0, 0, 0,
    0.0f, 1.0f, 0.0f);

    glCallList(displayList);

    glutSwapBuffers();
    }
    ===
    Thanks,
    Zero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •