// display texture // XXX: NEEDS TO BE IMPLEMENTED void Texture::display(void){ // setup model matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.5, 0.5, 0.5, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(rayTraceMode){ normQuadShader.bind(); rayTexture.bind(); quad.draw(); normQuadShader.unbind(); rayTexture.unbind(); }else{ mesh1.draw(); mesh.draw(); mesh2.draw(); } glutSwapBuffers(); // glPopAttrib(); }
//release all allocated resources here void OnShutdown() { //delete all textures size_t total_textures = materialMap.size(); for(size_t i=0;i<total_textures;i++) { if(materialNames[i].length()>0) glDeleteTextures(1, &materialMap[materialNames[i]]); } materialNames.clear(); materialMap.clear(); submeshes.clear(); vertices.clear(); indices.clear(); skeleton.clear(); animations.clear(); dualQuaternions.clear(); animatedXform.clear(); skeleton.clear(); bindPose.clear(); invBindPose.clear(); //Destroy shader shader.DeleteShaderProgram(); flatShader.DeleteShaderProgram(); //Destroy vao and vbo glDeleteBuffers(1, &vboVerticesID); glDeleteBuffers(1, &vboIndicesID); glDeleteVertexArrays(1, &vaoID); glDeleteVertexArrays(1, &lightVAOID); glDeleteVertexArrays(1, &lightVerticesVBO); cout<<"Shutdown successfull"<<endl; }
void OnShutdown() { X.clear(); X_last.clear(); F.clear(); indices.clear(); springs.clear(); glDeleteQueries(1, &query); glDeleteQueries(1, &t_query); glDeleteTextures( 2, texPosID); glDeleteTextures( 2, texPrePosID); glDeleteVertexArrays(2, vaoUpdateID); glDeleteVertexArrays(2, vaoRenderID); glDeleteVertexArrays(1, &clothVAOID); glDeleteVertexArrays(1, &gridVAOID); glDeleteBuffers( 1, &gridVBOVerticesID); glDeleteBuffers( 1, &gridVBOIndicesID); glDeleteBuffers( 1, &clothVBOVerticesID); glDeleteBuffers( 1, &clothVBOIndicesID); glDeleteBuffers( 2, vboID_Pos); glDeleteBuffers( 2, vboID_PrePos); glDeleteBuffers( 1, &vboIndices); glDeleteTransformFeedbacks(1, &tfID); renderShader.DeleteProgram(); massSpringShader.DeleteProgram(); particleShader.DeleteProgram(); }
//display callback void OnRender() { //get the elapse time time = glutGet(GLUT_ELAPSED_TIME)/1000.0f * SPEED; //clear the colour and depth buffers glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //set teh camera viewing transformation glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, dist)); glm::mat4 Rx = glm::rotate(T, rX, glm::vec3(1.0f, 0.0f, 0.0f)); glm::mat4 MV = glm::rotate(Rx, rY, glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 MVP = P*MV; //bind the shader shader.Use(); //set the shader uniforms glUniformMatrix4fv(shader("MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); glUniform1f(shader("time"), time); //draw the mesh triangles glDrawElements(GL_TRIANGLES, TOTAL_INDICES, GL_UNSIGNED_SHORT, 0); //unbind the shader shader.UnUse(); //swap front and back buffers to show the rendered result glutSwapBuffers(); }
//display function void OnRender() { //clear colour and depth buffers glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //set the camera transform glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, dist)); glm::mat4 Rx = glm::rotate(T, rX, glm::vec3(1.0f, 0.0f, 0.0f)); glm::mat4 Ry = glm::rotate(Rx, rY, glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 MV = Ry; glm::mat4 MVP = P*MV; //since we have kept the terrain vertex array object bound //it is still bound to the context so we can directly call draw element //which will draw vertices from the bound vertex array object //bind the terrain shader shader.Use(); //pass shader uniforms glUniformMatrix4fv(shader("MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); //draw terrain mesh glDrawElements(GL_TRIANGLES, TOTAL_INDICES, GL_UNSIGNED_INT, 0); //unbind shader shader.UnUse(); //swap front and back buffers to show the rendered result glutSwapBuffers(); }
//function to render scene given the combined modelview projection matrix //and a shader void DrawScene(const glm::mat4& MVP, GLSLShader& shader) { //enable alpha blending with over compositing glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //bind the cube vertex array object glBindVertexArray(cubeVAOID); //bind the shader shader.Use(); //for all cubes for(int k=-1;k<=1;k++) { for(int j=-1;j<=1;j++) { int index =0; for(int i=-1;i<=1;i++) { GL_CHECK_ERRORS //set the modelling transformation and shader uniforms glm::mat4 T = glm::translate(glm::mat4(1), glm::vec3(i*2,j*2,k*2)); glUniform4fv(shader("vColor"),1, &(box_colors[index++].x)); glUniformMatrix4fv(shader("MVP"), 1, GL_FALSE, glm::value_ptr(MVP*R*T)); //draw the cube glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0); GL_CHECK_ERRORS } } } //unbind shader shader.UnUse(); //unbind vertex array object glBindVertexArray(0); }
//release all allocated resources void OnShutdown() { glDeleteTextures(1, &shadowMapTexID); //Destroy shader shader.DeleteShaderProgram(); flatshader.DeleteShaderProgram(); //Destroy vao and vbo glDeleteBuffers(1, &sphereVerticesVBO); glDeleteBuffers(1, &sphereIndicesVBO); glDeleteVertexArrays(1, &sphereVAOID); glDeleteBuffers(1, &cubeVerticesVBO); glDeleteBuffers(1, &cubeIndicesVBO); glDeleteVertexArrays(1, &cubeVAOID); glDeleteBuffers(1, &planeVerticesVBO); glDeleteBuffers(1, &planeIndicesVBO); glDeleteVertexArrays(1, &planeVAOID); glDeleteVertexArrays(1, &lightVAOID); glDeleteBuffers(1, &lightVerticesVBO); glDeleteFramebuffers(1,&fboID); cout<<"Shutdown successfull"<<endl; }
//renders sphere using the render shader void DrawSphere(const glm::mat4& mvp) { renderShader.Use(); glBindVertexArray(sphereVAOID); glUniformMatrix4fv(renderShader("MVP"), 1, GL_FALSE, glm::value_ptr(mvp)); glDrawElements(GL_TRIANGLES, total_sphere_indices,GL_UNSIGNED_SHORT,0); renderShader.UnUse(); }
void DrawGrid() { renderShader.Use(); glBindVertexArray(gridVAOID); glUniformMatrix4fv(renderShader("MVP"), 1, GL_FALSE, glm::value_ptr(mMVP)); glDrawElements(GL_LINES, grid_indices.size(),GL_UNSIGNED_SHORT,0); glBindVertexArray(0); renderShader.UnUse(); }
void DrawCloth() { renderShader.Use(); glBindVertexArray(clothVAOID); glUniformMatrix4fv(renderShader("MVP"), 1, GL_FALSE, glm::value_ptr(mMVP)); glDrawElements(GL_TRIANGLES, indices.size(),GL_UNSIGNED_SHORT,0); //glBindVertexArray(0); renderShader.UnUse(); }
void GLSLProgram::setTransformFeedbackVaryings(const std::vector<String>& nameStrings) { // Get program object ID. GLuint programId; if (Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) { //TODO include tessellation stages GLSLShader* glslGpuProgram = getGeometryShader(); if (!glslGpuProgram) glslGpuProgram = getVertexShader(); programId = glslGpuProgram->getGLProgramHandle(); // force re-link GpuProgramManager::getSingleton().removeMicrocodeFromCache(glslGpuProgram->_getHash()); glslGpuProgram->setLinked(false); } else { programId = getGLProgramHandle(); // force re-link GpuProgramManager::getSingleton().removeMicrocodeFromCache(getCombinedHash()); } mLinked = false; // Convert to const char * for GL std::vector<const char*> names; for (uint e = 0; e < nameStrings.size(); e++) { names.push_back(nameStrings[e].c_str()); } // TODO replace glTransformFeedbackVaryings with in-shader specification (GL 4.4) OGRE_CHECK_GL_ERROR(glTransformFeedbackVaryings(programId, nameStrings.size(), &names[0], GL_INTERLEAVED_ATTRIBS)); #if OGRE_DEBUG_MODE activate(); // Check if varyings were successfully set. GLchar Name[64]; GLsizei Length(0); GLsizei Size(0); GLenum Type(0); // bool Validated = false; for (size_t i = 0; i < nameStrings.size(); i++) { OGRE_CHECK_GL_ERROR( glGetTransformFeedbackVarying(programId, i, 64, &Length, &Size, &Type, Name)); LogManager::getSingleton().stream() << "Varying " << i << ": " << Name << " " << Length << " " << Size << " " << Type; // Validated = (Size == 1) && (Type == GL_FLOAT_VEC3); // std::cout << Validated << " " << GL_FLOAT_VEC3 << std::endl; } #endif }
void onInit() { //tex = loadImage("../textures/texture.png"); tex = loadImage("../textures/dots.png"); tex2 = loadImage("../textures/dots.png"); ctv = new CTextureViewer(0, "../shaders/textureViewer.vs", "../shaders/textureViewer.frag"); ctv->setTexture(tex); ctv->setTexture2(tex2); hist.LoadFromFile(GL_VERTEX_SHADER, "../shaders/histogram.vs"); hist.LoadFromFile(GL_FRAGMENT_SHADER, "../shaders/histogram.frag"); hist.CreateAndLinkProgram(); hist.Use(); //Create uniforms and attributes (filled later) hist.AddAttribute("vPosition"); hist.AddUniform("tex"); hist.AddUniform("textureWidth"); hist.AddUniform("textureHeight"); hist.UnUse(); initTex(); initPointVBO(); initHistogramFBO(); }
void computeHistogram() { glViewport(0, 0, WIDTH, HEIGHT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.0, 0.0, 0.0, 0.0); glDisable(GL_DEPTH_TEST); //Enable blending glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); //Additive glBlendEquation(GL_FUNC_ADD); hist.Use(); glBindBuffer(GL_ARRAY_BUFFER, HistogramVBO); glVertexAttribPointer(hist["vPosition"], 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GL_FLOAT), (void*)0); glEnableVertexAttribArray(hist["vPosition"]); glUniform1i(hist("tex"), 0); glUniform1f(hist("textureWidth"), (float)WIDTH); glUniform1f(hist("textureHeight"), (float)HEIGHT); glBindFramebuffer(GL_FRAMEBUFFER, FBO); //glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Compute histogram glDrawArrays(GL_POINTS, 0, WIDTH*HEIGHT); glBindBuffer(GL_ARRAY_BUFFER, 0); hist.UnUse(); //Disable blending glDisable(GL_BLEND); float hPixels[256]; glReadPixels(0, 0, 256, 1, GL_BLUE, GL_FLOAT, hPixels); int sum = 0; if (printed != 0) { cout << "\n\n-----------\n\n"; for(int j = 0; j < 256; j++) { //if((j % 3) == 0) cout << j << ":" << hPixels[j] << endl; sum += hPixels[j]; } cout << endl << sum << endl; printed--; } glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
//display callback function void OnRender() { GL_CHECK_ERRORS //clear colour and depth buffers glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //set the camera transform glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, dist)); glm::mat4 Rx = glm::rotate(T, rX, glm::vec3(1.0f, 0.0f, 0.0f)); glm::mat4 MV = glm::rotate(Rx, rY, glm::vec3(0.0f, 1.0f, 0.0f)); //1) Render scene from the light's POV //enable rendering to FBO glBindFramebuffer(GL_FRAMEBUFFER,fboID); //clear depth buffer glClear(GL_DEPTH_BUFFER_BIT); //reset viewport to the shadow map texture size glViewport(0,0,SHADOWMAP_WIDTH, SHADOWMAP_HEIGHT); //enable front face culling glCullFace(GL_FRONT); //draw scene from the point of view of light DrawScene(MV_L, P_L); //enable back face culling glCullFace(GL_BACK); //restore normal rendering path //unbind FBO, set the default back buffer and reset the viewport to screen size glBindFramebuffer(GL_FRAMEBUFFER,0); glDrawBuffer(GL_BACK_LEFT); glViewport(0,0,WIDTH, HEIGHT); //2) Render scene from point of view of eye DrawScene(MV, P, 0 ); //bind light gizmo vertex array object glBindVertexArray(lightVAOID); { //set the flat shader flatshader.Use(); //set the light's transform and render 3 lines glm::mat4 T = glm::translate(glm::mat4(1), lightPosOS); glUniformMatrix4fv(flatshader("MVP"), 1, GL_FALSE, glm::value_ptr(P*MV*T)); glDrawArrays(GL_LINES, 0, 6); //unbind shader flatshader.UnUse(); } //unbind the vertex array object glBindVertexArray(0); //swap front and back buffers to show the rendered result glutSwapBuffers(); }
void DrawClothPoints() { particleShader.Use(); //glBindVertexArray(clothVAOID); glUniform1i(particleShader("selected_index"), selected_index); glUniformMatrix4fv(particleShader("MV"), 1, GL_FALSE, glm::value_ptr(mMV)); glUniformMatrix4fv(particleShader("MVP"), 1, GL_FALSE, glm::value_ptr(mMVP)); //draw the masses last glDrawArrays(GL_POINTS, 0, total_points); glBindVertexArray(0); particleShader.UnUse(); }
void OnRender() { glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); GL_CHECK_ERRORS shader.Use(); drawDefaultBox(); shader.UnUse(); glutSwapBuffers(); }
//display function void OnRender() { //clear the colour and depth buffers glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //bind shader shader.Use(); //draw the full screen quad glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); //unbind shader shader.UnUse(); //swap front and back buffers to show the rendered result glutSwapBuffers(); }
void OnRender() { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, dist)); glm::mat4 Rx = glm::rotate(T, rX, glm::vec3(1.0f, 0.0f, 0.0f)); glm::mat4 Ry = glm::rotate(Rx, rY, glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 MV = Ry; glm::mat4 MVP = P*MV; //glBindVertexArray(vaoID); shader.Use(); glUniformMatrix4fv(shader("MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); glDrawElements(GL_TRIANGLES, TOTAL_INDICES, GL_UNSIGNED_INT, 0); shader.UnUse(); //glBindVertexArray(0); glutSwapBuffers(); }
Shader *GLSLShaderModule::createShader(TiXmlNode *node) { TiXmlNode* pChild, *pChild2, *pChild3; GLSLProgram *vp = NULL; GLSLProgram *fp = NULL; GLSLShader *retShader = NULL; for (pChild = node->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { if(strcmp(pChild->Value(), "vp") == 0) { vp = (GLSLProgram*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_PROGRAM, String(pChild->ToElement()->Attribute("source"))); if(vp) { for (pChild2 = pChild->FirstChild(); pChild2 != 0; pChild2 = pChild2->NextSibling()) { if(strcmp(pChild2->Value(), "params") == 0) { for (pChild3 = pChild2->FirstChild(); pChild3 != 0; pChild3 = pChild3->NextSibling()) { if(strcmp(pChild3->Value(), "param") == 0) { addParamToProgram(vp,pChild3); } } } } } } if(strcmp(pChild->Value(), "fp") == 0) { fp = (GLSLProgram*)CoreServices::getInstance()->getResourceManager()->getResource(Resource::RESOURCE_PROGRAM, String(pChild->ToElement()->Attribute("source"))); if(fp) { for (pChild2 = pChild->FirstChild(); pChild2 != 0; pChild2 = pChild2->NextSibling()) { if(strcmp(pChild2->Value(), "params") == 0) { for (pChild3 = pChild2->FirstChild(); pChild3 != 0; pChild3 = pChild3->NextSibling()) { if(strcmp(pChild3->Value(), "param") == 0) { addParamToProgram(fp,pChild3); } } } } } } } if(vp != NULL && fp != NULL) { GLSLShader *cgShader = new GLSLShader(vp,fp); cgShader->setName(String(node->ToElement()->Attribute("name"))); retShader = cgShader; shaders.push_back((Shader*)cgShader); } return retShader; }
void init() { pointList.clear(); pointList.push_back(Vector3(0, 0, 0)); generateVertexBuffer(); VBOInfo.vertexBufferSize = static_cast<int>(pointList.size()) * 3; VBOInfo.vertexBufferData = vertexBufferData; buffer.initVBO(VBOInfo, HardwareBuffer::FLAG_VERTEX_BUFFER); buffer.setVBOLocation(HardwareBuffer::FLAG_VERTEX_BUFFER, 0); buffer.setVBOUnitSize(HardwareBuffer::FLAG_VERTEX_BUFFER, 3); pointProgram.loadFromFile(GL_VERTEX_SHADER, "Shader/point.vs"); pointProgram.loadFromFile(GL_FRAGMENT_SHADER, "Shader/point.fs"); pointProgram.loadFromFile(GL_GEOMETRY_SHADER, "Shader/point.gs"); pointProgram.createProgram(); }
//release all allocated resources void OnShutdown() { shader.DeleteShaderProgram(); glDeleteVertexArrays(1, &volumeMarcherVAO); glDeleteBuffers(1, &volumeMarcherVBO); delete grid; delete marcher; cout<<"Shutdown successfull"<<endl; }
void InitShaders(void) { shader.LoadFromFile(GL_VERTEX_SHADER, "../CGE_solarsystem/shader.vert"); shader.LoadFromFile(GL_FRAGMENT_SHADER, "../CGE_solarsystem/shader.frag"); shader.CreateAndLinkProgram(); shader.Use(); shader.AddAttribute("vVertex"); shader.AddAttribute("vUV"); shader.AddUniform("MVP"); shader.AddUniform("textureMap"); glUniform1i(shader("textureMap"), 0); shader.UnUse(); GL_CHECK_ERRORS }
//display callback function void OnRender() { GL_CHECK_ERRORS //set the camera transform glm::mat4 Tr = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, dist)); glm::mat4 Rx = glm::rotate(Tr, rX, glm::vec3(1.0f, 0.0f, 0.0f)); glm::mat4 MV = glm::rotate(Rx, rY, glm::vec3(0.0f, 1.0f, 0.0f)); //clear the colour and depth buffers glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //get the combined modelview projection matrix glm::mat4 MVP = P*MV; //render the grid object grid->Render(glm::value_ptr(MVP)); //set the modelling transform to move the marhing result to origin glm::mat4 T = glm::translate(glm::mat4(1), glm::vec3(-0.5,-0.5,-0.5)); //if rendering mode set to wireframe we set the front and back //polygon mode to line if(bWireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //set the volume marcher vertex array object glBindVertexArray(volumeMarcherVAO); //bind the shader shader.Use(); //set the shader uniforms glUniformMatrix4fv(shader("MVP"), 1, GL_FALSE, glm::value_ptr(MVP*T)); //render the triangles glDrawArrays(GL_TRIANGLES, 0, marcher->GetTotalVertices()); //unbind the shader shader.UnUse(); //restore the default polygon mode if(bWireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //swap front and back buffers to show the rendered result glutSwapBuffers(); }
bool GLInputVertexAttribute::Enable() { if (isCreateOK()) { bool result = false; GLSLShader* shader = (dynamic_cast<GLRenderable*>(this->getRenderable()))->getShader(); GLMesh* mesh = (dynamic_cast<GLRenderable*>(this->getRenderable()))->getMesh(); if (shader->isCreateOK() && shader->isEnableOK() && mesh != NULL) { m_IAHandle = glGetAttribLocation(shader->getProgramHandle(), m_InputVertexAttributeName.c_str()); LOGD("call glGetAttribLocation(%d, %s), get the input attribute handle is %d", shader->getProgramHandle(), m_InputVertexAttributeName.c_str(), m_IAHandle); if (m_IAHandle != -1) { glEnableVertexAttribArray(m_IAHandle); if (mesh->isUseCPUBuffer()) { // use cpu memory's vertex buffer pointer glVertexAttribPointer(m_IAHandle, m_IAElementNum, m_IAType, m_IANormalized, m_IAStride, (BYTE*)(mesh->getVertexDataPointer()) + m_IAOffset); } else { // use gpu memory's vertex buffer glBindBuffer(GL_ARRAY_BUFFER, mesh->getVBOHandle()); glVertexAttribPointer(m_IAHandle, m_IAElementNum, m_IAType, m_IANormalized, m_IAStride, (BYTE*)m_IAOffset); } result = true; } else { LOGE("glGetAttribLocation return -1"); result = false; } } m_bIsEnableOK = result; } return isEnableOK(); }
//release all allocated resources void OnShutdown() { //Destroy shader shader.DeleteShaderProgram(); cubemapShader.DeleteShaderProgram(); //Destroy vao and vbo glDeleteBuffers(1, &sphereVerticesVBO); glDeleteBuffers(1, &sphereIndicesVBO); glDeleteVertexArrays(1, &sphereVAOID); delete grid; delete cube; glDeleteTextures(1, &dynamicCubeMapID); glDeleteFramebuffers(1, &fboID); glDeleteRenderbuffers(1, &rboID); cout<<"Shutdown successfull"<<endl; }
//release all allocated resources void OnShutdown() { shader.DeleteShaderProgram(); glDeleteVertexArrays(1, &cubeVAOID); glDeleteBuffers(1, &cubeVBOID); glDeleteBuffers(1, &cubeIndicesID); glDeleteTextures(1, &textureID); delete grid; cout<<"Shutdown successfull"<<endl; }
//delete all allocated resources void OnShutdown() { //Destroy shader shader.DeleteShaderProgram(); //Destroy vao and vbo glDeleteBuffers(1, &vboVerticesID); glDeleteBuffers(1, &vboIndicesID); glDeleteVertexArrays(1, &vaoID); cout<<"Shutdown successfull"<<endl; }
//release all allocated resources void OnShutdown() { glDeleteVertexArrays(1, &quadVAOID); glDeleteBuffers(1, &quadVBOID); glDeleteBuffers(1, &quadIndicesID); //delete all textures glDeleteTextures(1, &textureID); //delete all meshes size_t total_meshes = meshes.size(); for(size_t i=0;i<total_meshes;i++) { delete meshes[i]; meshes[i]=0; } meshes.clear(); size_t total_materials = materials.size(); for( size_t i=0;i<total_materials;i++) { delete materials[i]; materials[i] = 0; } materials.clear(); //Destroy shader shader.DeleteShaderProgram(); raytraceShader.DeleteShaderProgram(); flatShader.DeleteShaderProgram(); //Destroy vao and vbo glDeleteBuffers(1, &vboVerticesID); glDeleteBuffers(1, &vboIndicesID); glDeleteVertexArrays(1, &vaoID); glDeleteVertexArrays(1, &lightVAOID); glDeleteBuffers(1, &lightVerticesVBO); glDeleteTextures(1, &texVerticesID); glDeleteTextures(1, &texTrianglesID); cout<<"Shutdown successfull"<<endl; }
void render(uint textureId) { pointProgram.bind(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureId); generateVertexBuffer(); HardwareBuffer::VBOStruct _VBO; _VBO.vertexBufferData = vertexBufferData; _VBO.vertexBufferSize = static_cast<int>(pointList.size()) * 3; buffer.updateVBO(_VBO, HardwareBuffer::FLAG_VERTEX_BUFFER); buffer.render(GL_POINTS); glDisable(GL_BLEND); pointProgram.unbind(); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); }
//release all allocated resources void OnShutdown() { cubeShader.DeleteShaderProgram(); frontPeelShader.DeleteShaderProgram(); blendShader.DeleteShaderProgram(); finalShader.DeleteShaderProgram(); shutdownFBO(); glDeleteQueries(1, &queryId); glDeleteVertexArrays(1, &quadVAOID); glDeleteBuffers(1, &quadVBOID); glDeleteBuffers(1, &quadIndicesID); glDeleteVertexArrays(1, &cubeVAOID); glDeleteBuffers(1, &cubeVBOID); glDeleteBuffers(1, &cubeIndicesID); delete grid; cout<<"Shutdown successfull"<<endl; }