Home
Portfolio
Home
Home
The Passage
Mandelbrot
DarkForge
Stranded
Programming Title
Michael

November 22, 2011
Michael Schoell

There has not been a lot of visual progress made with DarkForge recently. Much of the work has been tied up in the core architecture. Since DarkForge is meant to support DirectX 9 and DirectX 11, this work has mostly involved the support for them. Between the two graphics APIs, things are different, what you have access to and how you have access to it.

This was the case with sending constants to the shaders. Where in DirectX 9 you simply call a line of code on a per constant basis, like so:

device->SetVertexShaderConstantF(...);

DirectX 11 needs an entire structure ID3D11Buffer, setup for the shader and filled with the constants. Fewer individual commands being setup and passed to the video card is likely a good thing, but offers some hasle with code setup. Since I did not want to add another class to seperate DirectX 9 and DirectX 11 and how they handle things, I simply opted for a void pointer.

The void pointer is sized to like a tiny memory pool to hold a list of constants in DirectX 9, and in DirectX 11 it holds the structure of constants with room in the last four bytes to hold a pointer to the ID3D11Buffer to pass the data to. Keeps the code from requiring another set of virtual function tables or function pointers and has zero impact on the end user.

User Interface has also been improved over the past several weeks. From how objects are managed to various display options such as anchor points, how they anchor to parents, and improved text options. Even while it does not support LUA commands as my previous version did, it is far more optimized and robust and should prove easy to expand into the future.

Below are some screenshots highlighting the anchor points. To set one up is no more complex than a line of code. The window is the tiled chess board, the sub object that we are modifying the anchor point of is the grass texture.

CenterCenter The grass image is centered in the chessboard window.
UpperLeftUpperLeft Default setup, the grass image is at 0, 0 in it's parent window as expected.
CenterUpperLeft The grass image's anchor is in the center, making it appear to begin at -32, -32.
LowerRightLowerRight The grass image's position is still 0, 0. Not it appears in the lower right hand corner due to a change in it's anchors.

Beyond basic setup to render an empty screen, which amounts to a dozen or so lines of code, there is not much to get the above to show. The user must create a few objects, all of which could be done in XML files if so desired and reducing the required C++ code to simply one line. All objects default to the upper left corner of their parent with an upper left anchor point.

dfTexture *pTexture, *pTexture2;

//Load the textures.
pTexture = pSceneManager->loadTexture("Assets/Texture.png");
pTexture2 = pSceneManager->loadTexture("Assets/Texture2.png");

//Create the window.
dfWindow *pWindow = pUIManager->createWindow(0, pTexture, 0, 0, 256, 256); //Parameters are: parent pointer (root windows are NULL), the texture, position X, position Y, width, height

//Anchor it to its parent
pWindow->setAnchorToParent(CENTER_ANCHOR); //Centers the window on the screen.
pWindow->setAnchor(CENTER_ANCHOR); //Makes the window center by it's center point rather than the upper left corner.

dfImage *pImage = pUIManager->createImage(pWindow, 0, 0, 64, 64, pTexture2); //Parameters are: parent pointer (the previously made window will house us), the texture, position X, position Y, width, height

pImage->setAnchor(LOWER_RIGHT_ANCHOR); //Bases our position off of the lower right corner. If we did not have the next line, this line would extend the image off the screen from -64, -64 to 0, 0.

pImage->setAnchorToParent(LOWER_RIGHT_ANCHOR); //Moves the image to the lower right corner of pWindow.

Site Development and Design by <CS>

Graphic Design by Nathan Schoell