I am trying to assemble 2d chess board textures for each move in a game. Each 2d texture represents a single ‘frame’ if you will of a chess game. I’m not sure of the correct approach. Kind of like what you see here:
chesstempo.com/pgn-viewer.html
I have made a PNG image with the board (360x360 pixels) and the chess pieces (each 45x45 pixels). This is attached.
For each board position I already have a string (looks like this when printed from command line):
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
Where lower case is ‘black’ and upper case is ‘white’.
Problem is, I’m not sure the best way to go about overlaying the 45x45 chess pieces on the 360x360 board in real-time. I want to generate on-the-fly a ‘frame’ texture for each board move and set each one of those to a quad that is pickable by the user. So the user can click a given quad (with a texture on it) (more or less a 2d ui) and switch my 3d view to the matching chess board position…
Solutions I can think of…
- Build a single texture in real-time (by setting raw pixels) for each board position (not sure how to do this without setting raw pixels which is expensive).
- Make a quad for the board with the 360x360 texture applied to it. Then make a quad for each chess piece and apply the appropriate 45x45 texture. Render the board and translate each chess piece quad above it…then use Render-to-Texture for each board position (not sure if this would be too expensive).
- Use brute force miltitexturing…I would need 9 textures in use I think to make this work…most graphics cards only support up to 8.
Any thoughts on the best path? Or an alternate?