Saturday, November 26, 2011

0.3 material testing system

I got all the common material types working into the testing system, and got the camera controls working so the materials could be more accurately checked. Not much else was added to the tester. I attempted to get another bug to work on, but the ones listed were either already taken or seemed like to large of bugs to pick up at this one. I'll leave ccliffe a message in hopes he can get me some more work to do. I feel the work done in this tester wasn't good enough to account for 0.3, so I guess my only option is to do an extra amount of work for 0.4 to make up for this.

Thursday, November 24, 2011

Getting 0.3 caught up

Ya know, as a programmer, being separated from your computer, and thus your ability to work, for several days can make you feel awful helpless... but thats neither here nor there.

Still working on 0.3 as of now, though it was due a few days ago. Still trying to fix up the testing platform, though the tester and fix I made for 0.2 landed early last week. I want to get this tester to a point that I think it is actually worth while, capable of testing all the materials and with the ability to fine tweak the testing environment without actually changing code... So far I've changed the interface to better reflect how it will be controlled, added camera controls, and did some more research on the material system in CubicVR. I still have to get the materials all in and working, and I wanted to implement both an automation process and a environment dump into the testing platform, so I still got a day of work on it. This could have been done on time, yet my inability to remember to pack my laptop when I leave severely hampered it.

Even when I get the tester done... I don't feel it will be enough for me to justify my 0.3, so I'll take a glance through the CubicVR bugs, and see if I can nab one that I can fix in a day and bundle that in with the tester as 0.3. I have become pretty familiar with the way CubicVR works that I can't imagine it will be difficult to finish. I guess I am hoping do a bit extra will excuse my tardiness.

As a cool side note, the Doom 3 source code was released. I am pretty excited to get a chance to dig through it, see if I can find any patterns or conventions use that I can learn from and adopt.

Monday, November 14, 2011

Mouse controls in Firefox: Going from the ground up

So we were tasked with trying to find some way of manipulating the mouse controlling code for the Firefox browser. For those who haven't seen it before, the Firefox code base is massive, so randomly choosing where to start will likely leave you stranded with no way to find what your looking for. It is in your best interest to start from something you are already familiar with and move from there. Even in foreign code, there will be many overlapping tools or code bases you are likely to already be familiar with. So I started from the lowest level I could find, simply because I am most comfortable and knowledgeable there, which in this case was the Windows API.

So I went into this thinking two things:
  • I am trying to find where the browser gets the mouse data so I can manipulate it
  • This build is compiled on Windows, so it needs to talk to the Windows API to get hardware input
So this left me with an easy opening, I'd simply search through the code base looking for Windows API input based function calls, and that would narrow down my search to a few files. It did, leading me to the \widget\src\windows\ folder. From there I found nsWindow.h and nsWindow.cpp; after glancing through the .h file, I knew I was looking for things that modified the sLastMousePoint variable. With a quick flip through the CPP file, I found where it was initialized, and where it was updated, the DispatchMouseEvent function. Having had the needed information passed in by the function, I glanced down to find the GET_Y_LPARAM functions that set the event pointer position which later altered the sLastMousePoint variable. Knowing I had found the entry point for the mouse information, I simply swapped the X and Y values for the mouse and tested it. As expected, the browser now though the movement on the X was on the Y and vice versa. With that working, I called it a day, I now knew where the raw mouse information was injected from the OS.

If anyone wants more information on this, comment and I'll post an updated post with more explanation.

**Update** - If my previous explanation was too wordy, here is a simple code sample.

mozilla-central\widget\src\windows\nsWindows.cpp

