openGL help sought

Hi, i am a newbie to openGL.
I am trying an example as given at the link:
http://www.eecs.tulane.edu/www/Terry/OpenGL/Examples/Hello_World.c

I am not including header file “gltk.h” as given but instead glut.h ( downloaded from opengl.org site)

now, i want to find the equivalent of following functions:

  1. tkexposeFunc()
  2. tkQuit()
  3. tkReshapeFunc
  4. tkDisplayFunc
  5. tkExec()

Note that i am using VC++ 6.0.

Help appreciated.

Hi !

I have no idea, but the tkReshapeFunc and tkDisplayFunc is the same as the reshape and display callbacks in glut, that is the most important part.

I guess tkQuit is used to shutdown the application and you do not have this in glut, you would have to use something like the atexit() feature in ansi C.

tkExec might be the same as the glut main loop but I am not sure.

tkexposeFunc is probably a callback to handle event when the window becomes visible, I do think you need to use it in glut.

Mikael

vega,
The version using GLUT instead of MesaTK looks like this. Try to compile it yourself:

// OpenGL Tutorial
// Hello_World.c

/*************************************************************************
This program essentially opens a window, clears it, sets the drawing
color, draws the object, and flushes the drawing buffer.  It then goes
into an infinite loop accepting events and calling the appropriate
functions.
*************************************************************************/

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

void reshape(int width, int height) {

    // Set the new viewport size
    glViewport(0, 0, (GLint)width, (GLint)height);
}

void draw(void) {

    // Clear the window
    glClear(GL_COLOR_BUFFER_BIT);

    // Set the drawing color
    glColor3f(1.0, 1.0, 1.0);

    // Specify which primitive type is to be drawn
    glBegin(GL_POLYGON);
        // Specify verticies in quad
        glVertex2f(-0.5, -0.5);
        glVertex2f(-0.5, 0.5);
        glVertex2f(0.5, 0.5);
        glVertex2f(0.5, -0.5);
    glEnd();

    // Flush the buffer to force drawing of all objects thus far
    glFlush();
}

void main(int argc, char **argv) {

    // init GLUT
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA);             // display mode
    glutInitWindowSize(400, 300);               // window size

    // Open a window, name it "Hello World"
    if(glutCreateWindow("Hello World") < 1)
        exit(0);

    // register GLUT callback functions
    glutDisplayFunc(draw);
    glutReshapeFunc(reshape);

    // Set the clear color to black
    glClearColor(0.0, 0.0, 0.0, 0.0);

    // Start GLUT event-processing loop
    glutMainLoop();
}

I think GLUT does not have such as “expose” callback, so glClear(GL_COLOR_BUFFER_BIT) is moved into draw().