How to Create a Chess Board in OpenGL


OpenGL offers computer programmers a fairly simple to use graphics application programming interface or API. You can create graphics for a variety of different programs, including games of skill, such as chess. Creating a chess board in OpenGL is only half the battle when creating a chess game, but if you don't know where to start, it can be a fairly daunting task.

  • Familiarize yourself with the various features of OpenGL and programming languages, especially Java and C++. While OpenGL provides you with a programming interface, it is not a program or language itself. You need to be fairly proficient in at least one basic computer programming language to use OpenGL to create a chessboard.

  • Determine how complicated you intend to get with your design. The easiest way to make a chessboard in OpenGL is to start with a simple two-dimensional model that is little more than a rectangular or square box shaded in the pattern of a chessboard.

  • Provide all side coordinates for the chessboard by using the glVertex2f function in OpenGL. Write the coordinates in a simple language like C++ and also use the OpenGL Utility Toolkit, or GLUT, to construct the board. A set of coordinates may look something like this:





    These commands have to be completed for each coordinate for each square of the chessboard.

  • Color the chessboard to distinguish the different squares from one another. Use the glColor3f function within OpenGL to determine the color for each square on the chessboard. The color scheme is designated by code similar to the location of each square: glColor2f(0.05f,0.05f).

  • Create more complicated designs using the glColor3f and the glVertex3f functions. These differ from the 2f functions in that they require a third coordinate to account for the z-axis that gives your board its three-dimensional look. Practice with each of these until you become proficient in creating the basic elements of your chessboard.


  • Photo Credit Thinkstock Images/Comstock/Getty Images
Promoted By Zergnet


Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!