Also...
So werden die Vertize initialisiert:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
//Vertize initialisieren
//Unten rechts
m_aVertex[2].Color = Color;
m_aVertex[2].fRHW = 1.f;
m_aVertex[2].vPosition = og3DVector(m_vPositionAbs.x + m_vSizeAbs.x, m_vPositionAbs.y + m_vSizeAbs.y, 0.1f);
m_aVertex[2].vTexture = m_pvTexBottomRight[0];
//Unten links
m_aVertex[0].Color = Color;
m_aVertex[0].fRHW = 1.f;
m_aVertex[0].vPosition = og3DVector(m_vPositionAbs.x, m_vPositionAbs.y + m_vSizeAbs.y, 0.1f);
m_aVertex[0].vTexture = og2DVector(m_pvTexTopLeft[0].x, m_pvTexBottomRight[0].y);
//Oben links
m_aVertex[1].Color = Color;
m_aVertex[1].fRHW = 1.f;
m_aVertex[1].vPosition = og3DVector(m_vPositionAbs.x, m_vPositionAbs.y, 0.1f);
m_aVertex[1].vTexture = m_pvTexTopLeft[0];
//Oben rechts
m_aVertex[3].Color = Color;
m_aVertex[3].fRHW = 1.f;
m_aVertex[3].vPosition = og3DVector(m_vPositionAbs.x + m_vSizeAbs.x, m_vPositionAbs.y, 0.1f);
m_aVertex[3].vTexture = og2DVector(m_pvTexBottomRight[0].x, m_pvTexTopLeft[0].y);
|
=====================================
Gerendert wird alles so:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
ogDirect3D::Instance().SetFVF(ogGUIVertex::dwFVF);
//Rendern
ogDirect3D::Instance().SetTransform(D3DTS_WORLD, ogMatrixIdentity());
m_Effect.Begin();
for(int iPass = 0; iPass < m_Effect.GetPasses(); iPass++)
{
m_Effect.Pass(iPass);
//Rendern
HRESULT hResult;
if(FAILED(hResult = ogDirect3D::Instance()->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, m_aVertex, sizeof(ogGUIVertex))))
{
OG_ERROR_DIRECTX(L"DrawPrimitiveUP()", hResult, OG_ERROR);
}
}
m_Effect.End();
|
und zwar mit diesem Effekt:
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
TEXTURE Texture;
TECHNIQUE T1
{
PASS P1
{
Texture[0] = <Texture>;
ZEnable = False;
ZWriteEnable = False;
ColorOp[0] = Modulate;
ColorArg1[0] = Current;
ColorArg2[0] = Texture;
ColorOp[1] = Disable;
AlphaOp[0] = Modulate;
AlphaArg1[0] = Current;
AlphaArg2[0] = Texture;
AlphaOp[1] = Disable;
AlphaBlendEnable = True;
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
}
}
|
(Texture wird in der Init geladen und gesetzt!)
==============================================
Und das ist die Movemethode:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
//Maus bewegen
//Neue Pos berechnen
m_vPositionAbs.x += m_fSpeedFactor * DI[OG_MOUSE_X_POS].fAnalog * m_vResolution.x;
m_vPositionAbs.y -= m_fSpeedFactor * DI[OG_MOUSE_Y_POS].fAnalog * m_vResolution.y; //Negativ, weil null oben ist!
//Im gültigen Bereich?
if(m_vPositionAbs.x < 0.f) m_vPositionAbs.x = 0.f;
if(m_vPositionAbs.y < 0.f) m_vPositionAbs.y = 0.f;
if(m_vPositionAbs.x >= m_vResolution.x) m_vPositionAbs.x = m_vResolution.x - 1;
if(m_vPositionAbs.y >= m_vResolution.y) m_vPositionAbs.y = m_vResolution.y - 1;
//Vertize aktualisieren
//Unten rechts
m_aVertex[2].vPosition = og3DVector(m_vPositionAbs.x + m_vSizeAbs.x, m_vPositionAbs.y + m_vSizeAbs.y, 0.1f);
//Unten links
m_aVertex[0].vPosition = og3DVector(m_vPositionAbs.x, m_vPositionAbs.y + m_vSizeAbs.y, 0.1f);
//Oben links
m_aVertex[1].vPosition = og3DVector(m_vPositionAbs.x, m_vPositionAbs.y, 0.1f);
//Oben rechts
m_aVertex[3].vPosition = og3DVector(m_vPositionAbs.x + m_vSizeAbs.x, m_vPositionAbs.y, 0.1f);
|
(Die DirectInput-Klasse (DI) ist ählich aufgebaut wie die von David...)
So... falls noch was erwünscht ist, kann ich es gerne posten!
Hoffe das hilft...!