void gfx2d::destroy() { if(glIsBuffer(vbo_fullscreen_triangle)) glDeleteBuffers(1, &vbo_fullscreen_triangle); if(glIsBuffer(vbo_fullscreen_quad)) glDeleteBuffers(1, &vbo_fullscreen_quad); if(glIsBuffer(vbo_primitive)) glDeleteBuffers(1, &vbo_primitive); floor::get_event()->remove_event_handler(evt_handler); }
/* Clean up allocated data in a triangleSoup object */ void soupDelete(triangleSoup *soup) { if(glIsVertexArray(soup->vao)) { glDeleteVertexArrays(1, &(soup->vao)); } soup->vao = 0; if(glIsBuffer(soup->vertexbuffer)) { glDeleteBuffers(1, &(soup->vertexbuffer)); } soup->vertexbuffer = 0; if(glIsBuffer(soup->indexbuffer)) { glDeleteBuffers(1, &(soup->indexbuffer)); } soup->indexbuffer = 0; if(soup->vertexarray) { free((void*)soup->vertexarray); } if(soup->indexarray) { free((void*)soup->indexarray); } soup->nverts = 0; soup->ntris = 0; };
void OpenGLMesh::Unload () { #ifndef SINGLE_VAO OPENGL_CHECK_ERROR_NO_THROW; if ( glIsVertexArray ( mArray ) ) { OPENGL_CHECK_ERROR_NO_THROW; glDeleteVertexArrays ( 1, &mArray ); OPENGL_CHECK_ERROR_NO_THROW; mArray = 0; } #endif OPENGL_CHECK_ERROR_NO_THROW; if ( glIsBuffer ( mVertexBuffer ) ) { OPENGL_CHECK_ERROR_NO_THROW; glDeleteBuffers ( 1, &mVertexBuffer ); OPENGL_CHECK_ERROR_NO_THROW; mVertexBuffer = 0; } OPENGL_CHECK_ERROR_NO_THROW; if ( glIsBuffer ( mIndexBuffer ) ) { OPENGL_CHECK_ERROR_NO_THROW; glDeleteBuffers ( 1, &mIndexBuffer ); OPENGL_CHECK_ERROR_NO_THROW; mIndexBuffer = 0; } OPENGL_CHECK_ERROR_NO_THROW; }
CVertexBuffer::~CVertexBuffer() { if (glIsBuffer(_vert_id)) { glDeleteBuffers(1, &_vert_id); } if (glIsBuffer(_col_id)) { glDeleteBuffers(1, &_col_id); } }
void Buffer::free(GLuint id) { if (glIsBuffer(m_buffers[id])) { glDeleteBuffers(1, &m_buffers[id]); } if (glIsBuffer(m_buffersindex[id])) { glDeleteBuffers(1, &m_buffersindex[id]); } std::free(&m_buffers[id]); std::free(&m_buffersindex[id]); }
// Destroy GL objects void Box::Cleanup() { if (glIsBuffer(position_vbo) == GL_TRUE) glDeleteBuffers(1, &position_vbo); if (glIsBuffer(colour_vbo) == GL_TRUE) glDeleteBuffers(1, &colour_vbo); if (glIsVertexArray(vao) == GL_TRUE) glDeleteVertexArrays(1, &vao); _ready = false; }
void Buffer::free(void) { // Free up MEM for (unsigned int i = 0; i < CENGINE_MAX_BUFFER_SIZE; i++) { if (glIsBuffer(m_buffers[i])) { glDeleteBuffers(1, &m_buffers[i]); } if (glIsBuffer(m_buffersindex[i])) { glDeleteBuffers(1, &m_buffersindex[i]); } } std::free(m_buffers); std::free(m_buffersindex); }
Renderable::~Renderable() { mNumVertices = 0; mNumElements = 0; mNumIndicesPerElement = 0; mVertexSize = 0; if(glIsBuffer(mVbo)) glDeleteBuffers(1, &mVbo); if(glIsBuffer(mIbo)) glDeleteBuffers(1, &mIbo); }
game::~game() { eevt->remove_event_handler(action_handler_fct); set_enabled(false); t->delete_texture(death_tex); // eleminate cubes for(size_t i = CUBE_VBO_INDEX_VERT; i < CUBE_VBO_INDEX_MAX__; ++i) { if(glIsBuffer(cube_vbo[i])) glDeleteBuffers(1, &cube_vbo[i]); } if(glIsBuffer(laser_beam_vbo)) glDeleteBuffers(1, &laser_beam_vbo); if(glIsBuffer(laser_beam_indices_vbo)) glDeleteBuffers(1, &laser_beam_indices_vbo); if(glIsTexture(tex_permutation)) glDeleteTextures(1, &tex_permutation); if(glIsTexture(tex_gradient)) glDeleteTextures(1, &tex_gradient); }
void HardwareGeometry::cleanUp ( ) { if( glIsBuffer(m_vbo) ) GLCheck(glDeleteBuffers(1, &m_vbo)); if( glIsBuffer(m_ibo) ) GLCheck(glDeleteBuffers(1, &m_ibo)); if( glIsVertexArray(m_vao) ) GLCheck(glDeleteVertexArrays(1, &m_vao)); }
void Mesh::render() { initializeOpenGLFunctions(); if (glIsVertexArray(vao) == GL_FALSE || glIsBuffer(vbo) == GL_FALSE) { return; } glBindVertexArray(vao); if (glIsBuffer(ibo) == GL_TRUE) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); glDrawElements(GL_TRIANGLES, indicesCount, GL_UNSIGNED_INT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } else { glDrawArrays(GL_TRIANGLES, 0, verticesCount); } glBindVertexArray(0); }
void validate(const vbo& VBO) { if(!glIsBuffer(VBO)) { throw vbo_exception("point_vbo is not a buffer!"); } }
void gl_vertex_buffer::load(const void* data, size_t offset, size_t size) { assert(glIsBuffer(_buffer_id) == GL_TRUE); assert(offset + size <= vertex_buffer::size()); glBindBuffer(GL_ARRAY_BUFFER, _buffer_id); glBufferSubData(GL_ARRAY_BUFFER, offset, size, data); GLNOERROR; }
map_objects::~map_objects() { if(ws_positions != NULL) { delete [] ws_positions; ws_positions = NULL; } if(glIsBuffer(vbo_ws_position_id)) { glDeleteBuffers(1, &vbo_ws_position_id); } }
void QuadSurfaces::render() { //Update quad index buffer clock_t t1,t2; //Prepare the Index buffer if (!indexvbo) glGenBuffers(1, &indexvbo); //Always set data size again in case changed assert(elements); glGenBuffers(1, &indexvbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexvbo); GL_Error_Check; if (glIsBuffer(indexvbo)) { glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements * sizeof(GLuint), NULL, GL_DYNAMIC_DRAW); //glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements * sizeof(GLuint), NULL, GL_STATIC_DRAW); debug_print(" %d byte IBO created for %d indices\n", elements * sizeof(GLuint), elements); } else abort_program("IBO creation failed!\n"); GL_Error_Check; elements = 0; int offset = 0; int voffset = 0; for (unsigned int index = 0; index < geom.size(); index++) { t1=clock(); std::vector<Vec3d> normals(geom[index]->count); std::vector<GLuint> indices; //Quad indices int quads = (geom[index]->width-1) * (geom[index]->height-1); indices.resize(quads*4); debug_print("%d x %d grid, quads %d, offset %d\n", geom[index]->width, geom[index]->height, quads, elements); calcGridNormals(index, normals); calcGridIndices(index, indices, voffset); //Vertex index offset voffset += geom[index]->count; //Index offset elements += quads*4; //Read new data and continue //geom[index]->indices.clear(); geom[index]->normals.clear(); //geom[index]->indices.read(indices.size(), &indices[0]); geom[index]->normals.read(normals.size(), normals[0].ref()); t1 = clock(); int bytes = indices.size()*sizeof(GLuint); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, offset, bytes, &indices[0]); t2 = clock(); debug_print(" %.4lf seconds to upload %d quad indices (%d - %d)\n", (t2-t1)/(double)CLOCKS_PER_SEC, indices.size(), offset, bytes); t1 = clock(); offset += bytes; GL_Error_Check; } }
particle_system::~particle_system() { if(glIsBuffer(lights_ubo)) glDeleteBuffers(1, &lights_ubo); #if !defined(FLOOR_NO_OPENCL) && 0 // TODO: update compute stuff if(data.ocl_pos_time_buffer != nullptr) ocl->delete_buffer(data.ocl_pos_time_buffer); if(data.ocl_dir_buffer != nullptr) ocl->delete_buffer(data.ocl_dir_buffer); if(data.ocl_distances != nullptr) ocl->delete_buffer(data.ocl_distances); if(data.ocl_indices[0] != nullptr) ocl->delete_buffer(data.ocl_indices[0]); if(data.ocl_indices[1] != nullptr) ocl->delete_buffer(data.ocl_indices[1]); if(glIsBuffer(data.ocl_gl_pos_time_vbo)) glDeleteBuffers(1, &data.ocl_gl_pos_time_vbo); if(glIsBuffer(data.ocl_gl_dir_vbo)) glDeleteBuffers(1, &data.ocl_gl_dir_vbo); #endif if(glIsBuffer(data.particle_indices_vbo[0])) glDeleteBuffers(1, &data.particle_indices_vbo[0]); if(glIsBuffer(data.particle_indices_vbo[1])) glDeleteBuffers(1, &data.particle_indices_vbo[1]); }
void DeleteGlobalVBO() { /*if (glIsBufferARB_p == NULL) return; if (glDeleteBuffersARB_p == NULL) return;*/ if (glIsBuffer(*GlobalVBO)) glDeleteBuffers(1, GlobalVBO); }
const bool GPUQuery::isBuffer(const GLuint buffer) { const bool is(glIsBuffer(buffer) == GL_TRUE); if(!is) glGetError(); return is; }
model_renderer::~model_renderer() { // remove from scene sce->delete_model(this); // don't let a2estatic delete these this->vertices = nullptr; this->tex_coords = nullptr; this->indices = nullptr; delete [] bindices; pm->delete_particle_system(ps); if(aux_data.ocl_aux_2 != nullptr) ocl->delete_buffer(aux_data.ocl_aux_2); if(glIsBuffer(bones_ubo)) glDeleteBuffers(1, &bones_ubo); r->delete_buffer(mesh_fbo); // Note: cl_fbos[2] and cl_fbos[3] are handled/deleted in another class ocl->delete_buffer(cl_fbos[0]); ocl->delete_buffer(cl_fbos[1]); for(const auto& l : lights) { sce->delete_light(l); delete l; } delete dummy_mat; }
void Texture2D::present(Shader *shader) { // One shared mesh for all texture presentation static GLuint vao, vbo; if (!glIsBuffer(vao)) { GLfloat vertices[] = { -1.0, -1.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, 1.0, 0.0, }; glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, 48, vertices, GL_STATIC_DRAW); GLint loc = shader->getAttribLocation("vPosition"); glEnableVertexAttribArray(loc); glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); } glBindFramebuffer(GL_FRAMEBUFFER, 0); glBlendFunc(GL_ONE, GL_ZERO); glBindVertexArray(vao); shader->use(); GLint texLoc = shader->getUniformLocation("texture0"); glUniform1i(texLoc, 0); bindToUnit(GL_TEXTURE0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); unbind(); }
void menuBox::clean() { if (glIsVertexArray(vao)) { glDeleteVertexArrays(1, &vao); } vao = 0; if (glIsBuffer(vertexbuffer)) { glDeleteBuffers(1, &vertexbuffer); } vertexbuffer = 0; if (glIsBuffer(indexbuffer)) { glDeleteBuffers(1, &indexbuffer); } indexbuffer = 0; }
void FrameBufferObject::DrawBind() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, this->ID); if (!glIsBuffer(this->ID)) { throw Exception(DSGL_FBO_DOESNT_EXIST, DSGL_MSG_CANNOT_CREATE_FBO); } glViewport(0,0,this->width,this->height); }
void shutdown() { // unregister buffer to cuda cudaGraphicsUnregisterResource(cuVboResource); cudaGraphicsUnregisterResource(cuIboResource); if(glIsBuffer(clothVBO)) glDeleteBuffers(1, &clothVBO); if (glIsBuffer(clothIBO)) glDeleteBuffers(1, &clothIBO); SAFE_DELETE(camera); SAFE_DELETE(volcanoShaderProgram); SAFE_DELETE(fireShaderProgram); }
MeshRenderer::~MeshRenderer() { if (glIsBuffer(m_vbo)) glDeleteBuffers(1, &m_vbo); if (glIsVertexArray(m_vao)) glDeleteVertexArrays(1, &m_vao); }
TGEnv::~TGEnv() { if(glIsBuffer(myBuffers[0])) glDeleteBuffers(3, myBuffers); if(glIsTexture(myTexture)) glDeleteTextures(1, &myTexture); }
static void freeBuffer(GLuint* idholder) { if (glIsBuffer(*idholder)) { glDeleteBuffers(1, idholder); } // printGLError(); }
GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer) { if (!buffer) return GL_FALSE; makeContextCurrent(); return glIsBuffer(buffer); }
static enum piglit_result test(void) { GLuint buffers[2]; if (glIsBuffer(0)) { printf("%s: glIsBuffer(0) returned true instead of false.\n", TestName); return PIGLIT_FAIL; } glGenBuffers(2, buffers); if (buffers[0] == 0 || buffers[1] == 0 || buffers[0] == buffers[1]) { printf("%s: glGenBuffers failed\n", TestName); return PIGLIT_FAIL; } if (piglit_is_extension_supported("GL_EXT_pixel_buffer_object")) { glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, buffers[0]); if (glGetError()) { printf("%s: glBindBuffer failed\n", TestName); return PIGLIT_FAIL; } if (!glIsBuffer(buffers[0])) { printf("%s: glIsBuffer(%u) returned false instead of true.\n", TestName, buffers[0]); return PIGLIT_FAIL; } } /* * The GL spec is vague here. But the GL man pages say glIsBuffer should * return false in this case. Mesa and NVIDIA's driver return true. * Generate a warning, not an error, if the driver doesn't follow the * GL docs here. */ if (glIsBuffer(buffers[1])) { printf("%s: glIsBuffer(%u) returned true instead of false.\n", TestName, buffers[1]); return PIGLIT_WARN; } return PIGLIT_PASS; }
void mesh_opengl::update_vbo_texture(mesh_basic const& m) { //VBO vertex glBindBuffer(GL_ARRAY_BUFFER,vbo_texture); PRINT_OPENGL_ERROR(); ASSERT_CPE(glIsBuffer(vbo_texture),"vbo_buffer incorrect"); glBufferSubData(GL_ARRAY_BUFFER,0,3*sizeof(float)*m.size_texture_coord(),m.pointer_texture_coord()); PRINT_OPENGL_ERROR(); }
template<> template<> const GlObject<GlObject_Type::Buffer>* GlObject<GlObject_Type::Resource>::ResourceCast() const { if (glIsBuffer(RawGLHandle(this))) { return (GlObject<GlObject_Type::Buffer>*)(this); } else { return (GlObject<GlObject_Type::Buffer>*)RawGLHandle_Invalid; } }