I agree. I would like to code a "colored" panel for 3DGS using C# but I can only do this in C++. Please note that speaking of colored panel, I mean something like this:
Code:
using Vtx2D = Microsoft.DirectX.Direct3D.CustomVertex.TransformedColored;
// ...
void Render2D()
{
DrawPanel(0, 20, 160, 160, Color.Green);
DrawPanel(130, 120, 160, 160, Color.Yellow);
DrawHorizontalGradientPanel(400, 120, 300, 190,
Color.FromArgb(160, 20, 67),
Color.FromArgb(20, 20, 200));
DrawVerticalGradientPanel(300, 20, 300, 190,
Color.FromArgb(0, 20, 67),
Color.FromArgb(100, 250, 200));
DrawQuadGradientPanel(
0,
384,
1024,
384,
Color.DarkBlue, Color.DarkGreen, Color.DarkGreen, Color.FromArgb(0, 32, 0));
}
void DrawPanel(float x, float y, float scale_x, float scale_y,
Color c)
{
GraphicsStream stm = panelVB.Lock(0, 0, 0);
int i = 0;
panel[i++] = new Vtx2D(
x, y, 0, 0, c.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, y, 0, 0, c.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c.ToArgb());
panel[i++] = new Vtx2D(
x, scale_y + y, 0, 0, c.ToArgb());
panel[i++] = new Vtx2D(
x, y, 0, 0, c.ToArgb());
stm.Write(panel);
panelVB.Unlock();
deviceMultimedia.D3D9Device.SetStreamSource(0, panelVB, 0);
deviceMultimedia.D3D9Device.VertexFormat = Vtx2D.Format;
deviceMultimedia.D3D9Device.DrawPrimitives(
PrimitiveType.TriangleList, 0, panelFaces);
}
void DrawVerticalGradientPanel(float x, float y, float scale_x, float scale_y,
Color c1, Color c2)
{
GraphicsStream stm = panelVB.Lock(0, 0, 0);
int i = 0;
panel[i++] = new Vtx2D(
x, y, 0, 0, c1.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, y, 0, 0, c1.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
x, scale_y + y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
x, y, 0, 0, c1.ToArgb());
stm.Write(panel);
panelVB.Unlock();
deviceMultimedia.D3D9Device.SetStreamSource(0, panelVB, 0);
deviceMultimedia.D3D9Device.VertexFormat = Vtx2D.Format;
deviceMultimedia.D3D9Device.DrawPrimitives(
PrimitiveType.TriangleList, 0, panelFaces);
}
void DrawHorizontalGradientPanel(float x, float y, float scale_x, float scale_y,
Color c1, Color c2)
{
GraphicsStream stm = panelVB.Lock(0, 0, 0);
int i = 0;
panel[i++] = new Vtx2D(
x, y, 0, 0, c1.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
x, scale_y + y, 0, 0, c1.ToArgb());
panel[i++] = new Vtx2D(
x, y, 0, 0, c1.ToArgb());
stm.Write(panel);
panelVB.Unlock();
deviceMultimedia.D3D9Device.SetStreamSource(0, panelVB, 0);
deviceMultimedia.D3D9Device.VertexFormat = Vtx2D.Format;
deviceMultimedia.D3D9Device.DrawPrimitives(
PrimitiveType.TriangleList, 0, panelFaces);
}
void DrawQuadGradientPanel(float x, float y, float scale_x, float scale_y,
Color c1, Color c2, Color c3, Color c4)
{
GraphicsStream stm;
int i;
int CenterR = (c1.R + c2.R + c3.R + c4.R) / (17 / 4);
int CenterG = (c1.G + c2.G + c3.G + c4.G) / (17 / 4);
int CenterB = (c1.B + c2.B + c3.B + c4.B) / (17 / 4);
Color cCenter = Color.FromArgb(CenterR, CenterG, CenterB);
stm = panelVB.Lock(0, 0, 0);
i = 0;
panel[i++] = new Vtx2D(
x, y, 0, 0, c1.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
(scale_x / 2) + x, (scale_y / 2) + y, 0, 0, cCenter.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, y, 0, 0, c2.ToArgb());
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c4.ToArgb());
panel[i++] = new Vtx2D(
(scale_x / 2) + x, (scale_y / 2) + y, 0, 0, cCenter.ToArgb());
stm.Write(panel);
panelVB.Unlock();
deviceMultimedia.D3D9Device.SetStreamSource(0, panelVB, 0);
deviceMultimedia.D3D9Device.VertexFormat = Vtx2D.Format;
deviceMultimedia.D3D9Device.DrawPrimitives(
PrimitiveType.TriangleList, 0, panelFaces);
stm = panelVB.Lock(0, 0, 0);
i = 0;
panel[i++] = new Vtx2D(
scale_x + x, scale_y + y, 0, 0, c4.ToArgb());
panel[i++] = new Vtx2D(
x, scale_y + y, 0, 0, c3.ToArgb());
panel[i++] = new Vtx2D(
(scale_x / 2) + x, (scale_y / 2) + y, 0, 0, cCenter.ToArgb());
panel[i++] = new Vtx2D(
x, scale_y + y, 0, 0, c3.ToArgb());
panel[i++] = new Vtx2D(
x, y, 0, 0, c1.ToArgb());
panel[i++] = new Vtx2D(
(scale_x / 2) + x, (scale_y / 2) + y, 0, 0, cCenter.ToArgb());
stm.Write(panel);
panelVB.Unlock();
deviceMultimedia.D3D9Device.SetStreamSource(0, panelVB, 0);
deviceMultimedia.D3D9Device.VertexFormat = Vtx2D.Format;
deviceMultimedia.D3D9Device.DrawPrimitives(
PrimitiveType.TriangleList, 0, panelFaces);
}
...which look like this:
[image]/gpdotnet.worldispnetwork.com/images/MyImages/ColoredPanels.png[/image]