/* * public void renderDynamicLightsToTexture() * { * dynamicLightTexture.Clear(m_ClearColor); * * for (int i = 0; i < dynamicLights.Count; ++i) * { * renderALight(dynamicLights[i], dynamicLightTexture); * } * * dynamicLightTexture.Display(); * * } */ public void Render(RenderTarget destination, Camera camera) { //destination.Draw(this.lightMapDarkShape, new RenderStates(BlendMode.Multiply)); renderStaticLightsToTexture(camera.ViewBounds); //cRenderFunctions.DrawTextureSimple(destination, new Vector2f(), m_LightTexture.Texture, new IntRect(0,0, (int)m_LightTexture.Size.X, (int)m_LightTexture.Size.Y),Color.White, BlendMode.Multiply); DrawingBase.DrawTextureSimple(destination, camera.ViewBounds.topLeft, // viewRect.topLeft, staticLightTexture.Texture, new MyIntRect(0, 0, (int)this.staticLightTexture.Size.X, (int)this.staticLightTexture.Size.Y), //new IntRect((int)view_rect.topLeft.X, (int)view_rect.topLeft.Y, // (int)view_rect.dims.X, (int)view_rect.dims.Y), Color.White, BlendMode.Multiply); /* renderDynamicLightsToTexture(); * * cRenderFunctions.DrawTextureSimple(destination, * view_rect.topLeft, * dynamicLightTexture.Texture, * new IntRect((int)view_rect.topLeft.X, (int)view_rect.topLeft.Y, * (int)view_rect.dims.X, (int)view_rect.dims.Y), * Color.White, * BlendMode.Multiply); */ }
public void Render(RenderTarget destination, Vector2f pos) //MyIntRect view_rect = new MyIntRect() { MyIntRect frame = this.GetCurrentFrame().DeepCopy(); //.DeepCopy is very important for drawing!! frame.Left += this.animData.ViewOffsetRect.Left; frame.Top += this.animData.ViewOffsetRect.Top; frame.Width = this.animData.ViewOffsetRect.Width; frame.Height = this.animData.ViewOffsetRect.Height; /* * cRenderFunctions.DrawTextureSimple( destination, * pos, * this.GetSpriteSheet(), * frame, * Color.White, * BlendMode.Alpha * ); */ DrawingBase.DrawTexture(destination, pos, this.GetTexture(), frame, Color.White, 0.0f, 1.0f, //SCALE_FACTOR, false, //p_myCurrentAnim->IsFlippedHorizontally(), false, BlendMode.Alpha, null); }
private void renderALight(cLight light, RenderTarget target, AABB viewRect) { /* * Vector3f glColor = new Vector3f(0, 0, 0); * glColor.X = ((float)light.Color.R / 255.0f); * glColor.Y = ((float)light.Color.G / 255.0f); * glColor.Z = ((float)light.Color.B / 255.0f); */ Vector2f newPos = new Vector2f(light.Pos.X - viewRect.topLeft.X, light.Pos.Y - viewRect.topLeft.Y); //autenuationShader.SetUniform("lightPos", new Vec2(newPos.X, target.Size.Y - newPos.Y)); autenuationShader.SetUniform("lightPos", new Vec2(newPos.X, target.Size.Y - newPos.Y)); autenuationShader.SetUniform("lightColor", new Vec3(light.GLcolor.X, light.GLcolor.Y, light.GLcolor.Z)); autenuationShader.SetUniform("radius", light.Radius); autenuationShader.SetUniform("bleed", light.Bleed); autenuationShader.SetUniform("linearizeFactor", light.LinearizeFactor); DrawingBase.DrawDirLightByDVec(target, newPos, light.Radius, light.Dir, light.SpreadAngle, light.Color, BlendMode.Add, autenuationShader); /* * Vector2f newPos = new Vector2f(); * newPos.X = light.Pos.X - viewRect.topLeft.X; //(light.Pos.X / defaultTarget.Size.X) * target.Size.X; * newPos.Y = light.Pos.Y - viewRect.topLeft.Y;//(light.Pos.Y / defaultTarget.Size.Y) * target.Size.Y; * * lightSprite.Position = new Vector2f(light.Pos.X - viewRect.topLeft.X, light.Pos.Y - viewRect.topLeft.Y); * lightSprite.Color = light.Color; * * float scale = 1.0f + (light.Radius / (lightTexture.Size.X /2.0f)); * lightSprite.Scale = new Vector2f(scale, scale); * * * // BlendMode bm = new BlendMode(BlendMode.Factor.Zero, BlendMode.Factor.DstColor, BlendMode.Equation.Add, * // BlendMode.Factor.Zero, BlendMode.Factor.OneMinusSrcAlpha, BlendMode.Equation.Add); * * target.Draw(lightSprite, new RenderStates(BlendMode.Add)); */ }
public void RenderCentered(RenderTarget destination, Vector2f pos) { MyIntRect frame = this.GetCurrentFrame().DeepCopy(); frame.Left += this.animData.ViewOffsetRect.Left; frame.Top += this.animData.ViewOffsetRect.Top; frame.Width = this.animData.ViewOffsetRect.Width; frame.Height = this.animData.ViewOffsetRect.Height; DrawingBase.DrawTextureUseCenter(destination, pos, this.GetTexture(), frame, Color.White, 0.0f, 1.0f, //SCALE_FACTOR, false, //p_myCurrentAnim->IsFlippedHorizontally(), false, BlendMode.Add, null); }