void Model::draw(Camera * camera) { shaderProgram()->setUniformMatrix4fv("projection", camera->projectionMatrix()); shaderProgram()->setUniformMatrix4fv("view", camera->transformationMatrix()); shaderProgram()->setUniformMatrix4fv("model", transformationMatrix()); bindTextures(); shaderProgram()->use(); if (isWireframeMode()) { // wireframe mode glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } glBindVertexArray ( m_vaoId ); if (geometry()->isExist("index")) { GeometryBuffer *indices = geometry()->get("index"); indices->bind(); glDrawElements(GL_TRIANGLES, indices->size(), GL_UNSIGNED_INT, 0); } else { glDrawArrays ( GL_TRIANGLES, 0, geometry()->get("vertex")->size() ); } glBindVertexArray ( 0 ); if (isWireframeMode()) { // wireframe mode glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } shaderProgram()->disable(); unbindTextures(); }
int TextureManager::registerResourceManager(ResourceManager* theResourceManager) { if (NULL == theResourceManager) { // Decrement count by one --_myResourceManagerCount; if (_myResourceManagerCount == 0) { // Remove the Textures from the resourcemanager unbindTextures(); // XXX TODO: Copy vertices back into the Memory resource manager // Set the Resourcemanager back to the Memory implementation _myResourceManager = _myMemoryResourceManager.get(); } else if (_myResourceManagerCount < 0) { throw TextureManagerException("No Resourcemanager to set to NULL", PLUS_FILE_LINE); } AC_TRACE << "ResourceManagerCount decremented to " << _myResourceManagerCount; } else { if (_myResourceManager != theResourceManager) { // XXX TODO: Copy vertices from _myResourceManager into theResourceManager _myResourceManager = theResourceManager; } ++_myResourceManagerCount; AC_TRACE << "ResourceManagerCount incremented to " << _myResourceManagerCount; } return _myResourceManagerCount; }
void unbindTextures(const ImageOutport& outport) { unbindTextures(*outport.getData(), true, true, true); }
void unbindTextures(const ImageInport& inport) { unbindTextures(*inport.getData(), true, true, true); }
void unbindTextures(const Image& image) { unbindTextures(image, true, true, true); }
void unbindPickingTexture(const ImageOutport& outport) { unbindTextures(*outport.getData(), false, false, true); }
void unbindPickingTexture(const ImageInport& inport) { unbindTextures(*inport.getData(), false, false, true); }
void unbindDepthTexture(const ImageOutport& outport) { unbindTextures(*outport.getData(), false, true, false); }
void unbindDepthTexture(const ImageInport& inport) { unbindTextures(*inport.getData(), false, true, false); }