mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-27 00:52:43 +00:00
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:
@@ -1,5 +1,9 @@
|
|||||||
!!ARBfp1.0
|
!!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
|
END
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
<vertex file="arb/foreground_overlay.vp">
|
<vertex file="arb/foreground_overlay.vp">
|
||||||
<stream name="pos"/>
|
<stream name="pos"/>
|
||||||
<stream name="uv0"/>
|
<stream name="uv0"/>
|
||||||
</vertex>
|
</vertex>
|
||||||
|
|
||||||
<fragment file="arb/foreground_overlay.fp">
|
<fragment file="arb/foreground_overlay.fp">
|
||||||
<uniform name="baseTex" loc="0" type="sampler2D"/>
|
<uniform name="baseTex" loc="0" type="sampler2D"/>
|
||||||
|
<uniform name="colorMul" loc="0" type="vec4"/>
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
</program>
|
</program>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
uniform sampler2D baseTex;
|
uniform sampler2D baseTex;
|
||||||
|
uniform vec4 colorMul;
|
||||||
varying vec2 v_tex;
|
varying vec2 v_tex;
|
||||||
|
|
||||||
void main()
|
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() {}
|
function StatusBars() {}
|
||||||
|
|
||||||
StatusBars.prototype.Schema =
|
StatusBars.prototype.Schema =
|
||||||
@@ -119,7 +121,8 @@ StatusBars.prototype.AddAuraIcons = function(cmpOverlayRenderer, yoffset)
|
|||||||
icon,
|
icon,
|
||||||
{ "x": xoffset - iconSize/2, "y": yoffset },
|
{ "x": xoffset - iconSize/2, "y": yoffset },
|
||||||
{ "x": xoffset + iconSize/2, "y": yoffset + iconSize },
|
{ "x": xoffset + iconSize/2, "y": yoffset + iconSize },
|
||||||
offset
|
offset,
|
||||||
|
NATURAL_COLOR
|
||||||
);
|
);
|
||||||
xoffset += iconSize * 1.2;
|
xoffset += iconSize * 1.2;
|
||||||
}
|
}
|
||||||
@@ -142,14 +145,16 @@ StatusBars.prototype.AddBars = function(cmpOverlayRenderer, yoffset)
|
|||||||
"art/textures/ui/session/icons/"+type+"_bg.png",
|
"art/textures/ui/session/icons/"+type+"_bg.png",
|
||||||
{ "x": -width/2, "y":yoffset },
|
{ "x": -width/2, "y":yoffset },
|
||||||
{ "x": width/2, "y": height + yoffset },
|
{ "x": width/2, "y": height + yoffset },
|
||||||
offset
|
offset,
|
||||||
|
NATURAL_COLOR
|
||||||
);
|
);
|
||||||
|
|
||||||
cmpOverlayRenderer.AddSprite(
|
cmpOverlayRenderer.AddSprite(
|
||||||
"art/textures/ui/session/icons/"+type+"_fg.png",
|
"art/textures/ui/session/icons/"+type+"_fg.png",
|
||||||
{ "x": -width/2, "y": yoffset },
|
{ "x": -width/2, "y": yoffset },
|
||||||
{ "x": width*(amount - 0.5), "y": height + yoffset },
|
{ "x": width*(amount - 0.5), "y": height + yoffset },
|
||||||
offset
|
offset,
|
||||||
|
NATURAL_COLOR
|
||||||
);
|
);
|
||||||
|
|
||||||
yoffset += height * 1.2;
|
yoffset += height * 1.2;
|
||||||
@@ -190,7 +195,8 @@ StatusBars.prototype.AddBars = function(cmpOverlayRenderer, yoffset)
|
|||||||
icon,
|
icon,
|
||||||
{ "x": -rankSize/2 + xoffset, "y": -rankSize/2 + yoffset },
|
{ "x": -rankSize/2 + xoffset, "y": -rankSize/2 + yoffset },
|
||||||
{ "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.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -136,6 +136,7 @@ struct SOverlayTexturedLine
|
|||||||
struct SOverlaySprite
|
struct SOverlaySprite
|
||||||
{
|
{
|
||||||
CTexturePtr m_Texture;
|
CTexturePtr m_Texture;
|
||||||
|
CColor m_Color;
|
||||||
CVector3D m_Position; // base position
|
CVector3D m_Position; // base position
|
||||||
float m_X0, m_Y0, m_X1, m_Y1; // billboard corner coordinates, relative to 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.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -622,6 +622,8 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
|
|||||||
shader->BindTexture(str_baseTex, sprite->m_Texture);
|
shader->BindTexture(str_baseTex, sprite->m_Texture);
|
||||||
else
|
else
|
||||||
sprite->m_Texture->Bind();
|
sprite->m_Texture->Bind();
|
||||||
|
|
||||||
|
shader->Uniform(str_colorMul, sprite->m_Color);
|
||||||
|
|
||||||
CVector3D pos[4] = {
|
CVector3D pos[4] = {
|
||||||
sprite->m_Position + right*sprite->m_X0 + up*sprite->m_Y0,
|
sprite->m_Position + right*sprite->m_X0 + 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.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -27,6 +27,8 @@
|
|||||||
#include "graphics/TextureManager.h"
|
#include "graphics/TextureManager.h"
|
||||||
#include "renderer/Renderer.h"
|
#include "renderer/Renderer.h"
|
||||||
|
|
||||||
|
#include "ps/CLogger.h"
|
||||||
|
|
||||||
class CCmpOverlayRenderer : public ICmpOverlayRenderer
|
class CCmpOverlayRenderer : public ICmpOverlayRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -112,8 +114,12 @@ public:
|
|||||||
UpdateMessageSubscriptions();
|
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);
|
CTextureProperties textureProps(textureName);
|
||||||
|
|
||||||
SOverlaySprite sprite;
|
SOverlaySprite sprite;
|
||||||
@@ -122,6 +128,7 @@ public:
|
|||||||
sprite.m_Y0 = corner0.Y.ToFloat();
|
sprite.m_Y0 = corner0.Y.ToFloat();
|
||||||
sprite.m_X1 = corner1.X.ToFloat();
|
sprite.m_X1 = corner1.X.ToFloat();
|
||||||
sprite.m_Y1 = corner1.Y.ToFloat();
|
sprite.m_Y1 = corner1.Y.ToFloat();
|
||||||
|
sprite.m_Color = colorObj;
|
||||||
|
|
||||||
m_Sprites.push_back(sprite);
|
m_Sprites.push_back(sprite);
|
||||||
m_SpriteOffsets.push_back(CVector3D(position));
|
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.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -23,5 +23,5 @@
|
|||||||
|
|
||||||
BEGIN_INTERFACE_WRAPPER(OverlayRenderer)
|
BEGIN_INTERFACE_WRAPPER(OverlayRenderer)
|
||||||
DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpOverlayRenderer, Reset)
|
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)
|
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.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 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,
|
* @param corner0,corner1 coordinates of sprite's corners, in world-space units oriented with the camera plane,
|
||||||
* relative to the sprite position.
|
* relative to the sprite position.
|
||||||
* @param offset world-space offset of sprite position from the entity's base 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)
|
DECLARE_INTERFACE_TYPE(OverlayRenderer)
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user