bool Chunk::openToSky(const Coordinate& location) const { Coordinate current = location.addY(1); while (current.y < DEPTH) { if (!isTransparent(current)) return false; ++current.y; } return true; }
void FrameView::paint(GraphicsContext* context, const IntRect& rect) { #ifndef NDEBUG bool fillWithRed; if (isTransparent()) fillWithRed = false; // Transparent, don't fill with red. else fillWithRed = true; if (fillWithRed) context->fillRect(rect, Color(0xFF, 0, 0)); #endif RenderView* renderView = this->renderView(); if (!renderView) { WTF_LOG_ERROR("called FrameView::paint with nil renderer"); return; } RELEASE_ASSERT(!needsLayout()); bool isTopLevelPainter = !s_inPaintContents; s_inPaintContents = true; FontCachePurgePreventer fontCachePurgePreventer; ASSERT(!m_isPainting); m_isPainting = true; #if ENABLE(ASSERT) renderView->assertSubtreeIsLaidOut(); RenderObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*renderView); #endif LayerPaintingInfo paintingInfo(renderView->layer(), pixelSnappedIntRect(renderView->viewRect()), LayoutSize()); renderView->paintLayer(context, paintingInfo); m_isPainting = false; m_lastPaintTime = currentTime(); if (isTopLevelPainter) { // Everything that happens after paintContents completions is considered // to be part of the next frame. s_currentFrameTimeStamp = currentTime(); s_inPaintContents = false; } }
void FloatActionButton::onHovered(bool hover) { if (isTransparent()) return; if (isAnimated()) { if (hover) { _opacity.setStartValue(float(0.0)); _opacity.setEndValue(float(_st.fill_opacity)); _opacity.setDuration(15); _opacity.animStart(); } else { _opacity.setStartValue(float(_st.fill_opacity)); _opacity.setEndValue(float(0.0)); _opacity.setDuration(15); _opacity.animStart(); } } else { hover ? _opacity.setStartValue(float(_st.fill_opacity)) : _opacity.setStartValue(float(0.0)); } }
static void merge_bgs() { /* bitmap_t has width, height and colour_t **bitmap need to start the loop at x = (songbg->width - game_bg->width)/2 x = [(songbg->width - game_bg-width)/2, (songbg->width - game_bg->width)/2 + game_bg->width] y = [0, songbg->height] */ int x = (song_bg->width - game_bg->width)/2; /* int endx = startx + game_bg->width; */ /* (value1 * a + value2*(255-a))/255 printf("merge yo\n"); */ int overlayAlpha = 180; for (int i = 0; i < game_bg->width; i++, x++) { for (int j = 0; j < game_bg->height; j++) { /* uh, ok, how do I create fake transparency? */ /* whatever I'll just overwrite game_bg */ if (isTransparent(game_bg->bitmap[j][i])) { game_bg->bitmap[j][i] = song_bg->bitmap[j][x]; } else { game_bg->bitmap[j][i].red = (game_bg->bitmap[j][i].red * overlayAlpha + song_bg->bitmap[j][x].red*(255 - overlayAlpha) )/255; game_bg->bitmap[j][i].blue = (game_bg->bitmap[j][i].blue*overlayAlpha + song_bg->bitmap[j][x].blue*(255 - overlayAlpha) )/255; game_bg->bitmap[j][i].green = (game_bg->bitmap[j][i].green*overlayAlpha + song_bg->bitmap[j][x].green*(255 - overlayAlpha) )/255; } } } }
void Surface::draw(Vec const&) { if ( (checkState() != Qt::Checked) || !m_callListPositive || m_alpha < 0.01) return; GLboolean lighting; GLboolean blend; glGetBooleanv(GL_LIGHTING, &lighting); glGetBooleanv(GL_BLEND, &blend); if (isTransparent()) { glEnable(GL_BLEND); glDepthMask(GL_TRUE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_CULL_FACE); } switch (m_drawMode) { case Fill: glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); break; case Lines: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LINE_SMOOTH); glLineWidth(2.0); break; case Dots: glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_LIGHTING); glEnable(GL_POINT_SMOOTH); glPointSize(3.0); break; } GLfloat specular[] = {m_specular, m_specular, m_specular, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 100.0-m_shininess); glPushMatrix(); glMultMatrixd(m_frame.matrix()); if (m_callListPositive) { if (isTransparent()) glCullFace(GL_FRONT); glColor4fv(m_colorPositive); glCallList(m_callListPositive); if (isTransparent()) { glCullFace(GL_BACK); glCallList(m_callListPositive); } } if (m_callListNegative) { if (isTransparent()) glCullFace(GL_FRONT); glColor4fv(m_colorNegative); glCallList(m_callListNegative); if (isTransparent()) { glCullFace(GL_BACK); glCallList(m_callListNegative); glDisable(GL_CULL_FACE); } } glPopMatrix(); if (!blend) glDisable(GL_BLEND); if (lighting) glEnable(GL_LIGHTING); glDisable(GL_CULL_FACE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); }
// Geometry display void GLC_Geometry::render(const GLC_RenderProperties& renderProperties) { Q_ASSERT(!m_IsWire || (m_IsWire && m_MaterialHash.isEmpty())); bool renderWire= (renderProperties.renderingFlag() == glc::TransparentRenderFlag) && isTransparent(); renderWire= renderWire || ((renderProperties.renderingFlag() != glc::TransparentRenderFlag) && !isTransparent()); if (!m_IsWire || renderWire) { if (m_MaterialHash.isEmpty() && !m_IsWire) { GLC_Material* pMaterial= new GLC_Material(); pMaterial->setName(name()); addMaterial(pMaterial); } m_IsSelected= renderProperties.isSelected(); // Define Geometry's property if(!GLC_State::isInSelectionMode()) { glPropGeom(renderProperties); } glDraw(renderProperties); m_IsSelected= false; m_GeometryIsValid= true; // OpenGL error handler GLenum error= glGetError(); if (error != GL_NO_ERROR) { GLC_OpenGlException OpenGlException("GLC_Geometry::glExecute " + name(), error); throw(OpenGlException); } } }
bool GraphicsItem::isTranslucent() const { return !(isOpaque() || isTransparent()); }
bool RenderInline::requiresLayer() { return isRelPositioned() || isTransparent() || hasMask(); }
//___________________________________________________________ void BlurHelper::unregisterWidget( QWidget* widget ) { widget->removeEventFilter( this ); if( isTransparent( widget ) ) clear( widget ); }
//-------------------------------------------------------------------- // LLViewerJointMesh::drawShape() //-------------------------------------------------------------------- U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) { if (!mValid || !mMesh || !mFace || !mVisible || mFace->mVertexBuffer.isNull() || mMesh->getNumFaces() == 0) { return 0; } U32 triangle_count = 0; stop_glerror(); //---------------------------------------------------------------- // setup current color //---------------------------------------------------------------- if (!gRenderForSelect) { if (is_dummy) glColor4fv(LLVOAvatar::getDummyColor().mV); else glColor4fv(mColor.mV); } stop_glerror(); LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), gRenderForSelect ? 0.0f : mShiny && !(mFace->getPool()->getVertexShaderLevel() > 0)); //---------------------------------------------------------------- // setup current texture //---------------------------------------------------------------- llassert( !(mTexture.notNull() && mLayerSet) ); // mutually exclusive LLTexUnit::eTextureAddressMode old_mode = LLTexUnit::TAM_WRAP; if (mTestImageName) { gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTestImageName); if (mIsTransparent) { glColor4f(1.f, 1.f, 1.f, 1.f); } else { glColor4f(0.7f, 0.6f, 0.3f, 1.f); gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_LERP_TEX_ALPHA, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); } } else if( !is_dummy && mLayerSet ) { if( mLayerSet->hasComposite() ) { gGL.getTexUnit(0)->bind(mLayerSet->getComposite()); } else { // This warning will always trigger if you've hacked the avatar to show as incomplete. // Ignore the warning if that's the case. if (!gSavedSettings.getBOOL("RenderUnloadedAvatar")) { //llwarns << "Layerset without composite" << llendl; } gGL.getTexUnit(0)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT)); } } else if ( !is_dummy && mTexture.notNull() ) { if(mTexture->hasGLTexture()) { old_mode = mTexture->getAddressMode(); } gGL.getTexUnit(0)->bind(mTexture.get()); gGL.getTexUnit(0)->bind(mTexture); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } else { gGL.getTexUnit(0)->bind(LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT)); } if (gRenderForSelect) { if (isTransparent()) { gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_CONST_ALPHA); } else { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } } mFace->mVertexBuffer->setBuffer(sRenderMask); U32 start = mMesh->mFaceVertexOffset; U32 end = start + mMesh->mFaceVertexCount - 1; U32 count = mMesh->mFaceIndexCount; U32 offset = mMesh->mFaceIndexOffset; if (mMesh->hasWeights()) { if ((mFace->getPool()->getVertexShaderLevel() > 0)) { if (first_pass) { uploadJointMatrices(); } } mFace->mVertexBuffer->drawRange(LLRender::TRIANGLES, start, end, count, offset); } else { glPushMatrix(); LLMatrix4 jointToWorld = getWorldMatrix(); glMultMatrixf((GLfloat*)jointToWorld.mMatrix); mFace->mVertexBuffer->drawRange(LLRender::TRIANGLES, start, end, count, offset); glPopMatrix(); } gPipeline.addTrianglesDrawn(count); triangle_count += count; if (mTestImageName) { gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } if (mTexture.notNull() && !is_dummy) { gGL.getTexUnit(0)->bind(mTexture); gGL.getTexUnit(0)->setTextureAddressMode(old_mode); } return triangle_count; }
void OpenGLShader::constructNormalShader (const std::string& name) { // construction from IShader m_shader = GlobalShaderSystem().getShaderForName(name); OpenGLState& state = appendDefaultPass(); state.m_texture = m_shader->getTexture()->texture_number; state.m_state = RENDER_FILL | RENDER_TEXTURE_2D | RENDER_DEPTHTEST | RENDER_COLOURWRITE | RENDER_LIGHTING | RENDER_SMOOTH; state.m_state |= RENDER_CULLFACE; if ((m_shader->getFlags() & QER_ALPHATEST) != 0) { state.m_state |= RENDER_ALPHATEST; state.m_colour[3] = 0.25; IShader::EAlphaFunc alphafunc; m_shader->getAlphaFunc(&alphafunc, &state.m_alpharef); switch (alphafunc) { case IShader::eAlways: state.m_alphafunc = GL_ALWAYS; case IShader::eEqual: state.m_alphafunc = GL_EQUAL; case IShader::eLess: state.m_alphafunc = GL_LESS; case IShader::eGreater: state.m_alphafunc = GL_GREATER; case IShader::eLEqual: state.m_alphafunc = GL_LEQUAL; case IShader::eGEqual: state.m_alphafunc = GL_GEQUAL; } } state.m_colour = Vector4(m_shader->getTexture()->color, 1.0); if (isTransparent(m_shader->getName())) { state.m_state |= RENDER_BLEND; state.m_state |= RENDER_DEPTHWRITE; state.m_colour = Vector4(1.0, 1.0, 1.0, 0.4); state.m_sort = OpenGLState::eSortTranslucent; } else if ((m_shader->getFlags() & QER_TRANS) != 0) { state.m_state |= RENDER_BLEND; state.m_colour[3] = m_shader->getTrans(); BlendFunc blendFunc = m_shader->getBlendFunc(); state.m_blend_src = convertBlendFactor(blendFunc.m_src); state.m_blend_dst = convertBlendFactor(blendFunc.m_dst); if (state.m_blend_src == GL_SRC_ALPHA || state.m_blend_dst == GL_SRC_ALPHA) { state.m_state |= RENDER_DEPTHWRITE; } state.m_sort = OpenGLState::eSortTranslucent; } else if (m_shader->getTexture()->hasAlpha) { state.m_state |= RENDER_BLEND; state.m_state |= RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortTranslucent; } else { state.m_state |= RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortFullbright; } m_shader->forEachLayer(ShaderLayerVisitor(*this)); }
//-------------------------------------------------------------------- // LLViewerJointMesh::drawShape() //-------------------------------------------------------------------- U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) { if (!mValid || !mMesh || !mFace || !mVisible || mFace->mVertexBuffer.isNull() || mMesh->getNumFaces() == 0) { return 0; } U32 triangle_count = 0; stop_glerror(); //---------------------------------------------------------------- // setup current color //---------------------------------------------------------------- if (!gRenderForSelect) { glColor4fv(mColor.mV); } stop_glerror(); LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), gRenderForSelect ? 0.0f : mShiny && !(mFace->getPool()->getVertexShaderLevel() > 0)); //---------------------------------------------------------------- // setup current texture //---------------------------------------------------------------- llassert( !(mTexture.notNull() && mLayerSet) ); // mutually exclusive if (mTestImageName) { LLImageGL::bindExternalTexture( mTestImageName, 0, GL_TEXTURE_2D ); if (mIsTransparent) { glColor4f(1.f, 1.f, 1.f, 1.f); } else { glColor4f(0.7f, 0.6f, 0.3f, 1.f); gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_LERP_TEX_ALPHA, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); } } else if( mLayerSet ) { if( mLayerSet->hasComposite() ) { mLayerSet->getComposite()->bindTexture(); } else { llwarns << "Layerset without composite" << llendl; gImageList.getImage(IMG_DEFAULT)->bind(); } } else if ( mTexture.notNull() ) { if (!mTexture->getClampS() || !mTexture->getClampT()) { mTexture->bind(); mTexture->overrideClamp (TRUE, TRUE); } } else { gImageList.getImage(IMG_DEFAULT_AVATAR)->bind(); } if (gRenderForSelect) { if (isTransparent()) { gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR); gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_CONST_ALPHA); } else { LLImageGL::unbindTexture(0); } } mFace->mVertexBuffer->setBuffer(sRenderMask); U32 start = mMesh->mFaceVertexOffset; U32 end = start + mMesh->mFaceVertexCount - 1; U32 count = mMesh->mFaceIndexCount; U32 offset = mMesh->mFaceIndexOffset; if (mMesh->hasWeights()) { if ((mFace->getPool()->getVertexShaderLevel() > 0)) { if (first_pass) { uploadJointMatrices(); } } mFace->mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, start, end, count, offset); } else { glPushMatrix(); LLMatrix4 jointToWorld = getWorldMatrix(); glMultMatrixf((GLfloat*)jointToWorld.mMatrix); mFace->mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, start, end, count, offset); glPopMatrix(); } gPipeline.addTrianglesDrawn(count/3); triangle_count += count; if (mTestImageName) { gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } if (mTexture.notNull()) { mTexture->bind(); mTexture->restoreClamp(); } return triangle_count; }
unsigned int GSMS::MaskConfig::imprintMask(G4VPhysicalVolume* wptr) { //clean up for(int i=0; i<m_mask.size(); i++) { if(m_mask[i]) delete m_mask[i]; } m_mask.clear(); /* if(m_assembly) { std::vector<G4VPhysicalVolume*>::iterator iter = m_assembly->GetVolumesIterator(); for(int i=0;i<m_assembly->TotalImprintedVolumes();iter++,i++) { G4VPhysicalVolume* ptr = *iter; if(ptr) delete ptr; *iter = NULL; } delete m_assembly; }; m_assembly = new G4AssemblyVolume; */ G4VPhysicalVolume* world = NULL; if(wptr) world = wptr; else GSMS::GSMS::getWorld(&world); std::cerr << world << std::endl; try { G4VSolid* s_element = NULL; G4VSolid* s_mask = NULL; /* s_mask = new G4Tubs( "mask", 0., m_radius+m_ethick*1.5, m_eheight/2, 0.*deg, 360.*deg ); */ if(m_etype == "Box") { s_element = new G4Box( "element", m_ewidth/2, m_ethick/2, m_eheight/2); } else if(m_etype == "Segment") { s_element = new G4Box( "element", m_ewidth/2, m_ethick/2, m_eheight/2); } else return GSMS_ERR; G4Material* element_mat = NULL; G4Material* mask_mat = NULL; if(!__SUCCEEDED(GSMS::GSMS::getMaterial(m_emat,&element_mat)) || !__SUCCEEDED(GSMS::GSMS::getMaterial("Air",&mask_mat))) return GSMS_ERR; G4LogicalVolume* element_log = new G4LogicalVolume( s_element, element_mat, "element_log"); ///////////// /* G4LogicalVolume* mask_log = new G4LogicalVolume( s_mask, mask_mat, "mask_log" ); G4VPVParameterisation* mask_param = new MaskElement( this ); G4VPhysicalVolume* mask_phys = new G4PVParameterised( "mask_phys", element_log, mask_log, kUndefined, m_ecount, mask_param ); */ //////////// G4RotationMatrix mR; //mask G4ThreeVector mT(0.,0.,0.); //mask G4double local_time,angle,angle_offset; local_time = angle = angle_offset = 0.0; if(!__SUCCEEDED(GSMS::getTime(&local_time))) return GSMS_ERR; angle_offset = (m_speed * local_time); std::cerr << "Mask angle offset: " << angle_offset*360/2/pi << std::endl; for(int i=0;i<m_ecount;i++) if(!isTransparent(i)) { G4RotationMatrix mRe; //element G4ThreeVector mTe; //element angle = ( (float)i/(float)m_ecount*2*pi + angle_offset ); G4float xoff = (m_radius+m_ethick)*cos(angle); G4float yoff = (m_radius+m_ethick)*sin(angle); G4float zoff = 0.; mTe.setX(xoff); mTe.setY(yoff); mTe.setZ(zoff); mRe.rotateZ(pi/2 + angle); G4VPhysicalVolume* mask_phys = new G4PVPlacement( G4Transform3D(mRe,G4ThreeVector(xoff,yoff,zoff)), element_log, "element_phys", world->GetLogicalVolume(), false, i ); // &mRe, // G4ThreeVector(xoff,yoff,zoff), // "mask_phys", // element_log, // world, // false, // 0); m_mask.push_back(mask_phys); //m_assembly->AddPlacedVolume(element_log,mTe,&mRe); std::cerr << "Element " << i << " at angle " << angle*360/2/pi << " xOff = " << xoff << " yOff = " << yoff << " zOff = " << zoff << std::endl; }; // m_assembly->MakeImprint(world->GetLogicalVolume(),mT,&mR, true); G4VisAttributes* element_vis = new G4VisAttributes(GSMS_COLOR_ELEMENT); element_vis->SetVisibility(true); element_vis->SetForceSolid(true); element_log->SetVisAttributes(element_vis); //////////// } catch(...) { return GSMS_ERR; }; return GSMS_OK; };
void ObjectRenderer::renderGeometry(Geometry* geom, const glm::mat4& modelMatrix, GameObject* object, RenderList& outList) { for (SubGeometry& subgeom : geom->subgeom) { bool isTransparent = false; Renderer::DrawParameters dp; dp.colour = {255, 255, 255, 255}; dp.count = subgeom.numIndices; dp.start = subgeom.start; dp.textures = {0}; dp.visibility = 1.f; if (object && object->type() == GameObject::Instance) { auto modelinfo = object->getModelInfo<SimpleModelInfo>(); dp.depthWrite = !(modelinfo->flags & SimpleModelInfo::NO_ZBUFFER_WRITE); } if (geom->materials.size() > subgeom.material) { Geometry::Material& mat = geom->materials[subgeom.material]; if (!mat.textures.empty()) { auto tex = mat.textures[0].texture; if (tex) { if (tex->isTransparent()) { isTransparent = true; } dp.textures = {tex->getName()}; } } if ((geom->flags & RW::BSGeometry::ModuleMaterialColor) == RW::BSGeometry::ModuleMaterialColor) { dp.colour = mat.colour; if (object && object->type() == GameObject::Vehicle) { auto vehicle = static_cast<VehicleObject*>(object); if (dp.colour.r == 60 && dp.colour.g == 255 && dp.colour.b == 0) { dp.colour = glm::u8vec4(vehicle->colourPrimary, 255); } else if (dp.colour.r == 255 && dp.colour.g == 0 && dp.colour.b == 175) { dp.colour = glm::u8vec4(vehicle->colourSecondary, 255); } } } dp.visibility = 1.f; if (dp.colour.a < 255) { isTransparent = true; } dp.diffuse = mat.diffuseIntensity; dp.ambient = mat.ambientIntensity; } dp.blend = isTransparent; glm::vec3 position(modelMatrix[3]); float distance = glm::length(m_camera.position - position); float depth = (distance - m_camera.frustum.near) / (m_camera.frustum.far - m_camera.frustum.near); outList.emplace_back( createKey(isTransparent, depth * depth, dp.textures), modelMatrix, &geom->dbuff, dp); } }
void Image::removeTransparentBorder() { int channels; int numBytes = 0; switch(m_format) { case GL10::GL_RGB: return; case GL10::GL_RGBA: channels = 4; numBytes = m_width * m_height * channels; break; default: return; } if(numBytes) { // down m_region.yMin = 0; for (size_t i = 0; i < m_height; ++i) { size_t j = 0; for ( ; j < m_width; ++j) if (!isTransparent(m_pixels, j, i, channels)) break; if (j == m_width) ++m_region.yMin; else break; } // up m_region.yMax = m_height; for (int i = m_height - 1; i >= 0; --i) { size_t j = 0; for ( ; j < m_width; ++j) if (!isTransparent(m_pixels, j, i, channels)) break; if (j == m_width) --m_region.yMax; else break; } // left m_region.xMin = 0; for (size_t i = 0; i < m_width; ++i) { size_t j = 0; for ( ; j < m_height; ++j) if (!isTransparent(m_pixels, i, j, channels)) break; if (j == m_height) ++m_region.xMin; else break; } // right m_region.xMax = m_width; for (int i = m_width - 1; i >= 0; --i) { size_t j = 0; for ( ; j < m_height; ++j) if (!isTransparent(m_pixels, i, j, channels)) break; if (j == m_height) --m_region.xMax; else break; } m_region.translate(Vector(-m_width*0.5f, -m_height*0.5f)); } }
virtual void apply(osg::Node& node) { if (node.getStateSet()) isTransparent(*node.getStateSet()); traverse(node); }
void MidiKeyboardComponent::paint (Graphics& g) { g.fillAll (findColour (whiteNoteColourId)); auto lineColour = findColour (keySeparatorLineColourId); auto textColour = findColour (textLabelColourId); for (int octave = 0; octave < 128; octave += 12) { for (int white = 0; white < 7; ++white) { auto noteNum = octave + whiteNotes[white]; if (noteNum >= rangeStart && noteNum <= rangeEnd) drawWhiteNote (noteNum, g, getRectangleForKey (noteNum), state.isNoteOnForChannels (midiInChannelMask, noteNum), mouseOverNotes.contains (noteNum), lineColour, textColour); } } float x1 = 0.0f, y1 = 0.0f, x2 = 0.0f, y2 = 0.0f; auto width = getWidth(); auto height = getHeight(); if (orientation == verticalKeyboardFacingLeft) { x1 = width - 1.0f; x2 = width - 5.0f; } else if (orientation == verticalKeyboardFacingRight) x2 = 5.0f; else y2 = 5.0f; auto x = getKeyPos (rangeEnd).getEnd(); auto shadowCol = findColour (shadowColourId); if (! shadowCol.isTransparent()) { g.setGradientFill (ColourGradient (shadowCol, x1, y1, shadowCol.withAlpha (0.0f), x2, y2, false)); switch (orientation) { case horizontalKeyboard: g.fillRect (0.0f, 0.0f, x, 5.0f); break; case verticalKeyboardFacingLeft: g.fillRect (width - 5.0f, 0.0f, 5.0f, x); break; case verticalKeyboardFacingRight: g.fillRect (0.0f, 0.0f, 5.0f, x); break; default: break; } } if (! lineColour.isTransparent()) { g.setColour (lineColour); switch (orientation) { case horizontalKeyboard: g.fillRect (0.0f, height - 1.0f, x, 1.0f); break; case verticalKeyboardFacingLeft: g.fillRect (0.0f, 0.0f, 1.0f, x); break; case verticalKeyboardFacingRight: g.fillRect (width - 1.0f, 0.0f, 1.0f, x); break; default: break; } } auto blackNoteColour = findColour (blackNoteColourId); for (int octave = 0; octave < 128; octave += 12) { for (int black = 0; black < 5; ++black) { auto noteNum = octave + blackNotes[black]; if (noteNum >= rangeStart && noteNum <= rangeEnd) drawBlackNote (noteNum, g, getRectangleForKey (noteNum), state.isNoteOnForChannels (midiInChannelMask, noteNum), mouseOverNotes.contains (noteNum), blackNoteColour); } } }
//-------------------------------------------------------------------- // LLViewerJointMesh::drawShape() //-------------------------------------------------------------------- U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass) { if (!mValid || !mMesh || !mFace || !mVisible || mFace->mVertexBuffer.isNull() || mMesh->getNumFaces() == 0) { return 0; } U32 triangle_count = 0; stop_glerror(); //---------------------------------------------------------------- // setup current color //---------------------------------------------------------------- if (!gRenderForSelect) { if ((mFace->getPool()->getVertexShaderLevel() > 0)) { glColor4f(0,0,0,1); if (gMaterialIndex > 0) { glVertexAttrib4fvARB(gMaterialIndex, mColor.mV); } if (mShiny && gSpecularIndex > 0) { glVertexAttrib4fARB(gSpecularIndex, 1,1,1,1); } } else { glColor4fv(mColor.mV); } } stop_glerror(); LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), gRenderForSelect ? 0.0f : mShiny && !(mFace->getPool()->getVertexShaderLevel() > 0)); LLGLEnable texture_2d((gRenderForSelect && isTransparent()) ? GL_TEXTURE_2D : 0); //---------------------------------------------------------------- // setup current texture //---------------------------------------------------------------- llassert( !(mTexture.notNull() && mLayerSet) ); // mutually exclusive if (mTestImageName) { LLImageGL::bindExternalTexture( mTestImageName, 0, GL_TEXTURE_2D ); if (mIsTransparent) { glColor4f(1.f, 1.f, 1.f, 1.f); } else { glColor4f(0.7f, 0.6f, 0.3f, 1.f); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA); } } else if( mLayerSet ) { if( mLayerSet->hasComposite() ) { mLayerSet->getComposite()->bindTexture(); } else { llwarns << "Layerset without composite" << llendl; gImageList.getImage(IMG_DEFAULT)->bind(); } } else if ( mTexture.notNull() ) { mTexture->bind(); if (!mTexture->getClampS()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); } if (!mTexture->getClampT()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } } else { gImageList.getImage(IMG_DEFAULT_AVATAR)->bind(); } LLGLDisable tex(gRenderForSelect && !isTransparent() ? GL_TEXTURE_2D : 0); if (gRenderForSelect) { if (isTransparent()) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); // GL_TEXTURE_ENV_COLOR is set in renderPass1 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); } } else { //---------------------------------------------------------------- // by default, backface culling is enabled //---------------------------------------------------------------- /*if (sRenderPass == AVATAR_RENDER_PASS_CLOTHING_INNER) { LLImageGL::bindExternalTexture( sClothingMaskImageName, 1, GL_TEXTURE_2D ); glClientActiveTextureARB(GL_TEXTURE0_ARB); glActiveTextureARB(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); // Texture unit 1 glActiveTextureARB(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, sClothingInnerColor.mV); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_CONSTANT_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA); } else if (sRenderPass == AVATAR_RENDER_PASS_CLOTHING_OUTER) { glAlphaFunc(GL_GREATER, 0.1f); LLImageGL::bindExternalTexture( sClothingMaskImageName, 1, GL_TEXTURE_2D ); glClientActiveTextureARB(GL_TEXTURE0_ARB); glActiveTextureARB(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); // Texture unit 1 glActiveTextureARB(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); }*/ } mFace->mVertexBuffer->setBuffer(sRenderMask); U32 start = mMesh->mFaceVertexOffset; U32 end = start + mMesh->mFaceVertexCount - 1; U32 count = mMesh->mFaceIndexCount; U32* indicesp = ((U32*) mFace->mVertexBuffer->getIndicesPointer()) + mMesh->mFaceIndexOffset; if (mMesh->hasWeights()) { if ((mFace->getPool()->getVertexShaderLevel() > 0)) { if (first_pass) { uploadJointMatrices(); } llDrawRangeElements(GL_TRIANGLES, start, end, count, GL_UNSIGNED_INT, indicesp); } else { llDrawRangeElements(GL_TRIANGLES, start, end, count, GL_UNSIGNED_INT, indicesp); } } else { glPushMatrix(); LLMatrix4 jointToWorld = getWorldMatrix(); glMultMatrixf((GLfloat*)jointToWorld.mMatrix); llDrawRangeElements(GL_TRIANGLES, start, end, count, GL_UNSIGNED_INT, indicesp); glPopMatrix(); } triangle_count += mMesh->mFaceIndexCount; if (mTestImageName) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } /*if (sRenderPass != AVATAR_RENDER_PASS_SINGLE) { LLImageGL::unbindTexture(1, GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); // Return to the default texture. LLImageGL::unbindTexture(0, GL_TEXTURE_2D); glClientActiveTextureARB(GL_TEXTURE0_ARB); glActiveTextureARB(GL_TEXTURE0_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); glAlphaFunc(GL_GREATER, 0.01f); }*/ if (mTexture.notNull()) { if (!mTexture->getClampS()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); } if (!mTexture->getClampT()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } } return triangle_count; }
struct eListboxStyle *eListbox::getLocalStyle(void) { /* transparency is set directly in the widget */ m_style.m_transparent_background = isTransparent(); return &m_style; }
void PhongMaterial::rebuildState(void) { if(_pState != NullFC) { _pState->clearChunks(); } else { _pState = State::create(); addRefCP(_pState); } prepareLocalChunks(); Color3f v3; Color4f v4; float alpha = 1.f - getTransparency(); beginEditCP(_materialChunk); v3 = getAmbient(); v4.setValuesRGBA(v3[0], v3[1], v3[2], alpha); _materialChunk->setAmbient(v4); v3 = getDiffuse(); v4.setValuesRGBA(v3[0], v3[1], v3[2], alpha); _materialChunk->setDiffuse(v4); v3 = getSpecular(); v4.setValuesRGBA(v3[0], v3[1], v3[2], alpha); _materialChunk->setSpecular(v4); _materialChunk->setShininess(getShininess()); v3 = getEmission(); v4.setValuesRGBA(v3[0], v3[1], v3[2], alpha); _materialChunk->setEmission(v4); _materialChunk->setLit(getLit()); _materialChunk->setColorMaterial(getColorMaterial()); endEditCP(_materialChunk); _pState->addChunk(_materialChunk); if(isTransparent()) _pState->addChunk(_blendChunk); if(_vpChunk != NullFC) _pState->addChunk(_vpChunk); createFragmentProgram(); if(_fpChunk != NullFC) _pState->addChunk(_fpChunk); for(MFStateChunkPtr::iterator i = _mfChunks.begin(); i != _mfChunks.end(); ++i) { _pState->addChunk(*i); } }
//-------------------------------------------------------------------- // render() //-------------------------------------------------------------------- U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) { stop_glerror(); U32 triangle_count = 0; //---------------------------------------------------------------- // ignore invisible objects //---------------------------------------------------------------- if ( mValid ) { //---------------------------------------------------------------- // if object is transparent, defer it, otherwise // give the joint subclass a chance to draw itself //---------------------------------------------------------------- if ( is_dummy ) { triangle_count += drawShape( pixelArea, first_pass, is_dummy ); } else if (LLPipeline::sShadowRender) { triangle_count += drawShape(pixelArea, first_pass, is_dummy ); } else if ( isTransparent() && !LLPipeline::sReflectionRender) { // Hair and Skirt if ((pixelArea > MIN_PIXEL_AREA_3PASS_HAIR)) { // render all three passes LLGLDisable cull(GL_CULL_FACE); // first pass renders without writing to the z buffer { LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); triangle_count += drawShape( pixelArea, first_pass, is_dummy ); } // second pass writes to z buffer only gGL.setColorMask(false, false); { triangle_count += drawShape( pixelArea, FALSE, is_dummy ); } // third past respects z buffer and writes color gGL.setColorMask(true, false); { LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); triangle_count += drawShape( pixelArea, FALSE, is_dummy ); } } else { // Render Inside (no Z buffer write) glCullFace(GL_FRONT); { LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); triangle_count += drawShape( pixelArea, first_pass, is_dummy ); } // Render Outside (write to the Z buffer) glCullFace(GL_BACK); { triangle_count += drawShape( pixelArea, FALSE, is_dummy ); } } } else { // set up render state triangle_count += drawShape( pixelArea, first_pass ); } } //---------------------------------------------------------------- // render children //---------------------------------------------------------------- for (child_list_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { LLViewerJoint* joint = (LLViewerJoint*)(*iter); F32 jointLOD = joint->getLOD(); if (pixelArea >= jointLOD || sDisableLOD) { triangle_count += joint->render( pixelArea, TRUE, is_dummy ); if (jointLOD != DEFAULT_LOD) { break; } } } return triangle_count; }
int eSlider::event(int event, void *data, void *data2) { switch (event) { case evtPaint: { ePtr<eWindowStyle> style; eSize s(size()); getStyle(style); /* paint background */ eWidget::event(evtPaint, data, data2); gPainter &painter = *(gPainter*)data2; style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style if (!m_pixmap) painter.fill(m_currently_filled); else painter.blit(m_pixmap, ePoint(0, 0), m_currently_filled.extends, isTransparent() ? gPainter::BT_ALPHATEST : 0); // border if (m_have_border_color) painter.setForegroundColor(m_border_color); painter.fill(eRect(0, 0, s.width(), m_border_width)); painter.fill(eRect(0, m_border_width, m_border_width, s.height()-m_border_width)); painter.fill(eRect(m_border_width, s.height()-m_border_width, s.width()-m_border_width, m_border_width)); painter.fill(eRect(s.width()-m_border_width, m_border_width, m_border_width, s.height()-m_border_width)); return 0; } case evtChangedSlider: { int num_pix = 0, start_pix = 0; gRegion old_currently_filled = m_currently_filled; int pixsize = (m_orientation == orHorizontal) ? size().width() : size().height(); if (m_min < m_max) { int val_range = m_max - m_min; num_pix = (pixsize * (m_value - m_start) + val_range - 1) / val_range; /* properly round up */ start_pix = (pixsize * m_start + val_range - 1) / val_range; if (m_orientation_swapped) start_pix = pixsize - num_pix - start_pix; } if (start_pix < 0) { num_pix += start_pix; start_pix = 0; } if (num_pix < 0) num_pix = 0; if (m_orientation == orHorizontal) m_currently_filled = eRect(start_pix, 0, num_pix, pixsize); else m_currently_filled = eRect(0, start_pix, pixsize, num_pix); // redraw what *was* filled before and now isn't. invalidate(m_currently_filled - old_currently_filled); // redraw what wasn't filled before and is now. invalidate(old_currently_filled - m_currently_filled); return 0; } default: return eWidget::event(event, data, data2); } }