So recently I've been working with JavaScript, which I have little experience in.Mostly I just go ahead Google "thing I need to do" + JavaScript.
I've decided to change that and really learn a bit about the language. I was surprised to find that JavaScript is a fully object oriented language and is hands down the best language out there to do anything on a web browser that needs user input and to provide a smooth experience (i.e. Ajax etc)
Also the Mozilla Dev Center is a great resource for JavaScript (and a few other web related languages)
So if you haven't already, give JavaScript another look.
LaunchingPad
Follow me on a journey through the code! Hope you enjoy whatever is currently holding my attention and maybe you can even learn something along the way. Everything from micro board programming on the MSP340 to openGL programming for the iPhone.
Thursday, December 29, 2011
Saturday, October 29, 2011
Let's play with OpenGL! Part 1
So yes yes I'm back after a small hiatus, but I'm back starting over fresh.
So let's talk about OpenGL!
First off what is OpenGL? OpenGL is a graphics library used to interface with your video card to issue commands to it. It might not looking it but Pong and Arkham City, Battlefield 3 and Modern Warfare all have one thing in common. They simply get graphics cards to draw a bunch of pixels on screen and add a color to them.
So OpenGL allows us to interface with the video card to draw pixels so we don't have to play with low level memory access or commands each time we want to do it. It allows us easy human readable commands to make the pixels on the screen do what we want.
DirectX is another popular graphics library that does the same thing as well, and is more popular than OpenGL as of right now, but don't be fooled; OpenGL is every bit just as powerful as DirectX. The reasons behind its lack of popularity are all in the politics that software companies play, but that's for another post.
Next up: Getting OpenGL installed and setting up your work environment!
So let's talk about OpenGL!
First off what is OpenGL? OpenGL is a graphics library used to interface with your video card to issue commands to it. It might not looking it but Pong and Arkham City, Battlefield 3 and Modern Warfare all have one thing in common. They simply get graphics cards to draw a bunch of pixels on screen and add a color to them.
So OpenGL allows us to interface with the video card to draw pixels so we don't have to play with low level memory access or commands each time we want to do it. It allows us easy human readable commands to make the pixels on the screen do what we want.
DirectX is another popular graphics library that does the same thing as well, and is more popular than OpenGL as of right now, but don't be fooled; OpenGL is every bit just as powerful as DirectX. The reasons behind its lack of popularity are all in the politics that software companies play, but that's for another post.
Next up: Getting OpenGL installed and setting up your work environment!
Wednesday, August 17, 2011
Worry not I'm still here
I just started enjoying summer a bit more...you know...going outside. I've been indoors doing geek things most of the summer and now that its nearly done I just need to get outdoors some more. You know biking, rock climbing etc.
Did anyone else go to Otakon by chance? What are your thoughts of the con this year? Personally I thought the panels were a bit stale...same old same old from years gone by. Nowadays I go to the same panels every year with nothing new grabbing my interests. Maybe I'm just getting too old for an anime convention.
Did anyone else go to Otakon by chance? What are your thoughts of the con this year? Personally I thought the panels were a bit stale...same old same old from years gone by. Nowadays I go to the same panels every year with nothing new grabbing my interests. Maybe I'm just getting too old for an anime convention.
Tuesday, July 19, 2011
Sidenote: Programming blogs
Anyone else just love reading programming blogs? Recently I've take up reading a few programming blogs quite a bit at home (and at work too :P)
Its very enthralling to read older posts from high level bloggers from high tech companies. Some of my favorites are:
Do you have any favorite programming / tech blogs?
Its very enthralling to read older posts from high level bloggers from high tech companies. Some of my favorites are:
- The Old New Thing by Raymond Chen always gives good insight into how microsoft works and how we've come up with the product we all know and love / hate.
- Coding Horror by Jeff Atwood speaks about the lots of meta-programming stuff, stuff about comptuers that programmers are likely to be interested in, sometimes tips he posts tips on design too.
- Joel On Software by Joel Spolsky speaks alot about management of programmers, everything from how to hire, sell your product and how to treat programmers at work.
Do you have any favorite programming / tech blogs?
Wednesday, June 29, 2011
Pushing and Poppin'
In OpenGL when you apply any type of transformation or apply any type of texture or property, it is applied globally to everything else below it.
So if I were to do this:
for(int i = 0; i < 5; i++)
{
glColor3f(1.0,0.0,0.0) ;
glTranslatef(i*3,0.0,0.0);
glutSolidTetrahedron (); // TETRAHEDRONS!!
}
We would expect to see 5 evenly spaced tetrahedrons(think pyramids) right? Of course since I'm asking you would expect its wrong, so I know you wouldn't whip out your visa and bet with me.
See the translation is applied to the entire world and it persists. Therefore instead of this:
You end up with this
^ ^ ^ ^ ^
How do we solve this? Simple you push and then pop before you make the translation! By pushing into a sort of matrix buffer you tell the compiler : Only apply the changes to things inside this matrix, nothing else. So if you do this instead:
for(int i = 0; i < 5; i++)
{
glColor3f(1.0,0.0,0.0) ;
glPushMatrix();
glTranslatef(i*3,0.0,0.0);
glutSolidTetrahedron (); // TETRAHEDRONS!!
glPopMatrix();
}
and with that you will get the expected result.
So if I were to do this:
for(int i = 0; i < 5; i++)
{
glColor3f(1.0,0.0,0.0) ;
glTranslatef(i*3,0.0,0.0);
glutSolidTetrahedron (); // TETRAHEDRONS!!
}
We would expect to see 5 evenly spaced tetrahedrons(think pyramids) right? Of course since I'm asking you would expect its wrong, so I know you wouldn't whip out your visa and bet with me.
See the translation is applied to the entire world and it persists. Therefore instead of this:
^ ^ ^ ^ ^
You end up with this
^ ^ ^ ^ ^
How do we solve this? Simple you push and then pop before you make the translation! By pushing into a sort of matrix buffer you tell the compiler : Only apply the changes to things inside this matrix, nothing else. So if you do this instead:
for(int i = 0; i < 5; i++)
{
glColor3f(1.0,0.0,0.0) ;
glPushMatrix();
glTranslatef(i*3,0.0,0.0);
glutSolidTetrahedron (); // TETRAHEDRONS!!
glPopMatrix();
}
and with that you will get the expected result.
Wednesday, June 22, 2011
OpenGL
So I've been working on OpenGL on the iPhone, but I'm still kinda learning Objective C and the iOS libraries so its a bit slow going. This week I started up messing around on OpenGL on a PC. The first pictures is from a projection view and the second is from an orthographic view. Gonna use open GL to work on a small project of mine in my spare time.
I also know DirectX 10, but I just have more fun in OpenGL. I'm thinking of taking it to the next level and buying the OpenGL SuperBible( The Blue Book) and learning shaders a bit better. (Shaders are hard!)
No code samples today as I feel its rather basic and just a bunch of setup stuff unless you want to watch lots of arrays initialized like this:
GLfloat cube[][3] = {{-1.0,-1.0,-1.0},{1.0,-1.0,-1.0},{1.0,-1.0,1.0},
{-1.0,-1.0,1.0},{-1.0,1.0,-1.0},{1.0,1.0,-1.0},
{1.0,1.0,1.0},{-1.0,1.0,1.0}};
I thought so.
Wednesday, June 15, 2011
Sleep Sort
Every so often a certain notorious image board (which shall not be named, lest it is summoned) pops out a gold nugget. I preset sleep sort:
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shiftdone
wait
It works like this: Imagine you had a room full of people and you each hand them a number between let say 1 and 100. Whatever number that person gets, they wait for that amount of time in minutes and then they write their number down on a white board.
People with the highest numbers will wait for much longer times and people with small numbers will wait less. So the person who got 1, will only wait for one minute and write down their number, the person who got 2 has to wait longer than the person who got 1 to write their number and so on. There you have it sleep sort, instead of minutes it works in seconds.
It's an interesting and new idea on sorting. The problem with it is that it has a terrible worst case and best case. It takes as long as the highest number to sort. So if you wanted to sort some numbers such as 1, 2, 3, 78943893 it would take 78943893 seconds to sort 4 numbers.
This could be fixed by calling some kind of notify whenever a number was printed. This actually seems like a perfect application for a parallel processing. Have each thread sleep, but upon printing out a sorted value, notify all the threads which are still sleeping that they can proceed to process the next one in line with the least amount of sleep time remaining.
What is more fascinating about this is the simplicity of it all. I doubt we'll see this taking over as the default sorting procedure but it is a very humorous and elegant piece of code.
I've whipped up some quick Java code which should re-create this bash script but haven't tested it. Later on I plan to see if I can write it up as a parallel program with the fixes I've suggested.
public void f(int s)
{
Thread.sleep(s);
system.out.println(s);
}
public void main()
{
String sortMe = "9 0 4 56 5 9 1 2 3 64 7 9";
StringTokenizer t = new StringTokenizer(sortMe, " ");
while (t. hasMoreTokens())
{
f(t.nextElement());
}
}
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shiftdone
wait
It works like this: Imagine you had a room full of people and you each hand them a number between let say 1 and 100. Whatever number that person gets, they wait for that amount of time in minutes and then they write their number down on a white board.
People with the highest numbers will wait for much longer times and people with small numbers will wait less. So the person who got 1, will only wait for one minute and write down their number, the person who got 2 has to wait longer than the person who got 1 to write their number and so on. There you have it sleep sort, instead of minutes it works in seconds.
It's an interesting and new idea on sorting. The problem with it is that it has a terrible worst case and best case. It takes as long as the highest number to sort. So if you wanted to sort some numbers such as 1, 2, 3, 78943893 it would take 78943893 seconds to sort 4 numbers.
This could be fixed by calling some kind of notify whenever a number was printed. This actually seems like a perfect application for a parallel processing. Have each thread sleep, but upon printing out a sorted value, notify all the threads which are still sleeping that they can proceed to process the next one in line with the least amount of sleep time remaining.
What is more fascinating about this is the simplicity of it all. I doubt we'll see this taking over as the default sorting procedure but it is a very humorous and elegant piece of code.
I've whipped up some quick Java code which should re-create this bash script but haven't tested it. Later on I plan to see if I can write it up as a parallel program with the fixes I've suggested.
public void f(int s)
{
Thread.sleep(s);
system.out.println(s);
}
public void main()
{
String sortMe = "9 0 4 56 5 9 1 2 3 64 7 9";
StringTokenizer t = new StringTokenizer(sortMe, " ");
while (t. hasMoreTokens())
{
f(t.nextElement());
}
}
Wednesday, June 8, 2011
SideNote: Starcraft
Same as previous post I've been play starcraft too. More facts.
(Don't worry next post I go back to OpenGL...been procrastinating on it since its been so hot, and with no AC in my apartment its easier to play video games than it is to program...terrible excuse I know)
This graphic was designed by Lorena O'Neal, you can check out more of
her work here (http://www.onlinegraphicdesignschools.org/)
her work here (http://www.onlinegraphicdesignschools.org/)
Side Note: WOW
So I've recently been play world of warcraft for the first time and its kinda of fun, but I think I'll be done with it once the 30 day trial is up.
Here are some interesting stats about it.
Here are some interesting stats about it.
This graphic was designed by Lorena O'Neal, you can
check out more of her work here (http://videogamedesigncolleges.org/)
check out more of her work here (http://videogamedesigncolleges.org/)
Wednesday, June 1, 2011
iPhone OpenGL ES
So I already know how to program on the iPhone for the most part since I took on a small project for work for a few months.
Today I decided to explore the functionality of the device a bit more by checking out OpenGL ES.
About 2 years ago I did a course on OpenGL, but I quickly realized that I wouldn't be able to just copy paste my old code and expect it to work. Things are a bit different in the iPhone setup (and the fact that my old code is written in C, the iPhone usesC++[oops I meant Objective-C])
After a bit (read: a lot) of googling, I was able to get a basic setup done. Its a shame that the default one apple provides starts the application off with using shaders, which even for someone who took a class on this 2 years ago was a bit tough. In the end though I was able to get a triangle drawn and rotate it. Pictures? I do think so!
*Note that though in the last screenshot the triangle should have been rotating it rather looks like its just moving up. I'm not 100% sure why this is, but I think it might have something to do with my view projections. I'll be working on this again tomorrow and trying to get some better results.
Also 100 + followers. Yay!
Today I decided to explore the functionality of the device a bit more by checking out OpenGL ES.
About 2 years ago I did a course on OpenGL, but I quickly realized that I wouldn't be able to just copy paste my old code and expect it to work. Things are a bit different in the iPhone setup (and the fact that my old code is written in C, the iPhone uses
After a bit (read: a lot) of googling, I was able to get a basic setup done. Its a shame that the default one apple provides starts the application off with using shaders, which even for someone who took a class on this 2 years ago was a bit tough. In the end though I was able to get a triangle drawn and rotate it. Pictures? I do think so!
Some of the code, there is more but these two functions are the heart of it all |
The multicolored triangle |
It's rotating* |
Also 100 + followers. Yay!
Subscribe to:
Posts (Atom)