forked from 0ad/0ad
Allow sprites to have color multiplication, which allows player-colored bars. Patch by Vladislav. Fixes #3233
This was SVN commit r16715.
This commit is contained in:
parent
f6f4f83784
commit
14bfbbf9d4
@ -1,5 +1,9 @@
|
||||
!!ARBfp1.0
|
||||
|
||||
TEX result.color, fragment.texcoord[0], texture[0], 2D;
|
||||
PARAM colorMul = program.local[0];
|
||||
TEMP color;
|
||||
TEX color, fragment.texcoord[0], texture[0], 2D;
|
||||
MUL color, color, colorMul;
|
||||
MOV result.color, color;
|
||||
|
||||
END
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
<fragment file="arb/foreground_overlay.fp">
|
||||
<uniform name="baseTex" loc="0" type="sampler2D"/>
|
||||
<uniform name="colorMul" loc="0" type="vec4"/>
|
||||
</fragment>
|
||||
|
||||
</program>
|
||||
|
@ -1,9 +1,10 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D baseTex;
|
||||
uniform vec4 colorMul;
|
||||
varying vec2 v_tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(baseTex, v_tex);
|
||||
gl_FragColor = texture2D(baseTex, v_tex) * colorMul;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
const NATURAL_COLOR = "255 255 255 255"; // pure white
|
||||
|
||||
function StatusBars() {}
|
||||
|
||||
StatusBars.prototype.Schema =
|
||||
@ -119,7 +121,8 @@ StatusBars.prototype.AddAuraIcons = function(cmpOverlayRenderer, yoffset)
|
||||
icon,
|
||||
{ "x": xoffset - iconSize/2, "y": yoffset },
|
||||
{ "x": xoffset + iconSize/2, "y": yoffset + iconSize },
|
||||
offset
|
||||
offset,
|
||||
NATURAL_COLOR
|
||||
);
|
||||
xoffset += iconSize * 1.2;
|
||||
}
|
||||
@ -142,14 +145,16 @@ StatusBars.prototype.AddBars = function(cmpOverlayRenderer, yoffset)
|
||||
"art/textures/ui/session/icons/"+type+"_bg.png",
|
||||
{ "x": -width/2, "y":yoffset },
|
||||
{ "x": width/2, "y": height + yoffset },
|
||||
offset
|
||||
offset,
|
||||
NATURAL_COLOR
|
||||
);
|
||||
|
||||
cmpOverlayRenderer.AddSprite(
|
||||
"art/textures/ui/session/icons/"+type+"_fg.png",
|
||||
{ "x": -width/2, "y": yoffset },
|
||||
{ "x": width*(amount - 0.5), "y": height + yoffset },
|
||||
offset
|
||||
offset,
|
||||
NATURAL_COLOR
|
||||
);
|
||||
|
||||
yoffset += height * 1.2;
|
||||
@ -190,7 +195,8 @@ StatusBars.prototype.AddBars = function(cmpOverlayRenderer, yoffset)
|
||||
icon,
|
||||
{ "x": -rankSize/2 + xoffset, "y": -rankSize/2 + yoffset },
|
||||
{ "x": rankSize/2 + xoffset, "y": rankSize/2 + yoffset },
|
||||
offset
|
||||
offset,
|
||||
"255 255 255 255"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -136,6 +136,7 @@ struct SOverlayTexturedLine
|
||||
struct SOverlaySprite
|
||||
{
|
||||
CTexturePtr m_Texture;
|
||||
CColor m_Color;
|
||||
CVector3D m_Position; // base position
|
||||
float m_X0, m_Y0, m_X1, m_Y1; // billboard corner coordinates, relative to base position
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -623,6 +623,8 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
|
||||
else
|
||||
sprite->m_Texture->Bind();
|
||||
|
||||
shader->Uniform(str_colorMul, sprite->m_Color);
|
||||
|
||||
CVector3D pos[4] = {
|
||||
sprite->m_Position + right*sprite->m_X0 + up*sprite->m_Y0,
|
||||
sprite->m_Position + right*sprite->m_X1 + up*sprite->m_Y0,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -27,6 +27,8 @@
|
||||
#include "graphics/TextureManager.h"
|
||||
#include "renderer/Renderer.h"
|
||||
|
||||
#include "ps/CLogger.h"
|
||||
|
||||
class CCmpOverlayRenderer : public ICmpOverlayRenderer
|
||||
{
|
||||
public:
|
||||
@ -112,8 +114,12 @@ public:
|
||||
UpdateMessageSubscriptions();
|
||||
}
|
||||
|
||||
virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D position)
|
||||
virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D position, std::string color)
|
||||
{
|
||||
CColor colorObj(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
if (!colorObj.ParseString(color, 1))
|
||||
LOGERROR("OverlayRenderer: Error parsing '%s'", color);
|
||||
|
||||
CTextureProperties textureProps(textureName);
|
||||
|
||||
SOverlaySprite sprite;
|
||||
@ -122,6 +128,7 @@ public:
|
||||
sprite.m_Y0 = corner0.Y.ToFloat();
|
||||
sprite.m_X1 = corner1.X.ToFloat();
|
||||
sprite.m_Y1 = corner1.Y.ToFloat();
|
||||
sprite.m_Color = colorObj;
|
||||
|
||||
m_Sprites.push_back(sprite);
|
||||
m_SpriteOffsets.push_back(CVector3D(position));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -23,5 +23,5 @@
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(OverlayRenderer)
|
||||
DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpOverlayRenderer, Reset)
|
||||
DEFINE_INTERFACE_METHOD_4("AddSprite", void, ICmpOverlayRenderer, AddSprite, VfsPath, CFixedVector2D, CFixedVector2D, CFixedVector3D)
|
||||
DEFINE_INTERFACE_METHOD_5("AddSprite", void, ICmpOverlayRenderer, AddSprite, VfsPath, CFixedVector2D, CFixedVector2D, CFixedVector3D, std::string)
|
||||
END_INTERFACE_WRAPPER(OverlayRenderer)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -48,8 +48,9 @@ public:
|
||||
* @param corner0,corner1 coordinates of sprite's corners, in world-space units oriented with the camera plane,
|
||||
* relative to the sprite position.
|
||||
* @param offset world-space offset of sprite position from the entity's base position.
|
||||
* @param color multiply color of texture
|
||||
*/
|
||||
virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D offset) = 0;
|
||||
virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D offset, std::string color = "255 255 255 255") = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(OverlayRenderer)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user