void ParticleRenderer::display(DisplayMode mode /* = PARTICLE_POINTS */) { switch (mode) { case PARTICLE_POINTS: glColor3f(1, 1, 1); glPointSize(m_pointSize); _drawPoints(); break; default: case PARTICLE_SPHERES: glEnable(GL_POINT_SPRITE_ARB); glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glUseProgram(m_program); glUniform1f( glGetUniformLocation(m_program, "pointScale"), m_window_h / tanf(m_fov*0.5f*(float)M_PI/180.0f) ); glUniform1f( glGetUniformLocation(m_program, "pointRadius"), m_particleRadius ); glColor3f(1, 1, 1); _drawPoints(); glUseProgram(0); glDisable(GL_POINT_SPRITE_ARB); break; } }
void Renderer::drawpointsprite(){ glEnable(GL_POINT_SPRITE_ARB); glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); m_program->enable(); m_program->setUniform1f("pointScale", m_window_h / tanf(m_fov*0.5f*(float)M_PI / 180.0f)); //m_program->setUniform1f("pointRadius", m_particleRadius); m_program->setUniform1f("pointRadius", 0.5f); m_program->setUniform3f("lightPositionIn", 32.0f,128.0f,32.0f); //m_program->setUniform1f("near", 0.1f); //m_program->setUniform1f("far", 3000.0f); glColor4f(1, 1, 1, 0.5); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); _drawPoints(); glDisable(GL_BLEND); m_program->disable(); glDisable(GL_POINT_SPRITE_ARB); }
void ParticleRenderer::display(DisplayMode mode /* = PARTICLE_POINTS */) { switch (mode) { case PARTICLE_POINTS: glColor3f(1, 1, 1); glPointSize(m_pointSize); _drawPoints(); break; case PARTICLE_SPRITES: default: { // setup point sprites glEnable(GL_POINT_SPRITE_ARB); glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); glPointSize(m_spriteSize); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); glDepthMask(GL_FALSE); glUseProgram(m_program); GLuint texLoc = glGetUniformLocation(m_program, "splatTexture"); glUniform1i(texLoc, 0); glActiveTextureARB(GL_TEXTURE0_ARB); glBindTexture(GL_TEXTURE_2D, m_texture); glColor3f(1, 1, 1); glSecondaryColor3fv(m_baseColor); _drawPoints(); glUseProgram(0); glDisable(GL_POINT_SPRITE_ARB); glDisable(GL_BLEND); glDepthMask(GL_TRUE); } break; case PARTICLE_SPRITES_COLOR: { // setup point sprites glEnable(GL_POINT_SPRITE_ARB); glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); glPointSize(m_spriteSize); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); glDepthMask(GL_FALSE); glUseProgram(m_program); GLuint texLoc = glGetUniformLocation(m_program, "splatTexture"); glUniform1i(texLoc, 0); glActiveTextureARB(GL_TEXTURE0_ARB); glBindTexture(GL_TEXTURE_2D, m_texture); glColor3f(1, 1, 1); glSecondaryColor3fv(m_baseColor); _drawPoints(true); glUseProgram(0); glDisable(GL_POINT_SPRITE_ARB); glDisable(GL_BLEND); glDepthMask(GL_TRUE); } break; } CUT_CHECK_ERROR_GL(); }
void ParticleRenderer::display() { if (b_renderSkyBox){ drawSkyBox(); } if (b_renderFloor){ drawFloor(); } switch (_displayMode) { case PARTICLE_POINTS: { glColor3f(1, 1, 1); glPointSize(1.0f); _drawPoints(); } break; case PARTICLE_FIRE: { glPointSize(4.0f); float m_baseColor[4] = { 0.6f, 0.1f, 0.0f, 0.95f}; glColor4f(m_baseColor[0],m_baseColor[1],m_baseColor[2],m_baseColor[3]); glEnable (GL_POINT_SMOOTH); glHint (GL_POINT_SMOOTH_HINT, GL_NICEST); glAlphaFunc(GL_GREATER, 0.1); glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); glDepthMask(GL_FALSE); // Disable depth buffer updating! (Integral to transparency!) _drawPoints(false); glDepthMask(GL_TRUE); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); } break; case SPRITE_COSMOS: { glEnable(GL_POINT_SPRITE_ARB); // setup point sprites glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); glDepthMask(GL_FALSE); glUseProgram(m_program_cosmos); GLuint texLoc = glGetUniformLocation(m_program_cosmos, "splatTexture"); glUniform1i(texLoc, 0); glActiveTextureARB(GL_TEXTURE0_ARB); glBindTexture(GL_TEXTURE_2D, m_texture); glColor3f(1, 1, 1); glPointSize(m_particleRadius*2.0f); //float m_baseColor[4] = {0.6f, 0.1f, 0.0f, 0.95f}; float m_baseColor[4] = { 1.0f, 0.6f, 0.3f, 0.20f}; // nbody fp32 color (yellow) //float m_baseColor[4] = { 0.4f, 0.8f, 0.1f, 1.0f}; // nbody fp64 color (green) glSecondaryColor3fv(m_baseColor); _drawPoints(); glUseProgram(0); glDisable(GL_POINT_SPRITE_ARB); glDisable(GL_BLEND); glDepthMask(GL_TRUE); } break; default: case PARTICLE_SPHERES: { glEnable(GL_POINT_SPRITE_ARB); glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glUseProgram(m_program_sphere); glUniform1f( glGetUniformLocation(m_program_sphere, "pointScale"), m_window_h / tanf(m_fov*0.5f*(float)M_PI/180.0f) ); glUniform1f( glGetUniformLocation(m_program_sphere, "pointRadius"), m_particleRadius ); glColor3f(1, 1, 1); _drawPoints(); glUseProgram(0); glDisable(GL_POINT_SPRITE_ARB); } break; } }
void Renderer::display(DisplayMode mode, GLSLProgram *prog) { switch (mode) { case PARTICLE_POINTS: glColor3f(1, 1, 1); glPointSize(m_pointSize); _drawPoints(); break; case PARTICLE_FLUID: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); glColor4f(0.5, 0.5, 0.5, 0.1); glEnable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); // don't write depth glEnable(GL_BLEND); prog->enable(); //prog->setUniform1f("pointRadius", mParticleRadius); prog->setUniform1f("pointRadius", 0.5f); glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); glVertexPointer(4, GL_FLOAT, 0, 0); glEnableClientState(GL_VERTEX_ARRAY); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexBuffer); glDrawElements(GL_POINTS, m_numParticles, GL_UNSIGNED_INT, (void *)(0 * sizeof(unsigned int))); //glDrawArrays(GL_POINTS, 0, m_numParticles); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); prog->disable(); glDepthMask(GL_TRUE); glDisable(GL_BLEND); default: case PARTICLE_SPHERES: //glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); //glColor4f(0.5, 0.5, 0.5, 0.1); //glEnable(GL_DEPTH_TEST); //glDepthMask(GL_FALSE); // don't write depth //glEnable(GL_BLEND); //prog->enable(); ////prog->setUniform1f("pointRadius", mParticleRadius); //prog->setUniform1f("pointRadius", 1.5f); //glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); //glVertexPointer(4, GL_FLOAT, 0, 0); //glEnableClientState(GL_VERTEX_ARRAY); //if (m_colorVBO){ // glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_colorVBO); // glColorPointer(4, GL_FLOAT, 0, 0); // glEnableClientState(GL_COLOR_ARRAY); //} //if (m_velVbo) //{ // glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_velVbo); // glClientActiveTexture(GL_TEXTURE0); // glTexCoordPointer(4, GL_FLOAT, 0, 0); // glEnableClientState(GL_TEXTURE_COORD_ARRAY); //} //if (m_indexBuffer){ // glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexBuffer); // glDrawElements(GL_POINTS, m_numParticles, GL_UNSIGNED_INT, (void *)(0 * sizeof(unsigned int))); // glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); //} //glDisableClientState(GL_VERTEX_ARRAY); //glDisableClientState(GL_COLOR_ARRAY); //prog->disable(); //glDepthMask(GL_TRUE); //glDisable(GL_BLEND); m_imageFbo->Bind(); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); m_imageFbo->Disable(); glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); m_imageFbo->Bind(); glViewport(0, 0, m_imageW, m_imageH); glColor4f(1.0, 1.0, 1.0, 1.0); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); drawpointsprite(); m_imageFbo->Disable(); glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); //drawPostProcess(); compositeResult(); //m_program->enable(); //glBindBuffer(GL_ARRAY_BUFFER, m_vbo); //glVertexPointer(4, GL_FLOAT, 0, 0); //glEnableClientState(GL_VERTEX_ARRAY); ///*glBindBufferARB(GL_ARRAY_BUFFER_ARB, normalVbo); //glNormalPointer(GL_FLOAT, sizeof(float) * 4, 0); //glEnableClientState(GL_NORMAL_ARRAY);*/ //glColor3f(1.0, 0.0, 0.0); //glDrawArrays(GL_TRIANGLES, 0, totalVerts); //glDisableClientState(GL_VERTEX_ARRAY); //glDisableClientState(GL_NORMAL_ARRAY); //glBindBuffer(GL_ARRAY_BUFFER, 0); //m_program->disable(); // break; } }