Well, it’s been two weeks since my last post, so I’ll go through what I’ve done the past weeks.
Last week we were introduced to network programming, which I’m very interested in and have been ever since I played Diablo II with my best friend, wanting to learn how it ticked.
It isn’t my first contact with networking in practice or theory, back in high-school I went to a networking course where we learned the OSI-model among others. even if it was mostly practice related with Linux, it was plenty of theory as well; how TCP and UDP works, how a connection is established with a three-way-handshake (in TCP) and that UDP is pretty much fire-and-forget, you either get a response or you don’t (though the program we used sent another package if it didn’t get a response in a timely manner). So the first lecture was not anything new for me, though it was very refreshing to hear again, with a more programmer-oriented point-of-view.
The following lectures were not so confusing except that I had to rewrite a lot of the code to work with my Mac. I don’t have to use WSA startup or shutdown for example, as it is Windows specific. I also don’t have a Socket class, but instead use a generic int to point to the socket (like a index). Sockaddr_in on Mac doesn’t have the address split up into 4 octets (chars) either, but rather use inet_addr(char*) to get the binary equivalent of that address, so a string ”192.168.1.5” would be passed in with .c_str() to get a int value which would be in binary ”11000000 10101000 00000001 00000101. This could probably be improved for better readability by using a struct of 4 char or int:8, which I believe WSA does.
Other than that, it’s only some minor name changes (closesocket is just close) and I have to include more libraries.
During the weekend I fixed a Linked List class, it took me about 2 hours to create and another 2 to refine it. I decided to take another 2 private members to the class, an unsigned int for index and a pointer for the last node in the Linked List. The last node was just to ease the pop_back and push_back functions, push_back was easier since I could add the new node unto the last node and then reset it to the new node, which is more efficient when adding (the bigger the List becomes the longer it takes to get to the last), though it doesn’t do much for when you are deleting. Index was just to ease when calling for size, as it doesn’t have to loop through the elements to find the size. It is more efficient at the small cost of 8 bytes per Linked List, it do stack eventually, and can become several kilobytes in very big projects, but a few kilobytes to improve efficiency is a good tradeoff in my opinion.
This week (last week as of writing) we worked on rendering with DirectX. I’m biased when it comes to the DirectX vs OpenGL war, as I am using Mac and Linux quite frequently (as of last year, I’m only ever using Windows to play games ( which happens less and less too)), I am heavily in favour of OpenGL. It is not that I particularly like OpenGL, in fact, I think it worse on several aspects, but the one restriction that put DirectX low on my list, it is Microsoft only. Since I tried out Linux 10 years ago, I’ve been in favour of cross-platform, and after using Mac OS X for a year now, that feeling have only become more intense.
The reason I want to learn and am interested in network programming is because I eventually will work with it. Wether it be MMO or MO. If it has a dedicated server, the only OS that comes to my mind is Linux, Windows is too… flashy. A lot of the resources goes to waste providing the desktop, this, in my opinion, is very counter-productive. A server should be the bare minimum for background applications and the resources should be dedicated to the software it runs, not be wasted on a desktop you won’t see anyway.
I can’t say much about 3D rendering yet, it is a complicated topic, especially the shaders. Our group have decided on using DirectX (though it was close that it would have been OpenGL, hadn’t I advised them to start with DirectX). I will take the theory behind the 3D rendering with me, and I’ll help my teammates in any way I can, if they get stuck. I will however try to apply this knowledge to OpenGL as well. My expectations of myself is to make an engine that can render with DirectX on Windows and OpenGL on other systems, as DirectX is superior in many ways.
Finally, this weekend I’ve been working on Binary Search Tree, I have it pretty much figured out, but I’m still struggling with how I’m going to do most optimally when I remove a node. I’m thinking that if i remove a more value, I’ll link the less value of it instead and it’s more to the less value, it’s confusing just writing about it.