bool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam,LPARAM lParam, bool aIsContextMenuKey,PRInt16 aButton, PRUint16 aInputSource)
{
bool result = false;
UserActivity();

...

nsIntPoint eventPoint;

eventPoint.x = GET_Y_LPARAM(lParam);
eventPoint.y = GET_X_LPARAM(lParam);

nsMouseEvent event(true, aEventType, this, nsMouseEvent::eReal,aIsContextMenuKey
? nsMouseEvent::eContextMenuKey : nsMouseEvent::eNormal);
...

Javascript: The language everyone wishes it wasn't

Having just gotten to watching the Crockford videos (well, 2 of 5 so far) due to the video's intimidating length (~7.5 hours in total), I'll say its definitely interesting and worth viewing. If you haven't yet seen them, they are easy to find on youtube (yahoo theater versions seem to have been moved or taken down).

The first part about the history of programing was quite interesting, but fairly inconsequential and can be skipped if you want to save yourself an hour and a half of time. It can be found here.

The second part really starts getting into the workings of javascript and its relationship to the browser. Crockford outlines many advantages and disadvantages to javascript, almost all of which I already knew, but he also outlined the ES5 standard, which had many awesome things that I think javascript sorely needed. The video can be found here.

Of the pros he discussed, the only thing that particularly sticks out is the sheer dynamism of the language, mostly given to it through its use of prototypical inheritance. This dynamism allows for a program to undergo a drastic change in structure or scope with less tedious refactoring involved when compared to other languages.

Of the cons he discussed, they all seem to stem from a simple lack of forethought on the part of the language's developers. Many of the issues came from the developers trying to make the language accessible to beginners, while they did manage to succeed in this, it resulted in many pitfalls that still plague the language today. One that stuck out to me was the NaN variable, as I didn't know that NaN does not equal NaN and that NaN is subsequently toxic to all numeric operations there after that use the NaN. Seems like a fairly useless implementation; I recall Objective C (terrible language btw...) having a similar situation with NaN, but I am unsure if NaN didn't equal NaN in that language.

The part I found most interesting was the new things that were being introduced in the ES5 standard. I was unaware of this functionality, but much of it seems very useful and would address many of the problems I have with javascript. A short document on the ES5 changes can be found here. These changes seem to primarily introduce ways to give greater control over the objects you create and use in javascript, giving you the ability to more rigidly and accurately structure your objects which in turn allows you to more accurately structure your scripts. I am not sure as of right now how widely supported these are across all the browsers out there, but I would hope that it is a fully supported standard by now, as I would like make use of these features in my future scripts.

I'm gonna finish this out by expressing an opinion I've had about javascript for sometime now... What holds javascript back is its attempt to be accessible and easy to learn. This is great for beginners but will seriously hold back the development of a more complex and intricate system that requires a large complicated infrastructure and mass resources to work. I think it may be in the interest of developers to create a new language, keep javascript around for compatibility and for beginners to code on, but give us the option of a cleaner, more robust language that we can work on for larger, more complicated systems that run in the browser. If the browser really is the future platform, the thing we are heading towards for all of our entertainment and media like some suggest, then a better implemented language is a must, because it will take far too long to improve and restructure javascript as to where it is the language we all need it to be.

Saturday, November 12, 2011

Using git and setting up my git server

Having used git for a few months now, I seem to have become fairly comfortable with it and have started implementing it into other projects that I have on the run. Really, with the exception of some initial start-up processes it can really be used as nothing more than a simply SVN server, so people familiar with SVN shouldn't have much of a problem operating git at a basic level. From this basic level, the users can slowly start unwrapping the layers of functionality within git. It doesn't seem to be too different from mercurial, I've heard some argue that git has a better branching system but I have heard opposing arguments that git lacks some of the utility that mercurial offers.

One con of git that I have noticed is that due to the way git works, simply making copies and copies of data as it branches and whatnot, it makes it inviable to keep binary resources(images, models, etc) grouped in with source code. If a project were to ever become large are well distributed, the sheer disk space usage that these resources would incur would very quickly spin out of control. I suppose this isn't too much of an issue, as it is probably good practice to keep your resources separate from your repo system anyways, instead using a more specialized solution to distribute a program's binary resources.

I recently got a git server running on my own personal server using gitosis. It was surprisingly difficult to get running, but this likely has a lot more to do with the fact that git server software are not usually built to run on Windows Server 2008 and are instead meant to run on Linux based system. Though through the use of cygwin and a few hours of tweaking I got a private git server running. If anyone is interested in having a place to privately store your code (as opposed to github which public unless you wanna drop like $8/month), you could set up your own git server running on your desktop or, once I get the security tightened up and tested on my server, I may be willing to give people accounts on my server so they may have access to a git repo that is unaccessible by the public.

Friday, November 11, 2011

Building Firefox in debug

So, I have recently attempted to build firefox in debug mode on windows. Having follow the instructions posted here after having downloaded all files from the git repository. Things were moving smoothly until I attempted to execute the make process, in which case it displayed the following error:
client.mk:121: *** This source tree appears to have Windows-style line endings. To convert it to Unix-style line endings, run "python mozilla/build/win32/mozilla-dos2unix.py". Stop.

I ran the python script it suggested, and after processing it, I re-ran the make process, but it continued to fail with the same error. I have looked up some in information on this problem, some have indicated that I have to set a option when I pull from the repository... I have yet to test this but I will update this when I have successfully completed the make process and share my findings.

**UPDATE** - So, found out why those errors were coming up, funny because I believe David Humphrey mentioned this in class (or someone did) but I didn't understand the context of what he was talking about. The problem is that git wasn't configured to deal with windows line endings correctly, so by entering the following command:
git config –global core.autocrlf false

and re-cloning the repo, this issue should be fixed.

**UPDATE** - So, took a while but it finally finished building. When I go to run it, for some reason it opens up my normal firefox application instead of the nightly build, but I'll figure that out tomorrow.