It's so rewarding to see something that started as a single huge file that has no OOP in it at all, to be refactored into tens of files and classes, fully OOP, fully abstracted.
Additions of this weekend were:
- The GraphicsObject abstract class, from which all concrete objects should inherit.
- The GraphicsObjectManager class, a singleton that manages a list of GraphicsObjects.
- The VBO abstract class, serves as a base for all other concrete VBOs (vertex, color, texture, ..).
- The VertexVBO class, a concrete VBO that copies vertex data into GPU memory.
- The IndicesVBO class, which contains the object's faces indices that will be copied to GPU memory.
- The VAO class, that associates several VBOs with itself.
- Camera was fully refactored to include the frustum info.
- The Pyramid was fully refactored to be a GraphicsObject.
- Scene was refactored, to use the GraphicsObjectManager.
I'm still very far away from meeting the specs, I'm really worried. I hope I can get most of them done by the end of the next weekend.
Tuesday, March 5, 2013
Sunday, February 24, 2013
Finally, The Graphics Engine!
Last Thursday night was a night from hell! I had to rebuild all of the libraries (GLTools, FREEGLUT, and MathEngine) from their sources, modifying their their projects' properties so that they compile and link without errors and warnings. Adding them to the Graphics engine project and get that to compile and link without errors or warnings was a whole other issue. I spent the whole night wrestling with Visual Studio. At 7 AM next day I finished the process successfully, but too tired to go ahead to write any code.
With the project all setup and ready for actual coding, the fun part started. Before taking SE456 - Architecture of Computer Games - last quarter, I thought I knew how to write software, but after I took that class, I discovered that I knew nothing about that before. Since then I fell in love with software architecture and anything related to that topic, including API design, OOP principles, and design patterns. When I apply these principles I learned, I really feel that I'm actually an ENGINEER as opposed to someone who just knows how to write code that runs.
I really didn't like the structure of the GLTools at all, or how the project was initially setup. So I played around a bit, using the baby steps approach. Wrapping all of what was originally there, transforming the project from a single file that had all the code in it to a project with multiple files and multiple classes. The main method now has only 5 lines of code. all the rest is handled by other classes.
It's far from being complete, but it's the very first step into a huge refactoring operation. This very first step is shown in the below UML. Very excited to continue the refactoring, hopefully transforming this into a strong graphics engine.
With the project all setup and ready for actual coding, the fun part started. Before taking SE456 - Architecture of Computer Games - last quarter, I thought I knew how to write software, but after I took that class, I discovered that I knew nothing about that before. Since then I fell in love with software architecture and anything related to that topic, including API design, OOP principles, and design patterns. When I apply these principles I learned, I really feel that I'm actually an ENGINEER as opposed to someone who just knows how to write code that runs.
I really didn't like the structure of the GLTools at all, or how the project was initially setup. So I played around a bit, using the baby steps approach. Wrapping all of what was originally there, transforming the project from a single file that had all the code in it to a project with multiple files and multiple classes. The main method now has only 5 lines of code. all the rest is handled by other classes.
It's far from being complete, but it's the very first step into a huge refactoring operation. This very first step is shown in the below UML. Very excited to continue the refactoring, hopefully transforming this into a strong graphics engine.
Tuesday, February 12, 2013
The Math Engine: More About C++ Than It Is About Math
Just Like Professor Keenan said, the math engine taught me a lot about C++ than it did about math. I list some of the things I learned about C++ below:
Wonderful class so far! :)
- Optional Function/Method Parameters:
- Those are the parameters that have default values, and are always put at the end of the parameters list. What I learned was not to define a default parameter twice (in the declaration and in the implementation), as it will not compile.
- Subscripting: Overloading the [] Operator:
- Overload it twice:
- Once with a return value of a reference type, which causes it be an I-value, allowing subscripted expressions on either side of the assignment operators:
- Vect& Vect::operator[](x_enum);
- To be used as either:
- V[x] = 5.0f;
- Or V[x] = V[y];
- The second version of it is intended to be used by a constant object of the class it is overloaded for:
- const Vect Vect::operator[](x_enum) const;
- Overloading Unary Operators ( +, -, ++, -- ):
- Can be overloaded by a global function made as a friend for the class:
- Vect operator+(Vect& v);
- Or as instance method, like below:
- Vect Vect::operator+();
- Nameless Unions: to reduce typing.
Wonderful class so far! :)
Saturday, February 2, 2013
Lagging Behind
With all of the bad stuff that has been going on in my country for more than a week now, and with my priority last week was given to studying and reading for the other Graphics class, I'm really lagging behind. I haven't written a single line of code in PA3 or PA4 so far. All what I have done was just some experimentation I wrote using Qt Creator for the file system.
For this, I have decided that this whole weekend is dedicated to prof. Ed Keenan's assignments. Period.
For this, I have decided that this whole weekend is dedicated to prof. Ed Keenan's assignments. Period.
Monday, January 28, 2013
Questions I had About the File System
I had a rough weekend and had to take care of few stuff, so I couldn't really get started on the file system. It is supposed to be easy and I believe it will. It's just that I'm confused about some stuff, and really didn't get the chance to ask about today.
The stuff that I read about the file system from the Game Engine Architecture book, and the Windows System Programming book made me not sure about how far I should go with the design of this file system for this particular assignment. I mean I don't know exactly what game programmers might need so that I can provide for them efficiently. Things like:
- Will they ever need to read text or characters for files? or all the need is just to read the files as binary.
- Shall I consider make the my file system I/O functions asynchronous so that a call to them doesn't block the game?
- Do I count on Windows to buffer the read/write I/O for me, or disable the buffering whenever I create a file handle, and do buffering on my own internally?
I started practicing a bit after I finished reading by coding some simple programs. Following prof. Ed's advice to make baby steps, prototyping to learn, and to use the tracer bullets concept to explore the unknown aspect of software design. In order to force myself that anything I write at this stage will be thrown away, I used a completely different IDE, namely Qt Creator. I used it several times before but I haven't used it for a while. I have to say after months of coding inside Visual Studio alone. Qt Creator is absolutely amazing, and fun to use.
I hope I could get it done soon, I'm waiting for the Unit Tests through, as they will clear out a lot of stuff.
The Math Engine seems to be a lot of work, but at the same time seems that it will be extremely fun. We'll see! :)
The stuff that I read about the file system from the Game Engine Architecture book, and the Windows System Programming book made me not sure about how far I should go with the design of this file system for this particular assignment. I mean I don't know exactly what game programmers might need so that I can provide for them efficiently. Things like:
- Will they ever need to read text or characters for files? or all the need is just to read the files as binary.
- Shall I consider make the my file system I/O functions asynchronous so that a call to them doesn't block the game?
- Do I count on Windows to buffer the read/write I/O for me, or disable the buffering whenever I create a file handle, and do buffering on my own internally?
I started practicing a bit after I finished reading by coding some simple programs. Following prof. Ed's advice to make baby steps, prototyping to learn, and to use the tracer bullets concept to explore the unknown aspect of software design. In order to force myself that anything I write at this stage will be thrown away, I used a completely different IDE, namely Qt Creator. I used it several times before but I haven't used it for a while. I have to say after months of coding inside Visual Studio alone. Qt Creator is absolutely amazing, and fun to use.
I hope I could get it done soon, I'm waiting for the Unit Tests through, as they will clear out a lot of stuff.
The Math Engine seems to be a lot of work, but at the same time seems that it will be extremely fun. We'll see! :)
Tuesday, January 22, 2013
The Memory System: "Technically" Done!
I was really worried about this system. So I decided not to touch it until I'm fully prepared. I refused to look at any posts on the forums related to this system until I start working on it, so that I won't feel influenced or demotivated. I spent this whole Saturday studying for it. I read all the slides and took notes, and then read the sections related to Win32 Heap creations and allocations from the Windows System Programming book, and also took notes.
At that moment only, I felt a little ready to start coding. I dedicated the whole Sunday night for that. The first hour though wasn't the happiest. It was just a tour of all the stubs and the unit tests already written there. I was trying to get the big picture of how the individual components of the system interact. It was so demotivating at first, to the point I didn't want continue working on it and leave it till another time. But I knew if I had done so, I would have felt extremely guilty about it, so I kept working.
To raise my moral a bit, I followed the 'baby steps' rule. I just wanted one test out of the 40 unit tests to pass in order to feel like I have done something. So I tackled the easiest one at all, the one that test the initialize() method that initializes the Mem object. And there it was, 1 success - 39 failures. Shortly, the 1 success became 3, and then 7. And after that, in order to move from there, I had to work on the whole system at once. So I kept banging my head against it, sometimes dealing with failed assertions and sometimes illegal memory access, all of that for about 4 continuous hours. 4 hours of debugging and stepping through the code and experimenting here and there. And suddenly, to my surprise, 40 SUCCESSES!
I was extremely happy, but that didn't mean I'm done. I'm not really satisfied with the code at all. It was all about passing those 40 unit tests and get it "Technically" done, but it's not the most elegant code in the world.
So the refactoring process started today, and two change lists were submitted already so far. The examples that Prof. Keenan gave in class today helped a lot clearing some of the stuff up. The best part about today's lecture was the revision of how to do software design. This is so important and extremely helpful, specially that it is transferable to any software development area, whether it's game development, web development, mobile development ... etc. It is so relevant to this assignment since now I have to iterate over my code again and again trying to enhance it and refine it.
At that moment only, I felt a little ready to start coding. I dedicated the whole Sunday night for that. The first hour though wasn't the happiest. It was just a tour of all the stubs and the unit tests already written there. I was trying to get the big picture of how the individual components of the system interact. It was so demotivating at first, to the point I didn't want continue working on it and leave it till another time. But I knew if I had done so, I would have felt extremely guilty about it, so I kept working.
To raise my moral a bit, I followed the 'baby steps' rule. I just wanted one test out of the 40 unit tests to pass in order to feel like I have done something. So I tackled the easiest one at all, the one that test the initialize() method that initializes the Mem object. And there it was, 1 success - 39 failures. Shortly, the 1 success became 3, and then 7. And after that, in order to move from there, I had to work on the whole system at once. So I kept banging my head against it, sometimes dealing with failed assertions and sometimes illegal memory access, all of that for about 4 continuous hours. 4 hours of debugging and stepping through the code and experimenting here and there. And suddenly, to my surprise, 40 SUCCESSES!
I was extremely happy, but that didn't mean I'm done. I'm not really satisfied with the code at all. It was all about passing those 40 unit tests and get it "Technically" done, but it's not the most elegant code in the world.
So the refactoring process started today, and two change lists were submitted already so far. The examples that Prof. Keenan gave in class today helped a lot clearing some of the stuff up. The best part about today's lecture was the revision of how to do software design. This is so important and extremely helpful, specially that it is transferable to any software development area, whether it's game development, web development, mobile development ... etc. It is so relevant to this assignment since now I have to iterate over my code again and again trying to enhance it and refine it.
Monday, January 14, 2013
The PCS Tree
Data structures are always interesting to me. The ability to store data in certain ways so that they could have special inherent features, such as fast search, or fast access, ... etc, is very exciting and rewarding. As professor Keenan mentioned, computer science and software engineering are all about moving data around, period. Finding the most convenient data structure to represent the data and efficiently implement the task at hand is all that matters.
The PCS Tree is really great for representing any hierarchy of objects. It reminds me of the Composite Design Pattern which I used in SE456 to represent the the hierarchy of collision boxes in the Space Invaders game. However, the PCS Tree is very generic, you don't need to write your objects in certain class hierarchies to implement the composite pattern. Just have your data object inherit from the PCSNode class, and it's then possible to add it to the PCS Tree.
This assignment wasn't hard, but it was very important as it served as a very good warming up for what's next. After 6 months of being far away from C++, and working with only managed languages such as Java and C#, C++ gets rusty and forgotten. C++ is a real big ocean, now one can really surround all of its knowledge, But once I start coding in it, I start to remember things little by little and appreciate the closeness it gives me to the machine. At that moment I realize how much I love C++ and how much I wish I could learn more about it. This class is going to be very challenging but I'm sure it's going to be very rewarding at the end. And as the Cadillac ad. said: "Welcome to the world of gentlemen, gentlemen!"
What I liked about the PCS Tree assignment:
1- Unit tests were provided so we make sure we're on the right track.
2- A great opportunity to practice my understanding of recursion and recursive methods.
I also like the way I implemented the dumpTree() method. I wrote it so that it prints the tree in sideways. So this hierarchy:
I'm worried about the memory system .. we'll see how that will go ...
The PCS Tree is really great for representing any hierarchy of objects. It reminds me of the Composite Design Pattern which I used in SE456 to represent the the hierarchy of collision boxes in the Space Invaders game. However, the PCS Tree is very generic, you don't need to write your objects in certain class hierarchies to implement the composite pattern. Just have your data object inherit from the PCSNode class, and it's then possible to add it to the PCS Tree.
This assignment wasn't hard, but it was very important as it served as a very good warming up for what's next. After 6 months of being far away from C++, and working with only managed languages such as Java and C#, C++ gets rusty and forgotten. C++ is a real big ocean, now one can really surround all of its knowledge, But once I start coding in it, I start to remember things little by little and appreciate the closeness it gives me to the machine. At that moment I realize how much I love C++ and how much I wish I could learn more about it. This class is going to be very challenging but I'm sure it's going to be very rewarding at the end. And as the Cadillac ad. said: "Welcome to the world of gentlemen, gentlemen!"
What I liked about the PCS Tree assignment:
1- Unit tests were provided so we make sure we're on the right track.
2- A great opportunity to practice my understanding of recursion and recursive methods.
I also like the way I implemented the dumpTree() method. I wrote it so that it prints the tree in sideways. So this hierarchy:
is printed out sideways as this:
I'm worried about the memory system .. we'll see how that will go ...
Subscribe to:
Posts (Atom)


