- 3D Stuff (12)
- AI (1)
- BumpTop (5)
- C/C++ (22)
- Open Source (8)
- Radiant (11)
- Seneca (6)
- Stuff (17)
- The Mortal Realm (2)
- Uncategorized (14)
- win32 (12)
- July 9, 2010: On Visual Studio 2010...
- December 22, 2009: Efficient Rendering, A La Mark.
- December 3, 2009: A Simple Opponent
- December 3, 2009: Blog++
- September 7, 2009: Food Budgeting
- July 3, 2009: Too Busy...
- March 26, 2009: How Do Patents Apply To Me?
- February 27, 2009: U.S. And Human Rights
- February 7, 2009: I've Been Busy...
- November 10, 2008: Radiant Update
Author Archive
On Visual Studio 2010…
July 9, 2010 by Mark.
When I look at Visual Studio, I see a large toolbox that is well organized and labeled. Much so is the case with VS2010 as it was with its predecessor. However, my analogy is inadequate when it comes time to use VS2010 on a production level. To give you some back story, I’ve been using it since it was in the beta stages and like all beta software, it had its ugly side. It’s flashy GUI makes the user feel like they are working with a paintbrush rather than a chisel. Yes, the GUI is hardware accelerated and relies heavily on the graphics card for its eye pleasing outfit. The anal minimalist side of me started screaming the instant I found this out. Why should a development tool be using the graphics card for anything??
I compare the jump from VS2008 to VS2010 like the jump from Windows XP to Vista. You went from a product that was designed to be fast and responsive to a lumber hulk of over designed and needless fluff that pegs your hardware when too many tabs are open. Visual Studio is supposed to be a tool, not a piece of art. When you start weighing it down with flashy effects and ‘themes’, it becomes something akin to a video game, not a development environment.
Moving on, I was under the assumption that the Microsoft team improved the short comings of VS2008. With VS2010, they actually took a step (or several steps) backwards. You get up-to-date Intellisense errors as you type your code (like C# does), which is great. However, if you try to look up a function declaration, it won’t be able to find it, even if it’s in the same file, 20 lines up.
On a brighter note, the team actually fixed multi-core compiles. If you have a quad core machine, it will properly utilize the cores and compile your source much faster. This I like. It has a built in testing environment that is much better than VS2008’s version. Code coverage actually works well. Custom visualizers work better now and won’t crash the IDE when a complex data structure is thrown at it (like a hashmap).
VS2010 has the potential to be decent but if you really want to jump head first into it, I would suggest you wait for a service pack.
Posted in C/C++, win32 | No Comments »
Efficient Rendering, A La Mark.
December 22, 2009 by Mark.
Rendering efficiently is one of those topics that is widely spoken about in the world of 3D graphics. Asking a question like ‘What is the best way to render a bunch of Objects’ is as open ended as asking ‘What is the best way to cook chicken soup.’ It is all based on application and preference and in all likelihood, there is no universal answer to this question. However, there are a series of specific solutions to this problem that can help in creating a mechanism that is best for the particular situation.
My problem is rather generic and will require a generic solution. I have a bunch of objects that need to be sorted by certain criteria in order to minimize state changes. It has to also support Shaders (Cg in my case) and it should minimize Shader state change between object rendering. Furthermore, an object must be generic enough to support complex models with bones and animations. On top of that, it should be easy to use. To start, we might need to break this down into smaller parts.
Objects:
For the time being, lets refer to an Object as a list of vertices inside a vertex buffer. It may or may not be accompanied by an index buffer, but in most cases it will. This Object will be shuffled to the graphics card to be rendered for each Object that exists in our world. This is inevitable until we support something complex like hardware based instancing.
State Changes:
Unless you want all objects to be rendered in the same way, in the same spot, and with the same vertices, you probably want some sort of state change. A state change is a change in any part of the system, whether it is the position of the camera, a new Object to be drawn, or a new effect. To quantify a state change, it is best to organize it into the types of state changes: swapping Render Targets, Shaders, Technique, Shader parameters, and using a different vertex or index buffer to draw an object. The order of the state changes, as listed above, matters because the changes at the beginning of the list are the most expensive and the changes at the end of the list are least expensive.
The RenderGraphNode:
This is a generic interface to which many types of nodes will be derived from. Each derivation of the node will be the embodiment of the changes listed above. In addition to the state change, the node will also be a container for child nodes. Usually the node will be generic enough to contain any type of node. However, in our case, we want to preserve an order to our nodes so that we optimize the state changes. The root of our tree will be a change in Render Targets. For the most part, there will only be one Render Target, the backbuffer (our screen). When a child node is added, it will automatically be sorted into the correct place in order to minimize the state change. This is especially important for Shader parameter changes because there can be multiple parameters in one Shader.
The RenderGraph:
In order to encapsulate all this, I need a class that will be the owner of Render Targets. It will be the only thing passed into the Renderer for drawing. At that point it will traverse the tree and render.
Sounds simple right? Yeah, but something doesn’t feel good about this design.
If we leave the design at this point, we are left with a bunch of nodes in which the user has to put together. This design is acceptable by some. In fact, OpenSceneGraph uses such a design for its SceneGraph. It is a bunch of classes that fit together in a tree fashion. Throw in a Visitor pattern into the mix for easy iteration and you have an engine. I’m not quite as happy with that design as my OpenSceneGraph counterparts are. The problem is, in my eyes, that it’s very verbose. Putting together a simple scene with an airplane in it was quite lengthy. You have to add a GeometryNode to a TechniqueNode to a ShaderNode to a RenderingTarget, and so on.
So back to my original question, what is the best way to implement something like this? When I figure it out, I’ll write about it.
Posted in Radiant, 3D Stuff, C/C++, Stuff | No Comments »
Blog++
December 3, 2009 by Mark.
I’m converting my blog to something a bit more useful. My long rants about my game engine were all leading towards a game of some sort. In the process I have recruited a friend to help me realize that dream. So, give a kind welcome to Alex.
Our first title will be a strategy turned-based war game by the name of ‘The Mortal Realm.’ It will feature my 3D engine and a robust battle system. As far as complexity goes, this game is one of the simplest we have come up with. It’s a simple point and click style of game with very minimal artwork. I’m hoping it will be a great test bed for my engine as well as Alex’s AI.
Posted in The Mortal Realm, Radiant, 3D Stuff, C/C++, Stuff | No Comments »
Food Budgeting
September 7, 2009 by Mark.
A food budget is a little bit different then a financial budget because you are budgeting quantities of ingredients rather then a lump sum of money. It is something that my wife just introduced me to and I am very excited to start doing it. Say you purchase a pound of ground beef but you only use up half of it. For example, rather then making the same dish again in order to use up the rest of the beef, you could make another dish with that exact amount of beef. However, she is having a difficult time trying to manage the data especially when you have more then one or two ingredients to work with.
So, I’m setting out on a journey to build her an application that would manage a database of ingredients. It would link the ingredients table with a table of recipes, making it easy to search. To be honest, I’m not a database person. In fact I have not done any DB work since first year at Seneca. I might need to pull out my old text books in order to re-learn how to use a DB. I’m thinking of using SQLlite for the back end and straight up C++ on the front end (though C# has crossed my mind). It will be all open source obviously.
Posted in Open Source, C/C++, Seneca | No Comments »
Too Busy…
July 3, 2009 by Mark.
I’ve been pretty bad at keeping my blog up to date as of late. With my wedding just around the corner, most of my time has been wasted planning things and what not. I found myself wishing for an extra hour or two a day just so I could fit in all the stuff that I like doing, such as programming and reading books. But, alas, it is an important part of life that requires a great deal of effort. And there is really nothing I can do about it (perhaps eloping would be easier) - everything, and I mean everything costs money.
I’m nearing my one year anniversary at McAfee (amongst other things) and finally I am at a comfortable stage in my life. I have a stable job which does not work me to the bone. I couldn’t be happier with it. But, my financial situation is inching closer and closer to the red line, all because my expenses as of late have been sucking my savings up. One of which was the purchase of a new house in Hamilton. So, I’m looking for a way to get a few more bucks. I started looking into something that has interested in for quite some time - Teaching.
Hamilton is home to Mohawk College. I attended this school before going to Seneca College and found it a decent place to learn. Though, after learning of what they had to offer I opted out for the Computer Programming stream at Seneca. What interests me is not the full-time position but night school, part-time classes. A teacher at Seneca told me that Ontario requires its colleges to have a certain amount of professors with a Masters degree or higher. But only for day school and only in their core streams. Night school, however, does not have that requirement but I bet having a Masters looks good when applying for a teaching position. My Bachelors might be beaten out of a teaching position by someone with more educational experience. So I’m hoping my experience working will carry some weight.
On Mohawk’s webpage they specify a few courses that interst me (if they are available in night school). These are ‘Introduction to C,’ ‘Object Oriented Design,’ and so on. Being first year courses, I fear that they might not be available in night school. I will be contacting the head of the Computer Department at Mohawk with regards to this. If anyone from Seneca or perhaps, any other college in Canada, can offer advice, it would be greatly appreciated.
Posted in Stuff, Seneca | No Comments »
How Do Patents Apply To Me?
March 26, 2009 by Mark.
I’ve been diligently working on a scene partitioning system which combines an Octree with a Uniform Grid. Basically, the way it works is that you build a loose Octree, which starts 4 levels deep. When each node reaches a critical mass, it subdivides into another level. The max levels you can have (While still being optimal) is 7. So, let’s assume that we have a detailed scene with a 7 level Octree. At the bottom of the Octree, each node is 128th the size of the entire area you are encompassing and it is also uniformly proportional to the entire area. You can build a Uniform Grid out of the bottom most nodes giving you the best of both worlds.
When all this is built, to add and remove items from the grid is a matter of doing simple division of finding out the exact spot in the Uniform Grid where the object belongs. Since pointers are being shared between Octree Nodes and Uniform Grid Nodes, you essentially add an item to the Octree in O(1) time (Adding to a Tree structure usually Takes O(Log n) time). Collision detection with simple objects is O(1) time while with complex objects it is O(Log n) time. What I have done is made the Octree a bit faster in some areas. Good idea, isn’t it?
Here is my problem. While randomly googling on this topic, I found a patent for this idea. The patent is very similar to what I just described. What I want to know (For all you Law junkies out there) is how does this effect me? Can I get sued? Does it matter that my implementation is my own and not copied from the patent? Does it matter that my implementation is Open Source? Are there ways to get around this patent (My implementation is different but algorithmically similar)?
Any suggestions are welcome.
Posted in Radiant, Open Source, 3D Stuff, C/C++, Stuff | No Comments »
U.S. And Human Rights
February 27, 2009 by Mark.
I knew that the U.S. had some Human Rights problems itself but it came as a shock to me that U.S. has a long and painful record of Human Rights violations. Even if you are not into politics, it makes for a very enlightening read.
Posted in Stuff | No Comments »
I’ve Been Busy…
February 7, 2009 by Mark.
I always hated the holidays. Christmas is probably the worst time of the year and what makes it so is all the rushing and running around and pointless stress. Giving and spending time with your family should be the focus of Christmas, not some faceless marketing campaign. On top of all this, I moved back to Hamilton. I should note that if you’re planning on moving in the middle of the winter time, make sure you do it on the warmest day possible. This was our second move on one of the coldest days of the year and it was the least bit pleasant. Regardless, all is well now and I have the next 10 months to recuperate.
I got my hands on a copy of Windows 7, and I am not impressed. It is, hands down, Vista Service Pack 2. Vista never impressed me, and Windows 7 is barely an upgrade from that. I have to admit, some of the features it has run faster, as they should, and are generally more efficient. For example, I run Windows 7 in VMWare. This VMWare image is being hosted by a Vista Machine running on raw hardware. Even though Windows 7 is virtualized, it still runs faster then Vista on raw hardware. Not only that, all the settings are buried so far away from the user that it becomes absurd. Changing network settings takes twice the amount of time as it used to (and this is not including the UAC pop-ups). As a word of advice, if you’re a poweruser and you want to have ease of use, stick with Windows XP, or 2000. If you are a Vista lover, Windows 7 is for you. Basically, ditch Vista by going back to XP/2K, or upgrade to Windows 7 once it matures.
On a side note, on the off chance I will upgrade to Windows 7, I have been looking for alternate shells and some seem promising. I’d rather have a shell that is poweruser friendly and fast. Litestep is one such product. Unfortunately, there is no way to actually replace all the functionality of explorer so there will be some annoyances. Linux is looking much better each time I look at Vista or Windows 7. With the way this post is going, maybe I should rename my blog to Grumble Grumble, Things that piss me off.
I’m currently looking into a thing called “Visual Studio Visualizers.” They are small scripts that allow you to modify the way the debugger displays information. I’m not done my research yet, but expect a nice big article on this. It’s barely documented and really cool :).
Posted in Stuff | No Comments »
Radiant Update
November 10, 2008 by Mark.
I held a bet with my brother to see who can guess the number of lines of code (or at least, close to it) my rendering engine is comprised of. Neither of us were close but I got a good sense of how much work went into this giant mash of code. About 25,000 lines is the total. That total is comprised of approximately 12,000 lines of computational code and about 13,000 lines of comments. This number does not include blank lines and such things. Regardless, it’s a staggering number for a project that is being worked on by one person, part time.
The engine itself is about 45% complete, with the majority of planning done. One of the components, my math module (it handles math stuffs and collision detection), is finally finished. I can breath a sigh of relief, it’s not easy stuff. Unfortunately I didn’t write any unit tests for it so I don’t know if it actually works or not. The project is open source. So, if anyone is masochistic enough to write a tests for my math module, by all means :).
Posted in Radiant, 3D Stuff, C/C++, Stuff, win32 | No Comments »
Primary Export: Pain
October 28, 2008 by Mark.
Everyone knows (or should know) that when you put together a DLL, you need to export functionality so that programs using your DLL know where to find your functions. This is usually done by prefixing classes or functions with __declspec(dllexport) or manually writing a definition file. Straight forward and right to the point. But what happens when you need to export something that does not have a name. Say for example, an overloaded new operator. What the hell does a new operator look like as a definition symbol?
I’ll give you a hint: its not human readable!
So, before I actually spoil the beans and tell you what I did, I have to explain why I did it, because its rather interesting. Radiant, my game engine, is split into 6 DLLs, all of which touch and create dynamically allocated memory somewhere. The problem with allocating memory all over the place is that you need to delete it in the same address space (or DLL) as you allocated it in. With that said, to make it more complex, I had to overload the new and delete operators in order to wrap around _aligned_malloc() and _aligned_free() calls. This is a special type of allocation that allows you to align dynamic memory to an address that is divisible by 16 (or any other value). This is crucial if your using SSE or any special instruction set because all values need to be aligned to at least 16 bytes.
Anyway, going back to the problem at hand, I have a bunch of overloaded operator functions that cannot be exported because if I try to add the __declspec(dllexport) prefix to them, the compiler will scream and tell you that the declarations of the functions do not match up with what is defined internally. Basically, what I am stuck with are a handful of functions that cannot exported programmatically. This is where the definition file comes into play. Exporting a function or class is as easy as entering its name in the definition file under the heading of EXPORTS. But here is the kicker, the overloaded operators of ‘new’ and ‘delete’ do not have a name! They are declared internally in a header that exists in the compiler’s own static data, and there’s no way to override inclusion of that header. Therefore, the only way is to manually enter the function’s mangled name into the definition file.
The mangled name looks something like the following:
| ??2@YAPAXI@Z | (void * __cdecl operator new(unsigned int)) |
| ??3@YAXPAX@Z | (void __cdecl operator delete(void *)) |
| ??_U@YAPAXI@Z | (void * __cdecl operator new[](unsigned int)) |
| ??_V@YAXPAX@Z | (void __cdecl operator delete[](void *)) |
In fact, those mangled names are fairly generic and may not match up correctly. But their names are very similar to what they should be. A more specific example of the name would be located in the Visual Studio directory under VC\crt\src\intel\_sampld_.def. This file contains a slew of definitions. What your looking for are the first four definitions that look very similar to the ones posted above. If you are running under a x64 or Itanium architecture, there are definition files for those architectures as well.
After a successful compile, all dynamic memory is allocated and deallocated in a single DLL’s memory space. This prevents the Heap Corruption errors I was getting before and allows me to further enhance the allocation and deallocation of dynamic memory. Woot!
I would suggest reading the following link because it contains a very good description of how this process works. Unfortunately, I stumbled upon this file AFTER I already fixed this problem. Alas, C’est La Vie.
Posted in Radiant, C/C++, Stuff, win32 | No Comments »