Hi,
I'm used to using GDI functions (e.g, Ellipse, Rectangle, FillRect, Polygon, GradientFill, LineTo, DrawText etc).
Was wondering if there are anything equivalent in DirectX10? Or can I use these functions to manipulate the buffer?
Reason is, I want a light-weight method of drawing these primitive shapes on screen without having to create a bunch of vertices, textures, etc.
Instead, I want to be able to quickly prototype ideas, like:
device->ClearRenderTargetView(....);
// Simple menu prototype
// Draw simple Border
DrawRectangle(device,
10, 10,
width-20, height-20,
NO_FILL, 0xffffffff);
// Offset where the menu text starts from
int menuTopOffset = 100;
// Draw selected menu's highlight border
int selectedMenuY = menuTopOffset + (_selectedMenuIndex * TextHeight());
DrawRectangle(device,
100, selectedMenuY,
width-200, selectedMenuY+TextHeight(),
FILL, 0xff00eeee);
// Draw each menu item one after the other, centered.
for (int i=0; i<NUM_MENU_ITEMS; i++)
{
// Let the selected menu text be BLUE. Non-selected menu text be WHITE
DWORD textColor = i==_selectedMenuIndex ? 0xffffffff : 0xff0000ff;
DrawText(device,
_menuItem,
(width-TextWidth(_menuItem))/2, // An idea to center the text. Or might use GDI-like flags like DT_CENTER, etc.
menuTopOffset + (i * TextHeight()),
textColor);
}
swapchain->Present(0,0);
And another example
device->ClearRenderTargetView(....);
// Random routine to draw a bunch of rectangles and circles on screen
for (int i=0; i<5000; i++)
{
int x = rand()%width;
int y = rand()%height;
int width = 10+rand()%100; // random size between 10-110
int height = 10+rand()%100; // random size between to-100
DWORD color = RGB(rand()%255, rand()%255, rand()%255);
// Draw a rectangle/ellipse alternatively
if (i%2==0)
DrawRectangle(device, x, y, width, height, color);
else
DrawEllipse(device, x,y,width,height, color);
}
swapchain->Present(0,0);
Any recommendations/advices? Thanks
Josh