All About the Graphics

All right, you graphics kiddies, here's some info about the graphics

I used GLUQuadrics for the pieces, which are modeled with the bases at the origin. They consist of Display Lists of mostly GLUCylinders and GLUDisks, set up so the normals point in the right direction. The knight even uses those, and I made the nose by rotating and (slightly) squeezing the coordinate system (via glScale) to make it kinda ovalish. The board is heirarchically modeled based upon the current chessboard state and the position of the pieces, and one mor object representing a square. I was going to represent the square useing GLVertex, etc with vertex lists, but I decided to be lazy and use a 4-sided quadric cylinder, which coincidentally is a cube. Pieces are selected using OpenGL select mode with each square's name (3-d position) pushed onto the name stack before the square and any piece on it are drawn. I did have a slight problem with the program returning multiple hits when exiting selection mode (Sometimes I need the first hit and sometimes I need the last hit - some oddity with the way I used the coordinate system and depth buffering), but I realized that I always needed either the first or the last name in the name buffer, so just chose the one with the lowest z-buffer value. The game is lighted with one light, which is located at (0,10,25), or just behind and above the viewer. I used the OpenGL Superbible to learn how to use OpenGL, although I found that its examples were often hard to apply to figuring out how to do just what I wanted to do. Still, it allowed me to get enough information to hack it out. I don't use an explicit camera (OpenGL doesn't really have one) or a gluLookAt, bacause I found that it was hard to use it and still be able to easily rotate, pan, and zoom in the scene. Instead, I rotate, etc. the coordinate system befor drawing the board. The Computer player statistics are done useing a glut subwindow, and the manipulations of the camera are done by a glut call back and which used flags set by the right-button menu. I originally had different callbacks based on what was being done (rotating around 2 different sets of axes, panning, and zooming) that were registered after the first mouse click after the menu selection and then de-registered after the mouseup event, but found that this didn't work under linux (the callback function was just never called) I don't know why this happens, and I dud look at the glut source to determine this, but couldn't figure it out, so instead changed the program to use a callback that was always was registered but that only does something when a flag is set. It's slightly kludgy, but it works.
Go Back to the main game page