I haven't made any update for a while, I've been trying to split the code in initDevice that shouldn't really be in the init function if we want to create objects freely and not only once in the initialization of the game.. It would also get really cluttery and outright non-modular to create all objects we want in the initialization function.. We want to split the graphics code from the game code and instead provide tools to create objects freely from the main part of the game code.
So I've made a separate .h for the graphics, which declares a TSceneGraph class, this class will be used to handle what we see, so far it's very simple, and in fact only supports one(!!) object, only supporting one object is of course a rather useless scene graph(if it should even be called a scene graph), but let's take simple steps.
Now, the TSceneGraph class is based on the code from the DX11 SDK tutorial 5, but split into functions in the class. Most of the functions are as they where, except that the object creation code has been taken of of InitDevice() and put into CreateObject(), and the vertex data is expected to be written where the CreateObject() function is called.
I ran into some trouble doing this, which is why there hasn't been an update for a while(also, I'm on an internship, so I'm rather busy).
Anyway, the first problem:
Calling
CreateBuffer()
returned
E_INVALIDARG
and the application quit from
InitDevice()
.
After finally making sure that the D3D11Device was created with the flag
D3D11_CREATE_DEVICE_DEBUG
, I found that I was my buffer description bd containd some very strange flags, apparently, this was because I had not done
ZeroMemory(db)
. This leaves some strange random data in the fields of the buffer description that are not specifically defined.
Second problem:
I tried to create the objects as pointers to 3dObject structs containing a VertexBuffer and an IndexBuffer each.. This all got really confusing and I probably just didn't manage to access them in the correct way, leading to exceptions when trying to create the buffers. I realized that such a struct only contains pointers anyway, so there is not really any use of making them pointer variables.
So I just skipped the complicated stuff for now and made regular variables.
So after some time of trouble, I finally got it compiling again. Way!
It's still just the same triforce, and it's not even rotating! :O
BUT, it's all just a bit more modular and uses a "scene graph".
PS, since I'm away from home for a while I have to do this on a laptop, making development really tedious due the small screen(note the lack of plural).. sigh.