So I have finished what would be the foundation part of the RTS programing book. That is mostly on textures and skinning and the heavy lifting of DirectX. Now it is time to put all the pieces together. First though, I need to take a step back. The code in the book is fairly simple. In that there isn't any real resource management, and much of the initialization information is hard coded in. The author does state that this is intentional just to focus on the aspects of the game programing, and not what would be considered more generalized programing. Basically the resource manager is left as an "Exercise for the Reader."
Fortunately, this is where I can start re-using from the MazeMover project. I did create a INI file parser and simplified resource manager for the SDL objects. Now to adapt both for each other.
This is were things get creative. I have to now look at both sets of code and figure out what each is really doing. So right now it is a lot reading and poking and seeing what has to be done. This is were the power of code encapsulation really comes in to play. I can now muck around with all the various implementations but still present the classes as they are in the book.
Still it means pulling some parts out and fitting in new ones, but if done correctly then the application itself does not change.
Rogue is a dungeon crawling video game first developed by Michael Toy and Glenn Wichman around 1980. It is generally credited with being the first "graphical" adventure game, and was a favorite on college Unix systems in the early to mid-1980s, in part due to the procedural generation of game content.
-- http://en.wikipedia.org/wiki/Rogue_(computer_game)
-- http://en.wikipedia.org/wiki/Rogue_(computer_game)
Tuesday, October 19, 2010
Monday, October 4, 2010
Flying though the sky
So I have finished all of Chapter 4 and I am on the final exercise of Chapter 5 of the RTS programming book. Right now I am have an issue with the vertex shaders and the terrain. Once again, this will require going though the example code and taking a look at mine to see what little step I have forgotten.
So far it is just a fancy terrain map with some functions for later use. Most of the problems I have encountered so far usually stem from tying to understand the subtleties of graphics programming in Direct X. It is kind of interesting, I am not much of an artist so I don't know much about creating texture files and actual models. However, I know all the math that goes on behind the scenes. Matrix multiplication and inverses. Using dot products to find projections and distances.
I am getting in to DirectX. Well at least I am enjoying programming 3D graphics. It just makes sense. Put things in the world, then "do the math" to show it on the screen. I was thinking about writing my own 2D Isometric view engine, but being the engineer that I am, I would rather use someone else tools then build my own.
So far it is just a fancy terrain map with some functions for later use. Most of the problems I have encountered so far usually stem from tying to understand the subtleties of graphics programming in Direct X. It is kind of interesting, I am not much of an artist so I don't know much about creating texture files and actual models. However, I know all the math that goes on behind the scenes. Matrix multiplication and inverses. Using dot products to find projections and distances.
I am getting in to DirectX. Well at least I am enjoying programming 3D graphics. It just makes sense. Put things in the world, then "do the math" to show it on the screen. I was thinking about writing my own 2D Isometric view engine, but being the engineer that I am, I would rather use someone else tools then build my own.
Monday, September 20, 2010
It is the little things
After beating my head against the wall, I called in a friend to help look at and debug the code. If I were in a collaborative environment to begin with, I would have asked for another set of eyes sooner. But after lunch at a nearby sub shop, I had him poke at my code.
Although the exact error was not found at that time, he did show me some more tricks working with Visual Studio and at least gave me a fresh perspective on where to focus my search. After narrowing down the location, I was able to go back to the example code and figure out what I was missing.
In short, it was the typical "off by one" error. In this case I was using a <= when it should have been <. So after that was done, a few more errors in math were found in the rendering portion and finally I had completed the exercise. Now I have half of a nice random terrain generator.
This is designed for an RTS so it has peaks and valleys. I am not sure if I will have non-flat terrain in YAR itself, but it other aspects, such as path finding and object placement will be useful. Orginally I was thinking of doing a simple 2D iso tile system, but it seems fairly straight forward to do this as a terrain/texture mesh over a 3D surface, even if the surface is going to be flat. Since most of the heavy lifting has been done in DirectX (and OpenGL) like matrix transformations and what not, I might as well stay here as well. I will be easier to make it simpler later.
Although the exact error was not found at that time, he did show me some more tricks working with Visual Studio and at least gave me a fresh perspective on where to focus my search. After narrowing down the location, I was able to go back to the example code and figure out what I was missing.
In short, it was the typical "off by one" error. In this case I was using a <= when it should have been <. So after that was done, a few more errors in math were found in the rendering portion and finally I had completed the exercise. Now I have half of a nice random terrain generator.
This is designed for an RTS so it has peaks and valleys. I am not sure if I will have non-flat terrain in YAR itself, but it other aspects, such as path finding and object placement will be useful. Orginally I was thinking of doing a simple 2D iso tile system, but it seems fairly straight forward to do this as a terrain/texture mesh over a 3D surface, even if the surface is going to be flat. Since most of the heavy lifting has been done in DirectX (and OpenGL) like matrix transformations and what not, I might as well stay here as well. I will be easier to make it simpler later.
Friday, September 10, 2010
Hitting a New Wall
I am slowing working my way though Programming an RTS Game using Direct 3D. Only on Chapter 4 but I am taking my time to go over the code in the book and the full code on the CD to understand what I am doing. Not to mention going back to some DirectX resources to see why I am doing what I am doing.
However, I have hit my first real stumper. Some how I am getting corrupt memory in my initializations. Annoyingly it happens at slightly different points in the code when I run it. But the error is some type of heap corruption or other misaligned memory. Unfortunately I have yet to see where the real problem is. Also the example code itself runs fine, yet mine does not. Now being the good learner, I am adding my own coding paradigm to the example code, so there are differences. But I am not sure what difference is causing the error in question.
The upside is that I am getting more familiar with the Visual Studio Debugger. It is kind of fun and for the most part I have been able to figure it out. Right-Click is your friend. Now I am still a little green trying to read some of the raw assembly code, but I got though reading UNIX trace/truss commands so this will just take some time to start seeing the patterns that have useful information.
However, I have hit my first real stumper. Some how I am getting corrupt memory in my initializations. Annoyingly it happens at slightly different points in the code when I run it. But the error is some type of heap corruption or other misaligned memory. Unfortunately I have yet to see where the real problem is. Also the example code itself runs fine, yet mine does not. Now being the good learner, I am adding my own coding paradigm to the example code, so there are differences. But I am not sure what difference is causing the error in question.
The upside is that I am getting more familiar with the Visual Studio Debugger. It is kind of fun and for the most part I have been able to figure it out. Right-Click is your friend. Now I am still a little green trying to read some of the raw assembly code, but I got though reading UNIX trace/truss commands so this will just take some time to start seeing the patterns that have useful information.
Friday, September 3, 2010
FORTRAN is the Latin of Engineering
If you went to Engineering school in the 80's you most likely had to take a programing in FORTRAN class. As I started in 1989, I too took FORTRAN. Two years later, entering freshmen learned C instead of FORTRAN. Granted I also took the C programing class as an elective, but FORTRAN was the required language. Also I think my year was one of the last years to have a mechanical drawing class with actual boards, pencils and T-Squares. And although I had my father's slide-ruler, we were allowed to use electronic calculators.
So learning "old" technology is very comfortable for me even if it is academic. Such is how I feel right now working with DirectX9. It is on the way out since XP is finally no longer allowed to be put on new systems and soon that will be moot since it wont have the support of new hardware anyway. I should be learning DX10 or DX11. However there is a lot more written and available for DX9. Currently most of the books of the variety "Programming $GAME with DirectX" are written for DX9. So I have a lot more examples to pull from.
Now in my case $GAME = RTS. Though I do have access to the online copy of RPG as well. So between the two of them I am getting a good idea of all the moving pieces that go in to a fairly typical, though small, game that I want to create for YAR.
I have found learning "old" methods very useful, though it has pigeon-holed me a few times. On the other hand, I am one of the people that can bring grognards up a few centuries and use at least more modern equipment then what they were using. Also since I am spending as much time learning the concepts of 3D graphics programing (like texturing and transforms) I can use all the examples I can get. My quick look in to DX10 shows that the concepts are still there but the implementation has changed (like Vertex and Index Buffers.) You still have to know how to use those items from a conceptual standpoint regardless of the API. When I poke a OpenGL sometime in the future, I will not have to learn basic 3D programing.
So learning "old" technology is very comfortable for me even if it is academic. Such is how I feel right now working with DirectX9. It is on the way out since XP is finally no longer allowed to be put on new systems and soon that will be moot since it wont have the support of new hardware anyway. I should be learning DX10 or DX11. However there is a lot more written and available for DX9. Currently most of the books of the variety "Programming $GAME with DirectX" are written for DX9. So I have a lot more examples to pull from.
Now in my case $GAME = RTS. Though I do have access to the online copy of RPG as well. So between the two of them I am getting a good idea of all the moving pieces that go in to a fairly typical, though small, game that I want to create for YAR.
I have found learning "old" methods very useful, though it has pigeon-holed me a few times. On the other hand, I am one of the people that can bring grognards up a few centuries and use at least more modern equipment then what they were using. Also since I am spending as much time learning the concepts of 3D graphics programing (like texturing and transforms) I can use all the examples I can get. My quick look in to DX10 shows that the concepts are still there but the implementation has changed (like Vertex and Index Buffers.) You still have to know how to use those items from a conceptual standpoint regardless of the API. When I poke a OpenGL sometime in the future, I will not have to learn basic 3D programing.
Thursday, August 12, 2010
In Scottland they speak English
There is English and there is English. I am from the US and have what is as close to what is the "Neutral US Accent." This is the accent of the majority of news casters and for the most part the non-metropolitan east coast accent. Being a geek I grew up with Monty Python and other British TV as well as spent some time in Australia. And for the most part I never had an issue understanding most other non-US English speakers. The vocabulary may change, but I could still understand what the words were said if I did not fully understand the context of the words. Then there is Scotland. In theory they speak English, but it is fairly difficult to tell at times.
What does this have to do with programing? Quite a bit. There is C and C++ and for the most part it is all the same. However everyone puts their own accent on it. Since I am now learning DirectX, I am learning to understand the vocabulary used by Microsoft API base programs and able to translate in to my own understanding of the languages.
However, I am doing it in the most curious of ways. I started with the DirectX 9 Tutorials from MSDN as I mentioned before. But there was quite a bit of details missing. Now I am going though Programming Role Playing Games with DirectX by Jim Adams. The particular edition I have uses DirectX 8. Of course in reality I should be working with DirectX 10 or 11. So here I am flipping between that book, the MSDN site as well as the occasional Googling to see what other people have done.
I feel like I am having to translate English to English and back in to English again. If Russian were in the middle, I could have gotten: "The Vodka is strong, but the meat is rotten."
What does this have to do with programing? Quite a bit. There is C and C++ and for the most part it is all the same. However everyone puts their own accent on it. Since I am now learning DirectX, I am learning to understand the vocabulary used by Microsoft API base programs and able to translate in to my own understanding of the languages.
However, I am doing it in the most curious of ways. I started with the DirectX 9 Tutorials from MSDN as I mentioned before. But there was quite a bit of details missing. Now I am going though Programming Role Playing Games with DirectX by Jim Adams. The particular edition I have uses DirectX 8. Of course in reality I should be working with DirectX 10 or 11. So here I am flipping between that book, the MSDN site as well as the occasional Googling to see what other people have done.
I feel like I am having to translate English to English and back in to English again. If Russian were in the middle, I could have gotten: "The Vodka is strong, but the meat is rotten."
Tuesday, August 10, 2010
Looks like a Duck
It has been a few days playing with DirectX and the tutorials from MSDN. As tutorials go, the MSDN collection is fairly weak. Lots of steps missing that you need to go research or already know. Very little in the way of explanation. On the upside it was nice to know that I could fill in the holes myself, and that I have learned quite a bit so far.
Like the Win32 API, DirectX (at least version 9) is much closer to C than C++. Even glancing up at version 10 and 11, it is still very much the same. One of the scary parts I found was:
if(FAILED(g_pVB->Lock(0, 0, (void**)&pVertices, 0)))
return E_FAIL;
Egads. Casting void pointer to pointer of a reference. Perfectly legitimate C code, and quite common to see. But always a construction that makes me curious about the "power" of C when you need to go though some interesting hoops to pass the data you need around. Ideally this would be a rare thing. You take care of this level of detail once in your lower level engine code and not worry about it when you are designing your game at the upper level.
So now to find some more in depth information. Looks like I am finally signing up for Safari Books again. Primarily because the one book that is recommended to me is out of print, but is available there for reading online. This way I can take a look at other books as well and determine which ones I will want to purchase for my own library.
Like the Win32 API, DirectX (at least version 9) is much closer to C than C++. Even glancing up at version 10 and 11, it is still very much the same. One of the scary parts I found was:
if(FAILED(g_pVB->Lock(0, 0, (void**)&pVertices, 0)))
return E_FAIL;
Egads. Casting void pointer to pointer of a reference. Perfectly legitimate C code, and quite common to see. But always a construction that makes me curious about the "power" of C when you need to go though some interesting hoops to pass the data you need around. Ideally this would be a rare thing. You take care of this level of detail once in your lower level engine code and not worry about it when you are designing your game at the upper level.
So now to find some more in depth information. Looks like I am finally signing up for Safari Books again. Primarily because the one book that is recommended to me is out of print, but is available there for reading online. This way I can take a look at other books as well and determine which ones I will want to purchase for my own library.
Subscribe to:
Posts (Atom)
