コード例 #1
0
ファイル: surface.cpp プロジェクト: AlbanBedel/scummvm
void Surface::scaleTransparentCopyGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
	// This is the same as scaleTransparentCopy(), but turns the red value of each
	// pixel all the way up.

	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();

	int srcW = srcRect.width();
	int srcH = srcRect.height();
	int dstW = dstRect.width();
	int dstH = dstRect.height();

	for (int y = 0; y < dstH; y++) {
		for (int x = 0; x < dstW; x++) {
			if (g_system->getScreenFormat().bytesPerPixel == 2) {
				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
						x * srcW / dstW + srcRect.left,
						y * srcH / dstH + srcRect.top));
				if (!isTransparent(color))
					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
						x * srcW / dstW + srcRect.left,
						y * srcH / dstH + srcRect.top));
				if (!isTransparent(color))
					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
			}
		}
	}
}
コード例 #2
0
ファイル: surface.cpp プロジェクト: AlbanBedel/scummvm
void Surface::copyToCurrentPortTransparentGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
	// This is the same as copyToCurrentPortTransparent(), but turns the red value of each
	// pixel all the way up.

	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);

	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;

	for (int y = 0; y < srcRect.height(); y++) {
		for (int x = 0; x < srcRect.width(); x++) {
			if (g_system->getScreenFormat().bytesPerPixel == 2) {
				uint16 color = READ_UINT16(src);
				if (!isTransparent(color))
					WRITE_UINT16(dst, getGlowColor(color));
			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
				uint32 color = READ_UINT32(src);
				if (!isTransparent(color))
					WRITE_UINT32(dst, getGlowColor(color));
			}

			src += g_system->getScreenFormat().bytesPerPixel;
			dst += g_system->getScreenFormat().bytesPerPixel;
		}

		src += _surface->pitch - lineSize;
		dst += screen->pitch - lineSize;
	}
}
コード例 #3
0
ファイル: Enemy.cpp プロジェクト: WilliamChao/atomic
    virtual void draw()
    {
        vec4 diffuse = getDiffuseColor();
        vec4 glow = getGlowColor();
        vec4 light = m_light_color;
        vec4 flash = getDamageColor();

        if(getState()==State_Fadein) {
            float32 s   = (float32)m_st_frame / FADEIN_TIME;
            float shininess = diffuse.w;
            diffuse     *= stl::min<float32>(s*2.0f, 1.0f);
            diffuse.w   = shininess;
            glow        *= stl::max<float32>(s*2.0f-1.0f, 0.0f);
            light       *= s;
        }
        else if(getState()==State_Fadeout) {
            float32 s = 1.0f - ((float32)m_st_frame / FADEOUT_TIME);
            light   *= s;
        }

        if(m_light_radius > 0.0f) {
            if(atmGetConfig()->lighting_level>=atmE_Lighting_Medium) {
                PointLight l;
                l.setPosition(getPositionAbs() + vec3(0.0f, 0.0f, m_light_radius*0.5f));
                l.setColor(light);
                l.setRadius(m_light_radius);
                atmGetLightPass()->addLight(l);
            }
            else {
                flash += light*0.05f;
                glow *= 2.0f;
            }
        }
        if(m_state!=State_Fadeout) {
            PSetInstance inst;
            inst.diffuse = diffuse;
            inst.glow = glow;
            inst.flash = flash;
            inst.elapsed = getPastTime();
            inst.appear_radius = inst.elapsed * 0.004f;
            inst.transform = inst.rotate = getTransformMatrix();
            atmGetFluidPass()->addParticles(getModel(), inst, computeNumParticles());
            atmGetBloodStainPass()->addBloodstainParticles(getTransformMatrix(), getBloodStainParticles(), getNumBloodstainParticles());
        }
    }