void SegmentsPainter::draw(const ContinuationSegment& continuation) { glCheck(glEnable(GL_TEXTURE_2D)); drawSlice(continuation.getSourceSlice(), 0.5, 1.0, 0.5); drawSlice(continuation.getTargetSlice(), 0.5, 1.0, 0.5); util::point<double> center1 = continuation.getSourceSlice()->getComponent()->getCenter(); util::point<double> center2 = continuation.getTargetSlice()->getComponent()->getCenter(); unsigned int section1 = continuation.getSourceSlice()->getSection(); unsigned int section2 = continuation.getTargetSlice()->getSection(); glCheck(glDisable(GL_TEXTURE_2D)); glBegin(GL_LINES); glCheck(glVertex3f(center1.x, center1.y, section1*_zScale)); glCheck(glVertex3f(center2.x, center2.y, section2*_zScale)); glCheck(glEnd()); glBegin(GL_POINTS); glCheck(glVertex3f(center1.x, center1.y, section1*_zScale)); glCheck(glVertex3f(center2.x, center2.y, section2*_zScale)); glCheck(glEnd()); }
int drawSphere(GLfloat radius, GLint slices, SPHERE_MODE mode) { int i=0,j=0,w=2*slices,h=slices; point *mx; mx=getPointMatrix(radius,slices); if(!mx)return 0; for(;i<h-1;i++) { for(j=0;j<w-1;j++) drawSlice(&mx[i*w+j],&mx[i*w+j+1],&mx[(i+1)*w+j+1],&mx[(i+1)*w+j],mode); drawSlice(&mx[i*w+j],&mx[i*w],&mx[(i+1)*w],&mx[(i+1)*w+j],mode); } free(mx); return 1; }
void GLLUTWidget::init() { if (_lut!=0) { int z=_lut->getSizeX(); int x=_lut->getSizeY(); int y=_lut->getSizeZ(); //clear any old slices: unsigned int n=slices.size(); if (n>0) { for (unsigned int i=n;i>0;i--) { delete slices[i-1]; } } slices.clear(); //reload 'slices' into texture memory: for (unsigned int i=0;i<(unsigned int)z;i++) { Slice * tmp=new Slice(); tmp->resize(x,y); tmp->bg->load(); tmp->selection->load(GL_CLAMP,GL_CLAMP,GL_NEAREST,GL_NEAREST); tmp->sampler->load(GL_CLAMP,GL_CLAMP, GL_LINEAR, GL_LINEAR); drawSlice(tmp,_lut,i); slices.push_back(tmp); } needs_init=false; } }
void SegmentsPainter::draw(const BranchSegment& branch) { glCheck(glEnable(GL_TEXTURE_2D)); drawSlice(branch.getSourceSlice(), 0.5, 0.5, 1.0); drawSlice(branch.getTargetSlice1(), 0.5, 0.5, 1.0); drawSlice(branch.getTargetSlice2(), 0.5, 0.5, 1.0); util::point<double> center1 = branch.getSourceSlice()->getComponent()->getCenter(); util::point<double> center2 = branch.getTargetSlice1()->getComponent()->getCenter(); util::point<double> center3 = branch.getTargetSlice2()->getComponent()->getCenter(); unsigned int section1 = branch.getSourceSlice()->getSection(); unsigned int section2 = branch.getTargetSlice1()->getSection(); unsigned int section3 = branch.getTargetSlice2()->getSection(); glCheck(glDisable(GL_TEXTURE_2D)); glBegin(GL_LINES); glVertex3f(center1.x, center1.y, section1*_zScale); glVertex3f(center2.x, center2.y, section2*_zScale); glCheck(glEnd()); glBegin(GL_POINTS); glVertex3f(center1.x, center1.y, section1*_zScale); glVertex3f(center2.x, center2.y, section2*_zScale); glCheck(glEnd()); glBegin(GL_LINES); glVertex3f(center1.x, center1.y, section1*_zScale); glVertex3f(center3.x, center3.y, section3*_zScale); glCheck(glEnd()); glBegin(GL_POINTS); glVertex3f(center1.x, center1.y, section1*_zScale); glVertex3f(center3.x, center3.y, section3*_zScale); glCheck(glEnd()); }
void GLLUTWidget::setChannel(int c) { state.channel=c; if (actionViewToggleOtherChannels->isChecked()==false) { for (unsigned int i=0;i<slices.size();i++) { drawSlice( slices[i],_lut,i,false,true,false); } } redraw(); }
void SegmentsPainter::draw(const EndSegment& end) { glCheck(glEnable(GL_TEXTURE_2D)); drawSlice(end.getSlice(), 1.0, 0.5, 0.5); glCheck(glDisable(GL_TEXTURE_2D)); }
void drawFrame(const uint8_t frame[8][8]) { uint8_t i; for(i = 0; i < 8; i++) { setSlice(i); drawSlice(frame[i]); SysCtlDelay( 1000 * WAIT_1US ); } }
void ImageViewer::paintEvent(QPaintEvent* event) { if (!_draw) { return; } if (_core == NULL) { drawSample(event); } else { drawSlice(event); } }
void VHParticlesRender::drawSlices() { batchSize = pSys->nParts / nSlices; glClearColor(0.0, 0.0, 0.0, 0.0); lightFbo->bind(); glClearColor(1.0 - lightColor[0], 1.0 - lightColor[1], 1.0 - lightColor[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); imageFbo->bind(); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); /*int at; glGetIntegerv ( GL_ACTIVE_TEXTURE, &at ); int mm; glGetIntegerv ( GL_MATRIX_MODE, &mm ); GLfloat texMat[16]; glGetFloatv(GL_TEXTURE_MATRIX, texMat);*/ glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); //glPushMatrix(); glLoadMatrixf((GLfloat *) shadowMatrix.get_value()); //--- for(int i=0; i<nSlices; i++) { // draw slice from camera view, sampling light buffer drawSlice(i); // draw slice from light view to light buffer, accumulating shadows drawSliceLightView(i); if (doBlur) { blurLightBuffer(); } } glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); //glPopMatrix(); glLoadIdentity(); //GLfloat texMat2[16]; //glGetFloatv(GL_TEXTURE_MATRIX, texMat2); glMatrixMode(GL_MODELVIEW); }
void ChromaClockApp::run() { ClockApp::run(); millis_t start = Uptime::millis(); while (Uptime::millis() - start < _maxDrawTime) { drawSlice(_curSlice, c[_curSlice],r[_curSlice]); _curSlice++; if (_curSlice >= _slices) { _curSlice = 0; }; } }
void GLLUTWidget::editRedo() { if (_lut==0) return; if (redoStack.empty() == false) { UndoState * s=redoStack.back(); UndoState * r=new UndoState(_lut); s->restore(_lut); for(int i=0; i<slices.size(); i++) drawSlice(slices[i],_lut, i, false,true,false); redoStack.pop_back(); delete s; undoStack.push_back(r); } actionUndo->setEnabled(!undoStack.empty()); actionRedo->setEnabled(!redoStack.empty()); _lut->updateDerivedLUTs(); redraw(); }
void VolumeBuffer::runProgram(Program *fprog, int bank) { m_fbo->Bind(); glPushAttrib(GL_VIEWPORT_BIT); glViewport(0, 0, m_width, m_height); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glDisable(GL_DEPTH_TEST); switch(m_blendMode) { case BLEND_ADDITIVE: glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); break; } fprog->BindTextures(); fprog->Activate(); for(int z=0; z<m_depth; z++) { // attach texture slice to FBO m_fbo->AttachTexture(GL_TEXTURE_3D, m_tex[bank], GL_COLOR_ATTACHMENT0_EXT, 0, z); // render drawSlice((z + 0.5f) / (float) m_depth); } fprog->Deactivate(); glDisable(GL_BLEND); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); m_fbo->Disable(); }
void SunburstCanvas::drawCanvas(unsigned Rt, double animationStep) { glColor3f(1.0f, 1.0f, 1.0f); glRectd(top_left.x, top_left.y, bottom_right.x, bottom_right.y); double unitWidth = (2.0 * PI) / (double) entityData->entities.size(); double currentTheta = 0.0; for (auto b : entityData->sortedBaseEntities) { if (b->getName() == "") continue; drawSlice(b, Rt, currentTheta); // Increment theta to avoid overlap if (b->isEntity()) currentTheta += unitWidth; } }
void GLLUTWidget::drawEvent ( QMouseEvent * event ) { //get coordinates int x; int y; if (glPixel2LUTCoordinates(event,x,y)==true) { _lut->lock(); if ((event->button() == Qt::RightButton)) { //if right mouse button: //FIXME: add a (if direct statement) if (state.continuing_undo==false) editStore(); _lut->maskFillYZ(state.slice_idx, x,y, (_mode==LUTChannelMode_Numeric) ? state.channel : (((event->modifiers() & Qt::AltModifier) != 0x00) ? (~(0x00)) : (0x01 << state.channel)), _mode, (event->modifiers() & (Qt::ShiftModifier | Qt::AltModifier)) != 0x00,actionViewToggleOtherChannels->isChecked(),actionExclusiveMode->isChecked()); drawSlice(slices[state.slice_idx], _lut, state.slice_idx,false, true,false); //update texture slices[state.slice_idx]->selection_update_pending=true; state.continuing_undo=false; } else { if ((event->buttons() & Qt::RightButton) == 0x00) { if (state.continuing_undo==false) editStore(); //get current mask value if (state.drag_on==true) { drawLine(x,y,state.drag_start_x,state.drag_start_y,event); } else { drawPixel(x,y,event); } state.drag_start_x=x; state.drag_start_y=y; state.drag_on=true; state.continuing_undo=true; } } //update texture slices[state.slice_idx]->selection_update_pending=true; _lut->unlock(); this->redraw(); } }
// draw particles as slices with shadowing void SmokeRenderer::drawSlices() { m_batchSize = mNumParticles / m_numSlices; // clear light buffer m_srcLightTexture = 0; m_lightFbo->Bind(); m_lightFbo->AttachTexture(GL_TEXTURE_2D, m_lightTexture[m_srcLightTexture], GL_COLOR_ATTACHMENT0_EXT); glClearColor(1.0 - m_lightColor[0], 1.0 - m_lightColor[1], 1.0 - m_lightColor[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); m_lightFbo->Disable(); // clear volume image 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); glLoadMatrixf((GLfloat *) m_shadowMatrix.get_value()); // render slices if (m_numDisplayedSlices > m_numSlices) m_numDisplayedSlices = m_numSlices; for(int i=0; i<m_numDisplayedSlices; i++) { // draw slice from camera view, sampling light buffer drawSlice(i); // draw slice from light view to light buffer, accumulating shadows drawSliceLightView(i); if (m_doBlur) { blurLightBuffer(); } } glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); }
void SliceRenderer::drawOnScreen(int animationId, int animationFrame, int screenX, int screenY, float facing, float scale, Graphics::Surface &surface) { if (scale == 0.0f) { return; } _position.x = 0; _position.y = 0; _position.z = 0; _facing = facing; loadFrame(animationId, animationFrame); float frameHeight = _frameSliceHeight * _frameSliceCount; float frameSize = sqrt(_frameScale.x * 255.0f * _frameScale.x * 255.0f + _frameScale.y * 255.0f * _frameScale.y * 255.0f); float size = scale / MAX(frameSize, frameHeight); float s = sin(_facing); float c = cos(_facing); Matrix3x2 m_rotation(c, -s, 0.0f, s, c, 0.0f); Matrix3x2 m_frame(_frameScale.x, 0.0f, _framePos.x, 0.0f, _frameScale.y, _framePos.y); Matrix3x2 m_scale_size_25_5(size, 0.0f, 0.0f, 0.0f, 25.5f, 0.0f); Matrix3x2 m_translate_x_32k(1.0f, 0.0f, screenX, 0.0f, 1.0f, 32768.0f); Matrix3x2 m_scale_64k_64(65536.0f, 0.0f, 0.0f, 0.0f, 64.0f, 0.0f); Matrix3x2 m = m_scale_64k_64 * (m_translate_x_32k * (m_scale_size_25_5 * (m_rotation * m_frame))); setupLookupTable(_m11lookup, m(0, 0)); setupLookupTable(_m12lookup, m(0, 1)); _m13 = m(0, 2); setupLookupTable(_m21lookup, m(1, 0)); setupLookupTable(_m22lookup, m(1, 1)); _m23 = m(1, 2); int frameY = screenY + (size / 2.0f * frameHeight); int currentY = frameY; float currentSlice = 0; float sliceStep = 1.0f / size / _frameSliceHeight; uint16 *frameLinePtr = (uint16 *)surface.getPixels() + 640 * frameY; uint16 lineZbuffer[640]; while (currentSlice < _frameSliceCount) { if (currentY >= 0 && currentY < 480) { memset(lineZbuffer, 0xFF, 640 * 2); drawSlice(currentSlice, false, frameLinePtr, lineZbuffer, currentY); currentSlice += sliceStep; currentY--; frameLinePtr -= 640; } } }
void SliceRenderer::drawInWorld(int animationId, int animationFrame, Vector3 position, float facing, float scale, Graphics::Surface &surface, uint16 *zbuffer) { assert(_lights); assert(_setEffects); //assert(_view); _vm->_sliceRenderer->setupFrameInWorld(animationId, animationFrame, position, facing); assert(_sliceFramePtr); if (_screenRectangle.isEmpty()) { return; } SliceLineIterator sliceLineIterator; sliceLineIterator.setup( _endScreenVector.x, _endScreenVector.y, _endScreenVector.z, _startScreenVector.x, _startScreenVector.y, _startScreenVector.z, _endSlice, _startSlice, _mvpMatrix ); SliceRendererLights sliceRendererLights = SliceRendererLights(_lights); _lights->setupFrame(_view->_frame); _setEffects->setupFrame(_view->_frame); float sliceLine = sliceLineIterator.line(); sliceRendererLights.calculateColorBase( Vector3(_position.x, _position.y, _position.z + _frameBottomZ + sliceLine * _frameSliceHeight), Vector3(_position.x, _position.y, _position.z + _frameBottomZ), sliceLineIterator._endY - sliceLineIterator._startY); float setEffectsColorCoeficient; Color setEffectColor; _setEffects->calculateColor( _view->_cameraPosition, Vector3(_position.x, _position.y, _position.z + _frameBottomZ + sliceLine * _frameSliceHeight), &setEffectsColorCoeficient, &setEffectColor); _lightsColor.r = setEffectsColorCoeficient * sliceRendererLights._finalColor.r * 65536.0f; _lightsColor.g = setEffectsColorCoeficient * sliceRendererLights._finalColor.g * 65536.0f; _lightsColor.b = setEffectsColorCoeficient * sliceRendererLights._finalColor.b * 65536.0f; _setEffectColor.r = setEffectColor.r * 31.0f * 65536.0f; _setEffectColor.g = setEffectColor.g * 31.0f * 65536.0f; _setEffectColor.b = setEffectColor.b * 31.0f * 65536.0f; setupLookupTable(_m12lookup, sliceLineIterator._sliceMatrix(0, 1)); setupLookupTable(_m11lookup, sliceLineIterator._sliceMatrix(0, 0)); _m13 = sliceLineIterator._sliceMatrix(0, 2); setupLookupTable(_m21lookup, sliceLineIterator._sliceMatrix(1, 0)); setupLookupTable(_m22lookup, sliceLineIterator._sliceMatrix(1, 1)); _m23 = sliceLineIterator._sliceMatrix(1, 2); if (_animationsShadowEnabled[_animation]) { float coeficientShadow; Color colorShadow; _setEffects->calculateColor( _view->_cameraPosition, _position, &coeficientShadow, &colorShadow); int transparency = 32.0f * sqrt(setEffectColor.r * setEffectColor.r + setEffectColor.g * setEffectColor.g + setEffectColor.b * setEffectColor.b); drawShadowInWorld(transparency, surface, zbuffer); } int frameY = sliceLineIterator._startY; uint16 *frameLinePtr = (uint16 *)surface.getPixels() + 640 * frameY; uint16 *zBufferLinePtr = zbuffer + 640 * frameY; while (sliceLineIterator._currentY <= sliceLineIterator._endY) { sliceLine = sliceLineIterator.line(); sliceRendererLights.calculateColorSlice(Vector3(_position.x, _position.y, _position.z + _frameBottomZ + sliceLine * _frameSliceHeight)); if (sliceLineIterator._currentY & 1) { _setEffects->calculateColor( _view->_cameraPosition, Vector3(_position.x, _position.y, _position.z + _frameBottomZ + sliceLine * _frameSliceHeight), &setEffectsColorCoeficient, &setEffectColor); } _lightsColor.r = setEffectsColorCoeficient * sliceRendererLights._finalColor.r * 65536.0f; _lightsColor.g = setEffectsColorCoeficient * sliceRendererLights._finalColor.g * 65536.0f; _lightsColor.b = setEffectsColorCoeficient * sliceRendererLights._finalColor.b * 65536.0f; _setEffectColor.r = setEffectColor.r * 31.0f * 65536.0f; _setEffectColor.g = setEffectColor.g * 31.0f * 65536.0f; _setEffectColor.b = setEffectColor.b * 31.0f * 65536.0f; if (frameY >= 0 && frameY < 480) { drawSlice((int)sliceLine, true, frameLinePtr, zBufferLinePtr, frameY); } sliceLineIterator.advance(); frameY += 1; frameLinePtr += 640; zBufferLinePtr += 640; } }