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 4 of 4

Thread: Problem with 3D

  1. #1
    Guest

    Problem with 3D

    Hi all

    I have made small program using OpenGL under Linux using GTKGLarea.

    D works fine, but when I try to write 3D, then it doesn't show up at all.

    Here is code:

    gint glarea_init (GtkWidget* widget) {
    if (gtk_gl_area_make_current (GTK_GL_AREA(widget))) {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0);
    glDepthFunc(GL_LESS);
    glShadeModel(GL_SMOOTH); glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_D IFFUSE);
    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_DEPTH_TEST);
    }
    return true
    }

    gint glarea_reshape (GtkWidget* widget, GdkEventConfigure* event) {
    int w = widget->allocation.width;
    int h = widget->allocation.height;
    if (gtk_gl_area_make_current (GTK_GL_AREA(widget))) {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective( 55.0f, (GLfloat)w/(GLfloat)h, 0.1f, 100.0f);
    glMatrixMode(GL_MODELVIEW);
    }
    return (TRUE);
    }

    gint glarea_draw (GtkWidget* widget, GdkEventExpose* event) {
    int w = widget->allocation.width;
    int h = widget->allocation.height;
    if (event->count > 0) {
    return(TRUE);
    }

    if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_LINES);
    glVertex3f( 0.0, 0.0, 500.0);
    glVertex3f(0.0,0.0, -500.0);
    glEnd();

    gtk_gl_area_swapbuffers (GTK_GL_AREA(widget));
    }
    return (TRUE);
    }

    That's about it.

    Any sugestions?

    Thanx

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Problem with 3D

    With that setup, you won't see anything except maybe a tiny little dot. You are looking directly down the Z axis at a line drawn right along the Z axis. If you were looking slightly off-center of the Z-axis, or your line was drawn a bit off-center from the Z-axis, then you would see something.
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Guest

    Re: Problem with 3D

    Yes, you are right,it is a bad example. But still do not work.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Problem with 3D

    More info needed. What did you do to "make it work?"
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

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