glut and glMinmax help please


I’m doing a workshop about visibility checking in a 3d scene, and i got some questions to ask about using glut and glMinmax.

in the final step i basically draw some white polygons on a squared black bitmap and i need to know whether i’ve covered all the square or there are still black pixels visible.

i got glut to open a window and i drew the polygons in that window, but now i got some problems:

  1. on the line:
    glMinmax(GL_MINMAX, GL_RGB, GL_FALSE);
    VC++ gives me glMinmax undefined and GL_MINMAX undeclared. i think i got the latest glut version, maybe i have an old opengl? how do i fix this?

  2. how can i draw the polygons not directly to the screen but only to a buffer, to do the glMinmax test on the buffer

  3. with a window after i call glutMainLoop() the drawing function is the one i registred using glutDisplayFunc, but i only want to draw the polygons and then go back directly to my program without registering the keyboard function… only draw, find minmax and be over with it. is it possible?

thanks in advance

I’ve never heard of glMinmax before. However about question 3. The only callback you need to register for glut to work is the display function. However glutMainloop will never exit, so any code after that point will not get executed.

thanks for the fast reply!

so let’s say i want to draw some stuff to a window/buffer, perform some sort of calculation on the buffer, and then continue on with my program …
how can i do that after i called
glutMainLoop() ?

maybe i should call glutCloseWindow() or something like that from inside the function i registered with glutDisplayFunc() ?

glMinMax is an extension (or at least not part of OpenGL 1.1, not sure if it was added into 1.3/1.4 as part of the spec.)

In either case, whether it’s still considered an extension or part of 1.4, you will need to use wglGetProcAddress to get access to that function. I would also suggest getting a copy of glext.h from SGI or the nVidia developer’s website. That has some #defines for function pointers that will prove useful.

Just off the top of my head it would be something like so…

#include <GL/glext.h>


void main()
glMinMax = wglGetProcAddress(“glMinMax”); // Possibly “glMinMaxEXT” or “glMinMaxARB”. Take a look at the spec

Edit: Added code tags and updated to the correct #define

[This message has been edited by Deiussum (edited 01-15-2003).]

glMinmax is a part of the imaging subset for OpenGL 1.2.

Ok. I knew I had seen it somewhere reading through either the 1.2.1 spec or the extensions specs, but couldn’t remember where. In any case, you still need to use wglGetProcAddress.

Thanks Deiussum and Bob, but i got an example source from the red book on using glMinmax and they simply call it without first calling wglGetProcAddress…

here it is:

  • minmax.c
  • Determine the minimum and maximum values of a group of pixels.
  • This demonstrates use of the glMinmax() call.
    #include <GL/glut.h>
    #include <stdlib.h>

extern GLubyte* readImage(const char*, GLsizei*, GLsizei*);

GLubyte *pixels;
GLsizei width, height;

void init(void)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glClearColor(0.0, 0.0, 0.0, 0.0);


void display(void)
GLubyte values[6];

glRasterPos2i(1, 1);
glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);

printf(" Red : min = %d max = %d
“, values[0], values[3]);
printf(” Green : min = %d max = %d
“, values[1], values[4]);
printf(” Blue : min = %d max = %d
", values[2], values[5]);

void reshape(int w, int h)
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glOrtho(0, w, 0, h, -1.0, 1.0);

void keyboard(unsigned char key, int x, int y)
switch (key) {
case 27:

/* Main Loop

  • Open window with initial window size, title bar,
  • RGBA display mode, and handle input events.
    int main(int argc, char
    * argv)
    pixels = readImage(“Data/leeds.bin”, &width, &height);

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(width, height);
glutInitWindowPosition(100, 100);
return 0;

this makes me thing that it’s just my opengl with is outdated…
does this code compile for you?
i got glMinmax undefined …
how do i check what’s the version of my opengl ? and how do i update it?

Even though OpenGL is at version 1.4, the OpenGL on our Win32 machines is still 1.1 - therefore all functionality added since version 1.1 must still be accessed as though it was an extension. The Redbook you have must be for a version later than 1.1 and therefore shows the commands as being part of the core.

You can still access the later features as long as your drivers support them via the extension mechanism.

[This message has been edited by T (edited 01-17-2003).]