const GLClientState::VertexAttribState * GLClientState::getState(int location) { if (!validLocation(location)) { return NULL; } return & m_states[location]; }
void GLClientState::setBufferObject(int location, GLuint id) { if (!validLocation(location)) { return; } m_states[location].bufferObject = id; }
void GLClientState::enable(int location, int state) { if (!validLocation(location)) { return; } m_states[location].enableDirty |= (state != m_states[location].enabled); m_states[location].enabled = state; }
void GLClientState::setState(int location, int size, GLenum type, GLboolean normalized, GLsizei stride, void *data) { if (!validLocation(location)) { return; } m_states[location].size = size; m_states[location].type = type; m_states[location].stride = stride; m_states[location].data = data; m_states[location].bufferObject = m_currentArrayVbo; m_states[location].elementSize = glSizeof(type) * size; m_states[location].normalized = normalized; }
const GLClientState::VertexAttribState * GLClientState::getStateAndEnableDirty(int location, bool *enableChanged) { if (!validLocation(location)) { return NULL; } if (enableChanged) { *enableChanged = m_states[location].enableDirty; } m_states[location].enableDirty = false; return & m_states[location]; }
//--------------------------------------------------------------------------------- // Function: setships() // Title: Set Ships // Description: // Allows user to put ships in grid // Programmer: Paul Bladek // modified by: Kyle Graham // Hang Nguyen // // Date: 9/12/06 // // Version: 0.5 // // Environment: Hardware: i3 // Software: OS: Windows 7; // Compiles under Microsoft Visual C++ 2012 // // Input: location and orientation using getCoord from cin // // Output: prompts to cout // // Calls: printGrid() // safeChoice() // getCoord() // saveGrid() // // Called By: main() // // Parameters: players: Player[]; the array of 2 players // size: char; 'S' or 'L' // whichPlayer: short; the player number (0 or 1) // // Returns: void // // History Log: // 9/12/06 PB comleted v 0.5 // 1/16/15 KG & HN completed v 0.6 // 1/23/15 KG & HN completed v 0.7 // 1/29/15 KG & HN completed v 0.8 // //--------------------------------------------------------------------------------- void setships(Player players[], char size, short whichPlayer) { char input = 'V'; char ok = 'Y'; char save = 'N'; ostringstream outSStream; Cell location = {0, 0}; for(short j = 1; j < SHIP_SIZE_ARRAYSIZE; j++) { system("cls"); printGrid(cout, players[whichPlayer].m_gameGrid[0], size); outSStream.str(""); outSStream << "Player " << whichPlayer + 1 << " Enter " << shipNames[j] << " orientation"; input = safeChoice(outSStream.str(), 'V', 'H'); players[whichPlayer].m_ships[j].m_orientation = (input == 'V') ? VERTICAL : HORIZONTAL; cout << "Player " << whichPlayer + 1 << " Enter " << shipNames[j] << " bow coordinates <row letter><col #>: "; players[whichPlayer].m_ships[j].m_bowLocation = getCoord(cin, size); location = players[whichPlayer].m_ships[j].m_bowLocation; // if ok if(!validLocation(players[whichPlayer], j, size)) { cout << "invalid location. Press <enter>" ; cin.get(); j--; // redo continue; } // our code for(int i = 0; i < shipSize[j]; i ++) { if (input == 'V') { players[whichPlayer].m_gameGrid[0][location.m_row + i] [location.m_col] = static_cast<Ship>(j); } else { players[whichPlayer].m_gameGrid[0][location.m_row] [location.m_col + i] = static_cast<Ship>(j); } } system("CLS"); printGrid(cout, players[whichPlayer].m_gameGrid[0], size); ok = safeChoice("Position okay? ", 'Y', 'N'); // choice not ok if (ok == 'N') { for(int i = 0; i < shipSize[j]; i ++) { if (input == 'V') { players[whichPlayer].m_gameGrid[0][location.m_row + i] [location.m_col] = NOSHIP; } else { players[whichPlayer].m_gameGrid[0][location.m_row] [location.m_col + i] = NOSHIP; } } system("CLS"); printGrid(cout, players[whichPlayer].m_gameGrid[0], size); j--; } } // end for j save = safeChoice("\nSave starting grid?", 'Y', 'N'); if(save == 'Y') saveGrid(players, whichPlayer, size); }