Original Post
Hi, me again, this time with the weirdest error I have ever encountered.
Here's the code
Here's the effect file, loaded as an ID3DXEffect and used by Font::DrawString
And here's the result. (attached as PNG)
[attachment=5807:Capture.PNG]
How on earth is this happening? The "Options" and "Exit" buttons clearly have larger Y-coordinates than "Start Game"!
I have tested and tested and tested all my matrix creation functions, (the same thing happens with D3DXMATRIX).
Font is my own implementation, I will post it up if required.
Here's the code
struct Button
{
std::string text;
gml::Vector2 position;
Button(std::string t, gml::Vector2 pos) : text(t), position(pos) {}
};
class MainMenuControl : GameObject
{
std::vector<Button> buttons;
Font* font;
public:
void Create(Scene* scene)
{
font = new Font(scene->pGraphics);
font->Load("Arial Black", 32);
buttons.push_back(Button("Start Game", gml::Vector2(100, 100)));
buttons.push_back(Button("Options", gml::Vector2(100, 132)));
buttons.push_back(Button("Exit", gml::Vector2(100, 164)));
}
void Update(Scene* scene)
{
}
void Render(Scene* scene)
{
gml::Matrix view = gml::Matrix::CreateLookAt(gml::Vector3(512, 288, 10), gml::Vector3(512, 288, 0), gml::Vector3(0, 1, 0));
gml::Matrix proj = gml::Matrix::CreateOrtho(-512, 512, -288, 288, 1, 1024);
gml::Matrix world;
for (int i = 0; i < buttons.size(); i++)
{
world = gml::Matrix::CreateTranslation(buttons.position.x, buttons.position.z, 0);
font->DrawString(buttons.text, world * view * proj);
}
}
void Destroy(Scene* scene)
{
delete font;
}
};
Here's the effect file, loaded as an ID3DXEffect and used by Font::DrawString
float4x4 WorldViewProj;
sampler TexSamp : register(s0) = sampler_state { MinFilter = Point; MagFilter = Point; MipFilter = None; };
void VertexShaderFunc(in float3 iPos : POSITION0, in float2 iTex : TEXCOORD0,
out float4 oPos : POSITION0, out float2 oTex : TEXCOORD0)
{
oPos = mul(float4(iPos.xyz, 1), WorldViewProj);
oTex = iTex;
}
void PixelShaderFunc(in float2 iTex : TEXCOORD0,
out float4 oCol : COLOR0)
{
oCol = tex2D(TexSamp, iTex);
}
technique t0
{
pass p0
{
VertexShader = compile vs_2_0 VertexShaderFunc();
PixelShader = compile ps_2_0 PixelShaderFunc();
AlphaBlendEnable = true;
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
}
}
And here's the result. (attached as PNG)
[attachment=5807:Capture.PNG]
How on earth is this happening? The "Options" and "Exit" buttons clearly have larger Y-coordinates than "Start Game"!
I have tested and tested and tested all my matrix creation functions, (the same thing happens with D3DXMATRIX).
Font is my own implementation, I will post it up if required.