void redraw(void) { int start, end; if (reportSpeed) { start = glutGet(GLUT_ELAPSED_TIME); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); /* repere camera */ tbVisuTransform(); /* origine et orientation de la scene */ glScalef(zoom,zoom,zoom); glTranslatef( -sx/2., -sy/2., -sz*hz/2.); drawSlices(); drawSlicesBoundary(); drawIsoCurveZ(); drawIsoCurveX(); drawIsoCurveY(); if (reportSpeed) { glFinish(); end = glutGet(GLUT_ELAPSED_TIME); printf("Speed %.3g frames/sec (%d ms)\n", 1000.0/(end-start), end-start); } glutSwapBuffers(); }
void SmokeRenderer::render() { switch(mDisplayMode) { case POINTS: glColor3f(1.0, 1.0, 1.0); m_simpleProg->enable(); drawPoints(0, mNumParticles, false); m_simpleProg->disable(); break; case SPRITES: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); glColor4f(1.0, 1.0, 1.0, m_spriteAlpha); drawPointSprites(m_particleProg, 0, mNumParticles, false); break; case VOLUMETRIC: drawSlices(); compositeResult(); break; case NUM_MODES: break; } if (m_displayLightBuffer) { // display light buffer to screen glViewport(0, 0, m_lightBufferSize, m_lightBufferSize); glDisable(GL_DEPTH_TEST); displayTexture(m_lightTexture[m_srcLightTexture]); glViewport(0, 0, mWindowW, mWindowH); } glutReportErrors(); }
void QwtPieCurve::draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const { int size = dataSize(); if (!painter || size <= 0) return; if (to < 0) to = size - 1; if (size > 1) drawSlices(painter, xMap, yMap, from, to); else drawDisk(painter, xMap, yMap); }
void VHParticlesRender::draw(){ if (pSys->nParts == -1) return; if(displayMode == SHADOWED_SPRITES) { calcVectors(); cu::float3 halfVec = cu::make_float3(halfVector.x,halfVector.y,halfVector.z); calcDepthCu(pSys->dev_pos, pSys->dev_keys, pSys->dev_indices, halfVec, pSys->nParts); if (sortParts) cudppSort(m_sortHandle, pSys->dev_keys, pSys->dev_indices, 32, pSys->nParts); } if((displayMode == SPRITES || displayMode == POINTS) && sortParts) { glGetFloatv(GL_MODELVIEW_MATRIX, (float *) modelView.get_value()); viewVector = -vec3f(modelView.get_row(2)); cu::float3 viewVec = cu::make_float3(viewVector.x, viewVector.y, viewVector.y); //printf("view vec : %f, %f, %f \n", viewVector.x, viewVector.y, viewVector.z); calcDepthCu(pSys->dev_pos, pSys->dev_keys, pSys->dev_indices, viewVec, pSys->nParts); cudppSort(m_sortHandle, pSys->dev_keys, pSys->dev_indices, 32, pSys->nParts); } pSys->posVbo->map(); pSys->colourVbo->map(); pSys->indexVbo->map(); pSys->updateVBOs(); pSys->posVbo->unmap(); pSys->colourVbo->unmap(); pSys->indexVbo->unmap(); switch (displayMode) { case POINTS: glPointSize(pointSize); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); pSys->posVbo->bind(); glVertexPointer(3, GL_FLOAT, 0, 0); glEnableClientState(GL_VERTEX_ARRAY); pSys->colourVbo->bind(); glColorPointer(4, GL_FLOAT, 0, 0); glEnableClientState(GL_COLOR_ARRAY); if (blendingMode == ADD) { glBlendFunc( GL_SRC_ALPHA, GL_ONE ); glDrawArrays(GL_POINTS, 0, pSys->nParts); } else { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if(sortParts){ pSys->indexVbo->bind(); glDrawElements(GL_POINTS, pSys->nParts, GL_UNSIGNED_INT, 0); pSys->indexVbo->unbind(); } else { glDrawArrays(GL_POINTS, 0, pSys->nParts); } } pSys->posVbo->unbind(); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisable(GL_BLEND); break; case LINES: glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); pSys->posVbo->bind(); glVertexPointer(3, GL_FLOAT, 0, 0); glEnableClientState(GL_VERTEX_ARRAY); pSys->colourVbo->bind(); glColorPointer(4, GL_FLOAT, 0, 0); glEnableClientState(GL_COLOR_ARRAY); glLineWidth(lineWidth); for (int i = 0; i<pSys->nLeadParts; i++) { glDrawArrays(GL_LINE_STRIP, i*pSys->trailLength, pSys->trailLength); } pSys->posVbo->unbind(); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisable(GL_BLEND); break; case SPRITES: glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); pSys->posVbo->bind(); glVertexPointer(3, GL_FLOAT, 0, 0); glEnableClientState(GL_VERTEX_ARRAY); pSys->colourVbo->bind(); glColorPointer(4, GL_FLOAT, 0, 0); glEnableClientState(GL_COLOR_ARRAY); simpleSpriteProg->enable(); simpleSpriteProg->setUniform1f("pointRadius",pointSize); simpleSpriteProg->bindTexture("sDiffuseMap",TextureManager::Inst()->m_texID[id1],GL_TEXTURE_2D,0); if (blendingMode == ADD) { glBlendFunc( GL_SRC_ALPHA, GL_ONE ); glDrawArrays(GL_POINTS, 0, pSys->nParts); } else { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if(sortParts){ pSys->indexVbo->bind(); glDrawElements(GL_POINTS, pSys->nParts, GL_UNSIGNED_INT, 0); pSys->indexVbo->unbind(); } else { glDrawArrays(GL_POINTS, 0, pSys->nParts); } } simpleSpriteProg->disable(); pSys->posVbo->unbind(); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); break; case SHADOWED_SPRITES : GLfloat currentViewport[4]; glGetFloatv(GL_VIEWPORT, currentViewport); if(width != currentViewport[2] || height != currentViewport[3]) initFbos(currentViewport[2],currentViewport[3], false); drawSlices(); //glutReportErrors(); Fbo::unbind(); glViewport(0, 0, width, height); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); int mm; glGetIntegerv ( GL_MATRIX_MODE, &mm ); displayTexProg->enable(); displayTexProg->bindTexture("tex", imageTex, GL_TEXTURE_2D, 0); drawQuad(); displayTexProg->disable(); if(displayLightBuffer) { displayTexProg->bindTexture("tex", lightTex[srcLightTexture], GL_TEXTURE_2D, 0); glViewport(0, 0, lightBufferSize, lightBufferSize); drawQuad(); displayTexProg->disable(); } //calcVectors(); glViewport(0, 0, width, height); if (displayVectors) { debugVectors(); } glutReportErrors(); break; } }