tavli
annotate src/board.cc @ 0:52e0dd47753b
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 21 Jun 2015 06:30:39 +0300 |
parents | |
children | 3fcd7b4d631f |
rev | line source |
---|---|
nuclear@0 | 1 #include "opengl.h" |
nuclear@0 | 2 #include "board.h" |
nuclear@0 | 3 |
nuclear@0 | 4 static Mesh *gen_board_mesh(); |
nuclear@0 | 5 static Mesh *gen_puck_mesh(); |
nuclear@0 | 6 |
nuclear@0 | 7 Board::Board() |
nuclear@0 | 8 { |
nuclear@0 | 9 clear(); |
nuclear@0 | 10 } |
nuclear@0 | 11 |
nuclear@0 | 12 Board::~Board() |
nuclear@0 | 13 { |
nuclear@0 | 14 destroy(); |
nuclear@0 | 15 } |
nuclear@0 | 16 |
nuclear@0 | 17 bool Board::init() |
nuclear@0 | 18 { |
nuclear@0 | 19 if(!(board_mesh = gen_board_mesh())) { |
nuclear@0 | 20 return false; |
nuclear@0 | 21 } |
nuclear@0 | 22 if(!(puck_mesh = gen_puck_mesh())) { |
nuclear@0 | 23 return false; |
nuclear@0 | 24 } |
nuclear@0 | 25 return true; |
nuclear@0 | 26 } |
nuclear@0 | 27 |
nuclear@0 | 28 void Board::destroy() |
nuclear@0 | 29 { |
nuclear@0 | 30 delete board_mesh; |
nuclear@0 | 31 delete puck_mesh; |
nuclear@0 | 32 board_mesh = puck_mesh = 0; |
nuclear@0 | 33 } |
nuclear@0 | 34 |
nuclear@0 | 35 void Board::clear() |
nuclear@0 | 36 { |
nuclear@0 | 37 memset(slots, 0, sizeof slots); |
nuclear@0 | 38 } |
nuclear@0 | 39 |
nuclear@0 | 40 void Board::draw() const |
nuclear@0 | 41 { |
nuclear@0 | 42 if(board_mesh) |
nuclear@0 | 43 board_mesh->draw(); |
nuclear@0 | 44 } |
nuclear@0 | 45 |
nuclear@0 | 46 static Mesh *gen_board_mesh() |
nuclear@0 | 47 { |
nuclear@0 | 48 return 0; |
nuclear@0 | 49 } |
nuclear@0 | 50 |
nuclear@0 | 51 static Mesh *gen_puck_mesh() |
nuclear@0 | 52 { |
nuclear@0 | 53 return 0; |
nuclear@0 | 54 } |