Trouble with my first OpenGL program

I am just starting to Learn OpenGL. I read through the first 3 chapters of the Open GL Super Bible online, but unfortunetely, it doesn’t let me get access to the CD that comes with it (guess they want me to buy it, no thx )

Anyway, I am trying to modify the 3rd section of code with the AuxKeyFunc function so that I can move a rectangle down when I press the d key. However, nothing happens when I press the key down. What is wrong with my code?

// bounce.c
// Bouncing square

#include <windows.h> // Standard windows include
#include <gl\gl.h> // OpenGL library
#include <gl\glaux.h> // AUX library
#include <iostream.h>

GLfloat windowHeight = 250.0f;
GLfloat windowWidth = 250.0f;

GLfloat x1 = 100;
GLfloat y1 = 100;
GLfloat rsize = 50;

void CALLBACK MoveDown(void) {
cout << “Yup, you pressed d” << endl;
if (y1 - rsize > 0)

void CALLBACK ChangeSize(GLsizei w, GLsizei h)
// Prevent a divide by zero, when window is too short
// (you can’t make a window of zero width)
if(h == 0)
h = 1;

    // Set the viewport to be the entire window
    glViewport(0, 0, w, h);

    // Reset the coordinate system before modifying

    // Keep the square square, this time, save calculated
    // width and height for later use
    if (w &lt;= h)
            windowHeight = 250.0f*h/w;
            windowWidth = 250.0f;

windowWidth = 250.0f*w/h;
windowHeight = 250.0f;

    // Set the clipping volume
    glOrtho(0.0f, windowWidth, 0.0f, windowHeight, 1.0f, -1.0f);

// Called by AUX library to update window
void CALLBACK RenderScene(void)
// Set background clearing color to blue
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);

    // Clear the window with current clearing color

    // Set drawing color to red, and draw rectangle at
    // current position.
    glColor3f(1.0f, 0.0f, 0.0f);
	glRectf(x1, y1, x1 + rsize, y1 + rsize);


// Main body of program
void main(void)
// AUX window setup and initialization
auxInitDisplayMode(AUX_DOUBLE | AUX_RGBA);
auxInitWindow(“Simple 2D Animation”);

    // Set function to call when window is resized

    // Start main loop

	//Move Rect down when D is pressed
	auxKeyFunc(AUX_d, MoveDown);

Although I’ve never read the Superbible (I stick to the red and blue books), I would assume that once you enter the main event loop, nothing else in main() gets executed until after the program terminates the loop (i.e. - quits). Are you getting a response to the button pressed event (you’ve got a print statemnet in there - is it executing?)? If not, try moving the last line…

instead of:
// Start main loop

//Move Rect down when D is pressed
auxKeyFunc(AUX_d, MoveDown);

//Move Rect down when D is pressed
auxKeyFunc(AUX_d, MoveDown);

// Start main loop


Yeah, it worked now. Thanks Chris.