openGL help sought

Hi, i am a newbie to openGL.
I am trying an example as given at the link:

I am not including header file “gltk.h” as given but instead glut.h ( downloaded from 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.


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

#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

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

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

    // Flush the buffer to force drawing of all objects thus far

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)

    // register GLUT callback functions

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

    // Start GLUT event-processing loop

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