Showing posts with label 3D game development. Show all posts
Showing posts with label 3D game development. Show all posts

Sunday, February 26, 2012

I have scene graph!

I finally got my scene graph working. It looks like THIS:
Oops, wrong picture, here we go:

It's not beautiful, but now I can create different objects to my hearts content and transform them as I wish. If you want you can download the .exe(and the shader file) or the source.
Next in line I guess is adding textures, lighting and keyboard input, in whichever order is the simplest.  

The importance of Zero, and not overcomplicating things..

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.

Saturday, February 18, 2012

DirectX Tutorial 1

I finished the first DirectX tutorial, it takes you through setting up a project in Visual Studio C++ Express 2010, and linking in the DX11 SDK libraries.

Read it here.

Progress Report

I have no fancy pictures of any moving textured objects yet, but there has been some progress.

I've realized that the way the code is structured in the DX11SDK tutorials simply won't do even as a starting point for a game engine, for a few different reasons..
First off, the triangles shown are defined and put into a vertex buffer in the InitDevice() function, and while we could change the triangles in some other function later, this would get rather messy, since the same kinds of things would be done at different places. Also, after Tutorial 5 we draw out two objects, but we actually only have one, we transform it and draw it at two places, but it's only one object. This is kind of a problem.

So we need to add something that manages different objects, where they're at, how large they are, what triangles they contain, how they are drawn, and so on. I *think* this is what's called a Scene Graph. We want to do these things in a separate file from the main .cpp, because in the main .cpp we will want to focus on handling events in the game.

So I'm restructuring all the code(not much code, but hey), making a class called TSceneGraph in a different .cpp file, that will do all of the above. This also means moving all the DX11 initialization to this TSceneGraph.
Inside this class I can create a variable that decides what API to use, making it possible to chose if I want it to initialize an OpenGL window or a DX11 window, while keeping track of all the objects separately from the API.
Making this new structure is kind of hard for me and requires some thought, and also, since I'm note really used to C++ anymore, lots and lots of compiling errors. To brush up I read about header file and source file standard practice here, and about class definition here. Hopefully, I'll have a rudimentary scene graph working soon.

I also found how to chose which pages to include or not in the menu, so from now on any tutorials will have their own pages, instead of posts, linked from the Tutorials page in the menu above, and from a list to the right.

Monday, February 13, 2012

I Have Triangles!

I have Triangles!

Ok, so I said I would document the journey from the start, and I did mean it.
I've just got to rendering triangles, using DX11.


This may not look like much, but at least it means that I've gotten Visual C++ 2010 express to work, and compile. The code is actually just the tutorial02 from the DX11 SDK, but I took the important parts of that code and put it into a default win32 application project, which is why I also have a menu. And then of course I played around a bit with the vertices.

As stated in the first post the idea is to support OpenGL and older DX versions, but I will start with DX11.

Here's a link to the tutorial

Welcome!

Welcome to the AWESOME 3D Game Engine Project Blog!

Here I will document my progress on making a game engine, and not just any game engine, It will have to be awesome.
Now, while the goal is to strive for perfection, the ultimate goal is to learn. I have only little experience with game programming, on top of that, it's been almost 10 years since I programmed anything serious at all. So I will learn as I go and report what I find here, and maybe throw in some tutorials. You'll be with me from the start.

Why not use any of the already available open game engines?
First of all, more than wanting to make a game/games, I want to understand how it all works, and what better way than to try and make it yourself? of course, I won't try to reinvent all wheels, so I will start of from OpenGL and DirectX, and the essential parts of a game engine one by one.

So, what kind of engine is it I'm trying to make?
Ultimately, the idea is that the AWESOME 3D Game Engine shall support all graphical features of an advanced 3D game, such as Crysis 2, Skyrim etc. It will be versetile, and not focused on FPS, RTS etc. but work for any kind of 3D game, and environment. This may sound insane, but even if I fail, I will at least have learned something ;)

Future Features include:
OpenGL and Direct X9/10/11 support
Advanced Shaders
Normal Mapped Textures
Adaptive Tesselation Support
Physics and collision detection, probably middleware, PhysX or ODE etc.
Keyboard and mouse Input
Sound Output
Large Scene Graph Support
etc.

So laugh all you want, but here I go! :P